Test application for the STMicroelectronics X-NUCLEO-LED61A1 LED Control Expansion Board showing several LED control modes, built against mbed OS.
Dependencies: X_NUCLEO_LED61A1
Fork of LedDimming_LED61A1 by
LED Control with the X-NUCLEO-LED61A1 Expansion Board
This application provides an example of usage of the X-NUCLEO-LED61A1 LED Control Expansion Board. It shows how to control a LED stripe load connected to the board through the following control modes:
- Manual PWM Dimming;
- Manual Analog Dimming;
- Sinusoidal PWM Dimming;
- Sinusoidal Analog Dimming;
- Photo-based Analog Dimming.
The button of the MCU board, when available, can be used in the following ways:
- Short Button Press [<0.5s] for Manual Dimming;
- Medium Button Press to Switch Demo;
- Long Button Press [>2s] to Switch Power ON/OFF.
The program starts in mode 1.
Revision 16:e39f206f26c8, committed 2017-07-03
- Comitter:
- Davidroid
- Date:
- Mon Jul 03 09:18:12 2017 +0000
- Parent:
- 15:ea1e402ce919
- Commit message:
- mbedOS
Changed in this revision
--- a/X_NUCLEO_LED61A1.lib Mon Mar 14 12:20:07 2016 +0000 +++ b/X_NUCLEO_LED61A1.lib Mon Jul 03 09:18:12 2017 +0000 @@ -1,1 +1,1 @@ -https://developer.mbed.org/teams/ST/code/X_NUCLEO_LED61A1/#5a7ee8e28f92 +https://developer.mbed.org/teams/ST/code/X_NUCLEO_LED61A1/#8cd869d64965
--- a/main.cpp Mon Mar 14 12:20:07 2016 +0000
+++ b/main.cpp Mon Jul 03 09:18:12 2017 +0000
@@ -41,9 +41,10 @@
/* mbed specific header files. */
#include "mbed.h"
+#include "rtos.h"
/* Component specific header files. */
-#include "led6001_class.h"
+#include "Led6001.h"
/* Definitions ---------------------------------------------------------------*/
@@ -79,7 +80,7 @@
AUTOMATIC_ANALOG_DIMMING,
PHOTO_BASED_ANALOG_DIMMING,
LED_DEMO_SIZE
-} LED_Demo_t;
+} led_demo_t;
/* Actions. */
typedef enum
@@ -88,7 +89,7 @@
SWITCH_DEMO,
SWITCH_STATE,
NO_ACTION
-} LED_Action_t;
+} led_action_t;
/* Variables -----------------------------------------------------------------*/
@@ -104,7 +105,7 @@
DigitalOut button_pressed_led(LED1);
/* LED Control Component. */
-LED6001 *led;
+Led6001 *led;
/* Interrupt flags. */
static volatile bool ticker_irq_triggered = false;
@@ -112,8 +113,8 @@
static volatile bool xfault_irq_triggered = false;
/* Demo State. */
-static volatile LED_Demo_t demo;
-static volatile LED_Action_t action;
+static volatile led_demo_t demo;
+static volatile led_action_t action;
static volatile bool power_on;
/* Demos' Names. */
@@ -134,11 +135,11 @@
* @param None.
* @retval None.
*/
-void InitDemo(void)
+void init_demo(void)
{
power_on = true;
action = SWITCH_DEMO;
- demo = (LED_Demo_t) (LED_DEMO_SIZE - 1);
+ demo = (led_demo_t) (LED_DEMO_SIZE - 1);
}
/**
@@ -146,7 +147,7 @@
* @param None.
* @retval None.
*/
-void LEDHandler(void)
+void led_handler(void)
{
static int tick = 0;
static float pwm_dimming;
@@ -170,7 +171,7 @@
printf("%-56s\r", "Power OFF");
/* Powering OFF the LED. */
- led->PowerOFF();
+ led->power_off();
}
}
@@ -183,7 +184,7 @@
pwm_dimming = 1.0f;
analog_dimming = 1.0f;
tick = 0;
- demo = (LED_Demo_t) ((demo + 1) % LED_DEMO_SIZE);
+ demo = (led_demo_t) ((demo + 1) % LED_DEMO_SIZE);
}
/* Setting the LED dimming depending on the selected demo. */
@@ -223,7 +224,7 @@
/* Setting Analog dimming according to the photo sensor. */
case PHOTO_BASED_ANALOG_DIMMING:
- analog_dimming = 1.0f - led->GetCurrent();
+ analog_dimming = 1.0f - led->get_current();
action = SWITCH_STATE;
break;
}
@@ -235,8 +236,8 @@
printf("%d) %-26s --> Dimming: %0.2f\r", demo + 1, demos[demo], demo == MANUAL_PWM_DIMMING || demo == AUTOMATIC_PWM_DIMMING ? pwm_dimming : analog_dimming);
/* Writing PWM and Analog dimming values to the LED. */
- led->SetPWMDimming(pwm_dimming);
- led->SetAnalogDimming(analog_dimming);
+ led->set_pwm_dimming(pwm_dimming);
+ led->set_analog_dimming(analog_dimming);
}
}
@@ -249,7 +250,7 @@
* @param None.
* @retval None.
*/
-void TickerIRQ(void)
+void ticker_irq(void)
{
ticker_irq_triggered = true;
}
@@ -259,7 +260,7 @@
* @param None.
* @retval None.
*/
-void ButtonIRQ(void)
+void button_irq(void)
{
button_irq_triggered = true;
button.disable_irq();
@@ -270,10 +271,10 @@
* @param None.
* @retval None.
*/
-void XFaultIRQ(void)
+void xfault_irq(void)
{
xfault_irq_triggered = true;
- led->DisableXFaultIRQ();
+ led->disable_xfault_irq();
}
/**
@@ -281,7 +282,7 @@
* @param None.
* @retval None.
*/
-void ButtonHandler(void)
+void button_handler(void)
{
/* User Button's timer to measure the time the button remains pressed. */
static Timer button_pressed_timer;
@@ -318,21 +319,21 @@
* @param None.
* @retval None.
*/
-void XFaultHandler(void)
+void xfault_handler(void)
{
/* Printing to the console. */
printf("XFAULT Interrupt detected! Re-initializing LED driver...");
/* Re-starting-up LED Control Component. */
- led->StartUp();
+ led->start_up();
/* Printing to the console. */
printf("Done.\r\n\n");
/* Re-initializing the demo. */
- InitDemo();
+ init_demo();
- led->EnableXFaultIRQ();
+ led->enable_xfault_irq();
}
@@ -355,22 +356,22 @@
, SWITCH_DEMO_BUTTON_PRESS_ms / 1000.0f, SWITCH_POWER_BUTTON_PRESS_ms / 1000.0f);
/* Initializing LED Control Component. */
- led = new LED6001(D4, A3, D6, D5);
- if (led->Init() != COMPONENT_OK)
+ led = new Led6001(D4, A3, D6, D5);
+ if (led->init() != COMPONENT_OK)
exit(EXIT_FAILURE);
/* Attaching interrupt request functions. */
- button.fall(ButtonIRQ);
- button.rise(ButtonIRQ);
- led->AttachXFaultIRQ(&XFaultIRQ);
- led->EnableXFaultIRQ();
- ticker.attach_us(TickerIRQ, LOOP_PERIOD_us);
+ button.fall(button_irq);
+ button.rise(button_irq);
+ led->attach_xfault_irq(&xfault_irq);
+ led->enable_xfault_irq();
+ ticker.attach_us(ticker_irq, LOOP_PERIOD_us);
/* Starting-up LED Control Component. */
- led->StartUp();
+ led->start_up();
/* Initializing the demo. */
- InitDemo();
+ init_demo();
/*----- LED Control. -----*/
@@ -381,15 +382,15 @@
if (ticker_irq_triggered)
{
ticker_irq_triggered = false;
- LEDHandler();
+ led_handler();
} else if (button_irq_triggered)
{
button_irq_triggered = false;
- ButtonHandler();
+ button_handler();
} else if (xfault_irq_triggered)
{
xfault_irq_triggered = false;
- XFaultHandler();
+ xfault_handler();
} else {
/* It is recommended that SEVONPEND in the System Control Register is NOT set. */
__WFE();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-os.lib Mon Jul 03 09:18:12 2017 +0000 @@ -0,0 +1,1 @@ +https://github.com/ARMmbed/mbed-os/#c9e63f14085f5751ff5ead79a7c0382d50a813a2
--- a/mbed.bld Mon Mar 14 12:20:07 2016 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/165afa46840b \ No newline at end of file
