Skip to content

Commit 258d220

Browse files
authored
Merge pull request #1 from cparata/master
First release for X-NUCLEO-LED61A1
2 parents 20c679f + a0b2690 commit 258d220

File tree

9 files changed

+922
-1
lines changed

9 files changed

+922
-1
lines changed

LICENSE.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
COPYRIGHT(c) 2017 STMicroelectronics
2+
3+
Redistribution and use in source and binary forms, with or without modification,
4+
are permitted provided that the following conditions are met:
5+
1. Redistributions of source code must retain the above copyright notice,
6+
this list of conditions and the following disclaimer.
7+
2. Redistributions in binary form must reproduce the above copyright notice,
8+
this list of conditions and the following disclaimer in the documentation
9+
and/or other materials provided with the distribution.
10+
3. Neither the name of STMicroelectronics nor the names of its contributors
11+
may be used to endorse or promote products derived from this software
12+
without specific prior written permission.
13+
14+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
18+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
21+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
22+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,25 @@
11
# X-NUCLEO-LED61A1
2-
Arduino library to support DC-DC LED driver based on LED6001 component
2+
3+
The X-NUCLEO-LED61A1 is an expansion board based on LED6001. The expansion board is equipped with a single-channel,
4+
constant-current LED driver for boost or SEPIC topologies. The X-NUCLEO interfaces with the STM32 microcontroller.
5+
It is compatible with the Arduino™ UNO R3 connector. The brightness of the LED string connected to its output can be
6+
controlled through a PWM signal (0 % - 100 % dimming) or a control voltage (analog dimming). Open/Short LED fault,
7+
feedback disconnection, LED overcurrent and output-to-ground short-circuit (SEPIC only) faults are detected and managed
8+
through the LED driver. The expansion board is designed to provide examples for applications involving several LEDs
9+
arranged is a single string (e.g., indoor and architectural LED lighting, off-grid street lighting, emergency LED lighting,
10+
white goods, gaming, etc.).
11+
12+
# Examples
13+
14+
There is 1 example with the X-NUCLEO-LED61A1 library.
15+
* X_NUCLEO_LED61A1_HelloWorld: This application provides a simple example of usage of the X-NUCLEO-LED61A1
16+
LED Control Expansion Board. It shows how to control a LED stripe load connected to the board by means
17+
of a sinusoidal wave form injected into the PWM dimming control pin.
18+
19+
## Documentation
20+
21+
You can find the source files at
22+
https://github.com/stm32duino/X-NUCLEO-LED61A1
23+
24+
The LED6001 datasheet is available at
25+
http://www.st.com/content/st_com/en/products/power-management/led-drivers/boost-current-regulators-for-led/led6001.html
Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
/**
2+
******************************************************************************
3+
* @file X_NUCLEO_LED61A1_HelloWorld.ino
4+
* @author Davide Aliprandi, STMicroelectronics
5+
* @version V1.0.0
6+
* @date October 17h, 2017
7+
* @brief Arduino test application for the STMicroelectronics X-NUCLEO-LED61A1
8+
* LED expansion board.
9+
******************************************************************************
10+
* @attention
11+
*
12+
* <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
13+
*
14+
* Redistribution and use in source and binary forms, with or without modification,
15+
* are permitted provided that the following conditions are met:
16+
* 1. Redistributions of source code must retain the above copyright notice,
17+
* this list of conditions and the following disclaimer.
18+
* 2. Redistributions in binary form must reproduce the above copyright notice,
19+
* this list of conditions and the following disclaimer in the documentation
20+
* and/or other materials provided with the distribution.
21+
* 3. Neither the name of STMicroelectronics nor the names of its contributors
22+
* may be used to endorse or promote products derived from this software
23+
* without specific prior written permission.
24+
*
25+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
29+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35+
*
36+
******************************************************************************
37+
*/
38+
39+
40+
/* Includes ------------------------------------------------------------------*/
41+
42+
/* Arduino specific header files. */
43+
#include "Arduino.h"
44+
45+
/* Component specific header files. */
46+
#include "Led6001.h"
47+
48+
49+
/* Definitions ---------------------------------------------------------------*/
50+
51+
/* PI. */
52+
#ifndef M_PI
53+
#define M_PI (3.14159265358979323846f)
54+
#endif
55+
56+
/* Loop period in micro-seconds. */
57+
#define LOOP_PERIOD_ms (5E2) /* 0.5 seconds. */
58+
59+
/* Sin period in micro-seconds. */
60+
#define LED_SIN_PERIOD_ms (1E4) /* 10 seconds. */
61+
62+
#define SerialPort Serial
63+
64+
/* Variables -----------------------------------------------------------------*/
65+
66+
/* Main loop's ticker. */
67+
unsigned long current_time, old_time;
68+
69+
/* LED Control Component. */
70+
Led6001 *led;
71+
72+
/* Interrupt flags. */
73+
static volatile bool xfault_irq_triggered = false;
74+
75+
76+
/* Functions -----------------------------------------------------------------*/
77+
78+
/**
79+
* @brief Handling the LED capabilities.
80+
* @param None.
81+
* @retval None.
82+
*/
83+
void led_handler(void)
84+
{
85+
static int tick = 0;
86+
87+
/* Handling the LED dimming when powered ON. */
88+
float dimming = 0.5f * sin(2 * M_PI * (tick++ * LOOP_PERIOD_ms) / LED_SIN_PERIOD_ms) + 0.5f;
89+
tick %= (int) (LED_SIN_PERIOD_ms / LOOP_PERIOD_ms);
90+
91+
SerialPort.print("Sinusoidal PWM Dimming --> ");
92+
SerialPort.print(dimming);
93+
SerialPort.print("\r");
94+
95+
/*
96+
Writing PWM dimming values to the LED.
97+
98+
Notes:
99+
+ Use "set_pwm_dimming()" for a PWM control, or "set_analog_dimming()"
100+
for an analog control.
101+
*/
102+
led->set_analog_dimming(dimming);
103+
}
104+
105+
/**
106+
* @brief Interrupt Request for the component's XFAULT interrupt.
107+
* @param None.
108+
* @retval None.
109+
*/
110+
void xfault_irq(void)
111+
{
112+
xfault_irq_triggered = true;
113+
}
114+
115+
/**
116+
* @brief Interrupt Handler for the component's XFAULT interrupt.
117+
* @param None.
118+
* @retval None.
119+
*/
120+
void xfault_handler(void)
121+
{
122+
/* Printing to the console. */
123+
SerialPort.print("XFAULT Interrupt detected! Re-initializing LED driver...");
124+
125+
/* Re-starting-up LED Control Component. */
126+
led->start_up();
127+
128+
/* Printing to the console. */
129+
SerialPort.print("Done.\r\n\n");
130+
}
131+
132+
/**
133+
* @brief Initialization.
134+
* @param None.
135+
* @retval None.
136+
*/
137+
void setup()
138+
{
139+
/* Printing to the console. */
140+
SerialPort.begin(115200);
141+
SerialPort.print("LED Control Application Example\r\n\n");
142+
143+
/* Initializing LED Control Component. */
144+
led = new Led6001(D4, A3, D6, D5);
145+
if (led->init() != COMPONENT_OK) {
146+
exit(EXIT_FAILURE);
147+
}
148+
149+
/* Attaching interrupt request functions. */
150+
led->attach_xfault_irq(&xfault_irq);
151+
152+
/* Starting-up LED Control Component. */
153+
led->start_up();
154+
old_time = millis();
155+
}
156+
157+
/**
158+
* @brief Main loop.
159+
* @param None.
160+
* @retval None.
161+
*/
162+
void loop()
163+
{
164+
current_time = millis();
165+
166+
/* Either performing the component handler, interrupt handlers, or waiting for events. */
167+
if (current_time - old_time >= LOOP_PERIOD_ms) {
168+
led_handler();
169+
old_time = current_time;
170+
} else if (xfault_irq_triggered) {
171+
xfault_irq_triggered = false;
172+
xfault_handler();
173+
}
174+
}

keywords.txt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#######################################
2+
# Syntax Coloring Map For x_nucleo_led61a1
3+
#######################################
4+
5+
#######################################
6+
# Datatypes (KEYWORD1)
7+
#######################################
8+
LED6001 KEYWORD1
9+
10+
#######################################
11+
# Methods and Functions (KEYWORD2)
12+
#######################################
13+
LED6001 KEYWORD2
14+
Init KEYWORD2
15+
ReadID KEYWORD2
16+
DeInit KEYWORD2
17+
SetPwmDim KEYWORD2
18+
SetAnaDim KEYWORD2
19+
FaultStatus KEYWORD2
20+
21+
#######################################
22+
# Constants (LITERAL1)
23+
#######################################
24+
LED6001_PDIM_FULL LITERAL1
25+
LED6001_ADIM_FULL LITERAL1
26+
NULL LITERAL1

library.properties

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name=STM32duino X-NUCLEO-LED61A1
2+
version=1.0.0
3+
author=STMicroelectronics
4+
maintainer=stm32duino
5+
sentence=Allows controlling the ST Microelectronics X-NUCLEO-LED61A1 Expansion Board
6+
paragraph=This library provides the drivers and a sample application to control ST X-NUCLEO-LED61A1 expansion board
7+
category=Device Control
8+
url=https://github.com/stm32duino/X-NUCLEO-LED61A1
9+
architectures=stm32

src/Component.h

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/**
2+
******************************************************************************
3+
* @file Component.h
4+
* @author AST
5+
* @version V1.0.0
6+
* @date April 13th, 2015
7+
* @brief This file contains the abstract class describing the interface of a
8+
* generic component.
9+
******************************************************************************
10+
* @attention
11+
*
12+
* <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
13+
*
14+
* Redistribution and use in source and binary forms, with or without modification,
15+
* are permitted provided that the following conditions are met:
16+
* 1. Redistributions of source code must retain the above copyright notice,
17+
* this list of conditions and the following disclaimer.
18+
* 2. Redistributions in binary form must reproduce the above copyright notice,
19+
* this list of conditions and the following disclaimer in the documentation
20+
* and/or other materials provided with the distribution.
21+
* 3. Neither the name of STMicroelectronics nor the names of its contributors
22+
* may be used to endorse or promote products derived from this software
23+
* without specific prior written permission.
24+
*
25+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
29+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35+
*
36+
******************************************************************************
37+
*/
38+
39+
40+
/* Define to prevent recursive inclusion -------------------------------------*/
41+
42+
#ifndef __COMPONENT_CLASS_H
43+
#define __COMPONENT_CLASS_H
44+
45+
46+
/* Includes ------------------------------------------------------------------*/
47+
48+
#include <stdint.h>
49+
50+
51+
/* Classes ------------------------------------------------------------------*/
52+
53+
/**
54+
* An abstract class for Generic components.
55+
*/
56+
class Component
57+
{
58+
public:
59+
60+
/**
61+
* @brief Initializing the component.
62+
* @param[in] init pointer to device specific initalization structure.
63+
* @retval "0" in case of success, an error code otherwise.
64+
*/
65+
virtual int init(void *init) = 0;
66+
67+
/**
68+
* @brief Getting the ID of the component.
69+
* @param[out] id pointer to an allocated variable to store the ID into.
70+
* @retval "0" in case of success, an error code otherwise.
71+
*/
72+
virtual int read_id(uint8_t *id) = 0;
73+
74+
/**
75+
* @brief Destructor.
76+
*/
77+
virtual ~Component() {};
78+
};
79+
80+
#endif /* __COMPONENT_CLASS_H */
81+
82+
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

0 commit comments

Comments
 (0)