-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #212 from aabadie/drv_rgbled_pwm
drv: add library to support rgbled via 3 pwm pins
- Loading branch information
Showing
14 changed files
with
286 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#ifndef __RGBLED_PWM_H | ||
#define __RGBLED_PWM_H | ||
|
||
/** | ||
* @file rgbled_pwm.h | ||
* @addtogroup DRV | ||
* | ||
* @brief Cross-platform declaration "rgbled pwm" driver module. | ||
* | ||
* @author Alexandre Abadie <[email protected]> | ||
* | ||
* @copyright Inria, 2023 | ||
*/ | ||
|
||
#include <stdlib.h> | ||
#include <stdint.h> | ||
|
||
#include "gpio.h" | ||
#include "pwm.h" | ||
|
||
//=========================== definitions ====================================== | ||
|
||
typedef struct { | ||
const gpio_t pins[3]; // red: 0, green: 1, blue: 2 | ||
} db_rgbled_pwm_conf_t; | ||
|
||
//=========================== public =========================================== | ||
|
||
/** | ||
* @brief Initialize the RGB LED pins | ||
* | ||
* @param[in] conf Configuration for the RGB LED pins | ||
*/ | ||
void db_rgbled_pwm_init(const db_rgbled_pwm_conf_t *conf); | ||
|
||
/** | ||
* @brief Set the color of the RGB LED | ||
* | ||
* @param[output] payload Decoded payload contained in the input buffer | ||
*/ | ||
void db_rgbled_pwm_set_color(uint8_t red, uint8_t green, uint8_t blue); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
* @file rgbled_pwm.c | ||
* @addtogroup DRV | ||
* | ||
* @brief Implementation of the "rgbled pwm" driver module. | ||
* | ||
* @author Alexandre Abadie <[email protected]> | ||
* | ||
* @copyright Inria, 2023 | ||
*/ | ||
|
||
#include <stdbool.h> | ||
#include <stdint.h> | ||
#include <string.h> | ||
|
||
#include "rgbled_pwm.h" | ||
#include "pwm.h" | ||
|
||
//=========================== definitions ====================================== | ||
|
||
#define PWM_CHANNELS (3) | ||
#define PWM_MAX_VALUE (UINT8_MAX) | ||
|
||
//=========================== public =========================================== | ||
|
||
void db_rgbled_pwm_init(const db_rgbled_pwm_conf_t *conf) { | ||
db_pwm_init(1, conf->pins, PWM_CHANNELS, PWM_MAX_VALUE); | ||
} | ||
|
||
void db_rgbled_pwm_set_color(uint8_t red, uint8_t green, uint8_t blue) { | ||
uint16_t pwm_seq[PWM_CHANNELS] = { red, green, blue }; | ||
db_pwm_channels_set(1, pwm_seq); | ||
} |
Oops, something went wrong.