CROSS Technical Documentation User Manual and Technical Doc.
INFN Milano Bicocca
Loading...
Searching...
No Matches
Led.c
Go to the documentation of this file.
1
2
3
4#include "tutti_gli_header.h"
5
6
7// DOCUMENTAZIONE DOXYGEN
8/// \file
9
10/*! \page LEDs The LEDs
11\anchor LEDs
12*\brief <span style="color:red;"> <b> The RED and GREEN LEDs </b> </span>
13*\tableofcontents
14
15 \b SUMMARY:
16- \ref LED_short_description
17 - \ref Start_up
18 - \ref Standby
19 - \ref Command_Execution
20- \ref LED_functions
21 - \ref LED_on_off
22 - \ref LED_flash
23
24*\section LED_short_description Short Description about LED
25<hr width="90%" size="10" align="left">
26\n There are 4 LEDs on the front panel of the post front-end. A pair of RED and GREEN LEDs marks the activity of the CAN-bus over
27the optical fibers. The second pair of LEDs, RED and GREEN, too, marks the activity of the board itself. The lighting modalities are descrbed in the following.
28
29\subsection Start_up Start up
30As soon as the board is powered the GREEN LED is maintained OFF and the RED LED is ON.
31\subsection Standby Standby
32When the &micro;-controler terminates the operations the GREEN LED is maintained ON and will flash just befor the &micro;-controler is going to power down.
33\subsection Command_Execution Command Execution
34During commands executions both the RED and GREEN LEDs flash, the GREEN one with a period that is one half that
35of the RED LED.
36In case of short commands the GREEN LED remain ON while the RED LED flashes at a fast speed for a time much longer
37of that of the command.
38
39*\section LED_functions LED functions and switches
40<hr width="90%" size="10" align="left">
41\n LEDs are operated both with fixed light and flashing.
42
43\subsection LED_on_off LEDs static operation
44Top operate the LEDs at fixed light the function LED_accendi_spegni(uint8_t LED, uint8_t accendi_1_spegni_0)
45must be run where
46\b LED can be #LED_RED or #LED_GREEN, and \b accendi_1_spegni_0 is #accendi or #spegni.
47
48\subsection LED_flash LED flashing
49Top operate the LEDs in flashing mode the variable #LED_verde_attivo and #LED_rosso_attivo must be set to \b true.
50When any of these variables are \b true the functions LED_RED_lampeggio() and/or LED_VERDE_lampeggio() are called at every interrupt of SysTick_Handler().
51The flashing duty cycle is set in ms by #LED_rosso_fondo_scala and #LED_verde_fondo_scala.
52
53*/
54
55volatile uint16_t LED_rosso_tempo =0;
56volatile uint16_t LED_rosso_fondo_scala =1000; /**< ... */
57volatile uint8_t LED_rosso_attivo =0; /**< ... */
58volatile uint8_t prolungamento=0;
59volatile uint8_t acceso=1;
60
61volatile uint8_t LED_verde_attivo =0; /**< ... */
62volatile uint16_t LED_verde_tempo =0;
63volatile uint16_t LED_verde_fondo_scala =500; /**< ... */
64
65volatile bool LED_remote_control=false;
66volatile uint8_t LED_remote_control_setting=0;
67
68/*! \brief This function toggles the Red LED and it is launched by SysTick_Handler()
69every time LED_rosso_tempo equals LED_rosso_fondo_scala. Count enable needs
70LED_rosso_attivo to be true
71
72*\return No Parameters
73 \showrefby
74*\snippet{lineno} Led.c fun_LED_RED_lampeggio
75 */
76//! <!-- [fun_LED_RED_lampeggio] -->
78
79
80 if (acceso) {
81 acceso=0;
82 }else{
83 acceso=1;
84 }
85 GPIO_PinWrite(LED_Red.porta_num, LED_Red.pin_num, acceso);
86}
87//! <!-- [fun_LED_RED_lampeggio] -->
88
89
90
91/*! \brief This function toggles the green LED and it is launched by SysTick_Handler()
92every time LED_verde_tempo equals LED_verde_fondo_scala. Count enable needs
93LED_verde_attivo to be true
94
95*\return No Parameters
96 \showrefby
97*\snippet{lineno} Led.c fun_LED_VERDE_lampeggio
98 */
99//! <!-- [fun_LED_VERDE_lampeggio] -->
101 static uint8_t acceso=1;
102
103 if (acceso) {
104 acceso=0;
105 }else{
106 acceso=1;
107 }
108
109 GPIO_PinWrite(LED_Green.porta_num, LED_Green.pin_num, acceso);
110}
111//! <!-- [fun_LED_VERDE_lampeggio] -->
112
113
114/*! \brief This function turns ON or OFF any of the selcted LED
115
116\param[in] LED : the LED to operate
117\param[in] accendi_1_spegni_0 : what to do with the selcted LED
118*\return No Parameters
119 \showrefby
120*\snippet{lineno} Led.c fun_LED_accendi_spegni
121 */
122//! <!-- [fun_LED_accendi_spegni] -->
123void LED_accendi_spegni(uint8_t LED, uint8_t accendi_1_spegni_0){
124
125 if(accendi_1_spegni_0 <=1){
126 if (LED == LED_RED){
127 GPIO_PinWrite(LED_Red.porta_num, LED_Red.pin_num, accendi_1_spegni_0);
128 }else if(LED == LED_GREEN){
129 GPIO_PinWrite(LED_Green.porta_num, LED_Green.pin_num, accendi_1_spegni_0);
130 }
131 }
132}
133//! <!-- [fun_LED_accendi_spegni] -->
134
135
136/*! \brief LEDs can be set ON/OFF
137
138*\return No Parameters
139\showrefby
140\showrefs
141*\snippet{lineno} Led.c fun_instr_LED_ON_OFF_function
142 */
143//! <!-- [fun_instr_LED_ON_OFF_function] -->
145
146 LED_remote_control = rx_data[5]; //! This is tested in the while(1): the setting below remains if it is 1
147 LED_remote_control_setting=rx_data[6]; //! This is the setting that remains if the remote control is 1
148
149}
150//! <!-- [fun_instr_LED_ON_OFF_function] -->
151
152
153/*! \brief LEDs can be set ON/OFF from remote
154
155*\return No Parameters
156\showrefby
157\showrefs
158*\snippet{lineno} Led.c fun_LED_remote_ON_OFF
159 */
160//! <!-- [fun_LED_remote_ON_OFF] -->
162
163 if( LED_remote_control){
164 prolungamento=0;
167 if( LED_remote_control_setting & 1){
168 //LED ON
170 }else{
171 //LED OFF
173 }
174 if( LED_remote_control_setting & 2){
175 //LED on
177 }else{
178 //Led off
180 }
181 }
182}
183//! <!-- [fun_LED_remote_ON_OFF] -->
184
185
volatile uint8_t rx_data[8]
Received data vector.
Definition: Can.c:318
const porta_pin_def LED_Red
Green LED.
Definition: Gpio.c:161
const porta_pin_def LED_Green
Green LED.
Definition: Gpio.c:160
void LED_remote_ON_OFF(void)
LEDs can be set ON/OFF from remote.
Definition: Led.c:161
void LED_accendi_spegni(uint8_t LED, uint8_t accendi_1_spegni_0)
This function turns ON or OFF any of the selcted LED.
Definition: Led.c:123
volatile uint8_t LED_rosso_attivo
Definition: Led.c:57
void LED_VERDE_lampeggio(void)
This function toggles the green LED and it is launched by SysTick_Handler() every time LED_verde_temp...
Definition: Led.c:100
volatile uint16_t LED_verde_fondo_scala
Definition: Led.c:63
void instr_LED_ON_OFF_function(void)
LEDs can be set ON/OFF.
Definition: Led.c:144
volatile uint16_t LED_rosso_fondo_scala
Definition: Led.c:56
volatile uint8_t LED_verde_attivo
Definition: Led.c:61
void LED_RED_lampeggio(void)
This function toggles the Red LED and it is launched by SysTick_Handler() every time LED_rosso_tempo ...
Definition: Led.c:77
#define LED_RED
Definition: Led.h:10
#define spegni
Definition: Led.h:13
#define LED_GREEN
Definition: Led.h:11
#define accendi
Definition: Led.h:12