added led helper methods. Added boards.txt
This commit is contained in:
1 parent
f92c0b7c14
commit
3e66f7491b
3 files changed
+49
No files matched your search
@@ -56,6 +56,11 @@ const uint32_t g_ADigitalPinMap[] =
|
||||
void initVariant()
|
||||
{
|
||||
switch_antenna(false);
|
||||
|
||||
led_pwm_init(LED_PRIMARY_IDX, LED_PRIMARY_PIN);
|
||||
led_pwm_init(LED_RGB_RED_IDX, LED_RGB_RED_PIN);
|
||||
led_pwm_init(LED_RGB_BLUE_IDX, LED_RGB_BLUE_PIN);
|
||||
led_pwm_init(LED_RGB_GREEN_IDX, LED_RGB_GREEN_PIN);
|
||||
}
|
||||
|
||||
void switch_antenna(bool useExternal) {
|
||||
@@ -106,6 +111,33 @@ void led_pwm_duty_cycle(uint32_t led_index, uint16_t duty_cycle) {
|
||||
nrf_pwm_task_trigger(NRF_PWM0, NRF_PWM_TASK_SEQSTART0);
|
||||
}
|
||||
|
||||
void ledWrite(uint32_t led_pin, uint8_t value) {
|
||||
uint32_t index = -1;
|
||||
switch (led_pin) {
|
||||
case LED_PRIMARY_PIN:
|
||||
index = LED_PRIMARY_IDX;
|
||||
break;
|
||||
case LED_RGB_RED_PIN:
|
||||
index = LED_RGB_RED_IDX;
|
||||
break;
|
||||
case LED_RGB_GREEN_PIN:
|
||||
index = LED_RGB_GREEN_IDX;
|
||||
break;
|
||||
case LED_RGB_BLUE_PIN:
|
||||
index = LED_RGB_BLUE_IDX;
|
||||
break;
|
||||
}
|
||||
|
||||
if (index != -1)
|
||||
led_pwm_duty_cycle(index, value);
|
||||
}
|
||||
|
||||
void rgbLedWrite(uint8_t red, uint8_t green, uint8_t blue) {
|
||||
led_pwm_duty_cycle(LED_RGB_RED_IDX, red);
|
||||
led_pwm_duty_cycle(LED_RGB_GREEN_IDX, green);
|
||||
led_pwm_duty_cycle(LED_RGB_BLUE_IDX, blue);
|
||||
}
|
||||
|
||||
void pwm_teardown(NRF_PWM_Type* pwm) {
|
||||
pwm->TASKS_SEQSTART[0] = 0;
|
||||
pwm->ENABLE = 0;
|
||||
|
||||
@@ -197,6 +197,8 @@ void led_pwm_init(uint32_t led_index, uint32_t led_pin);
|
||||
void led_pwm_teardown(void);
|
||||
void led_pwm_duty_cycle(uint32_t led_index, uint16_t duty_cycle);
|
||||
void pwm_teardown(NRF_PWM_Type* pwm);
|
||||
void ledWrite(uint32_t led_pin, uint8_t value);
|
||||
void rgbLedWrite(uint8_t red, uint8_t green, uint8_t blue);
|
||||
static uint16_t led_duty_cycles[PWM0_CH_NUM] = { 0 };
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
Reference in new issue
Block a user