4 * This file is part of BeRTOS.
6 * Bertos is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 * As a special exception, you may use this file as part of a free software
21 * library without restriction. Specifically, if other files instantiate
22 * templates or use macros or inline functions from this file, or you compile
23 * this file and link it with other files to produce an executable, this
24 * file does not by itself cause the resulting executable to be covered by
25 * the GNU General Public License. This exception does not however
26 * invalidate any other reasons why the executable file might be covered by
27 * the GNU General Public License.
29 * Copyright 2010 Develer S.r.l. (http://www.develer.com/)
32 * \brief led 7 segment display low-level
34 * This file has the functions that must be
35 * implemented to drive the 7 segments display by your
38 * \author Fabio Bizzi <fbizzi@bizzi.org>
40 * \addtogroup SevenSegDisplay 7 Segments LED Displays Driver
43 * Example implementation for AtMEGA 1280
44 * (Arduino MEGA) with a 4 digit display.
45 * We use PORTA to connect the 8 pins of
46 * the 7 segments display and 4 bit of
47 * PORTC to select which digit of the
48 * display we have to write on.
61 * 7 Seg Display Selection
72 * The implementation of the sseg_on procedure that set the PROPER PIN of PORT C
73 * to enable the requested digit of the display, after write the encoded character
78 * INLINE void sseg_on(uint8_t dgt, uint8_t n_dgt)
83 * #ifdef CONFIG_LED_7SEG_CCAT
86 * PORTC &= ~(BV(PORTC1) | BV(PORTC2) | BV(PORTC3));
87 * PORTC |= BV(PORTC0);
90 * PORTC &= ~(BV(PORTC0) | BV(PORTC2) | BV(PORTC3));
91 * PORTC |= BV(PORTC1);
94 * PORTC &= ~(BV(PORTC0) | BV(PORTC1) | BV(PORTC3));
95 * PORTC |= BV(PORTC2);
98 * PORTC &= ~(BV(PORTC0) | BV(PORTC1) | BV(PORTC2));
99 * PORTC |= BV(PORTC3);
106 * PORTC |= (BV(PORTC1) | BV(PORTC2) | BV(PORTC3));
107 * PORTC &= ~(BV(PORTC0));
110 * PORTC |= (BV(PORTC0) | BV(PORTC2) | BV(PORTC3));
111 * PORTC &= ~(BV(PORTC1));
114 * PORTC |= (BV(PORTC0) | BV(PORTC1) | BV(PORTC3));
115 * PORTC &= ~(BV(PORTC2));
118 * PORTC |= (BV(PORTC0) | BV(PORTC1) | BV(PORTC2));
119 * PORTC &= ~(BV(PORTC3));
125 * //Write the charater
131 * The implementation of the sseg_init procedure that set the DIRECTION of PORT C
132 * and PORT A to output
136 * INLINE void sseg_init(void)
138 * //Initialize PIN Direction to OUTPUT
140 * DDRC |= (BV(DDC0) | BV(DDC1) | BV(DDC2) | BV(DDC3));
141 * //Set the display OFF
147 * The implementation of the sseg_off procedure that set the reset PORT A
148 * to clean the display and turn off all the pin of PORT C that drive the
153 * INLINE void sseg_off(void)
155 * //Set the display OFF
157 * #ifdef CONFIG_LED_7SEG_CCAT
159 * PORTC &= ~(BV(PORTC0) | BV(PORTC1) | BV(PORTC2) | BV(PORTC3));
163 * PORTC |= (BV(PORTC0) | BV(PORTC1) | BV(PORTC2) | BV(PORTC3));
172 #ifndef HW_LED_7SEG_H
173 #define HW_LED_7SEG_H
175 #include "cfg/cfg_led_7seg.h"
176 #include "cfg/cfg_arch.h"
177 #include <cpu/types.h>
179 #include <drv/timer.h>
183 * INLINE HW Functions
187 * \brief Clean the display
189 * This is the procedure that clean the display in HW mode.
190 * you have to write it according with your hardware and micro.
192 INLINE void sseg_off(void)
194 /* Example implementation for AtMEGA 1280
195 * (Arduino MEGA) with a 4 digit display.
196 * We use PORTA to connect the 8 pins of
197 * the 7 segments display and 4 bit of
198 * PORTC to select which digit of the
199 * display we have to write on.
202 /* Set the display OFF */
204 #ifdef CONFIG_LED_7SEG_CCAT
206 PORTC &= ~(BV(PORTC0) | BV(PORTC1) | BV(PORTC2) | BV(PORTC3));
210 PORTC |= (BV(PORTC0) | BV(PORTC1) | BV(PORTC2) | BV(PORTC3));
215 * \brief writes the character to the single digit of the display
217 * This is the procedure that writes the character to the single digit
218 * of the display, you have to write it according with your hardware and micro.
220 * \param dgt the character that has to be displayed
221 * \param n_dgt the digit where to disply the character of the display's digits.
223 INLINE void sseg_on(uint8_t dgt, uint8_t n_dgt)
225 /* Example implementation for AtMEGA 1280
226 * (Arduino MEGA) with a 4 digit display.
227 * We use PORTA to connect the 8 pins of
228 * the 7 segments display and 4 bit of
229 * PORTC to select which digit of the
230 * display we have to write on.
243 #ifdef CONFIG_LED_7SEG_CCAT
246 PORTC &= ~(BV(PORTC1) | BV(PORTC2) | BV(PORTC3));
250 PORTC &= ~(BV(PORTC0) | BV(PORTC2) | BV(PORTC3));
254 PORTC &= ~(BV(PORTC0) | BV(PORTC1) | BV(PORTC3));
258 PORTC &= ~(BV(PORTC0) | BV(PORTC1) | BV(PORTC2));
266 PORTC |= (BV(PORTC1) | BV(PORTC2) | BV(PORTC3));
267 PORTC &= ~(BV(PORTC0));
270 PORTC |= (BV(PORTC0) | BV(PORTC2) | BV(PORTC3));
271 PORTC &= ~(BV(PORTC1));
274 PORTC |= (BV(PORTC0) | BV(PORTC1) | BV(PORTC3));
275 PORTC &= ~(BV(PORTC2));
278 PORTC |= (BV(PORTC0) | BV(PORTC1) | BV(PORTC2));
279 PORTC &= ~(BV(PORTC3));
284 /* Write the charater */
289 * \brief initalize the HW regsiters
291 * This is the procedure that initalize the HW regsiters.
292 * you have to write it according with your hardware and micro.
294 INLINE void sseg_init(void)
296 /* Example implementation for AtMEGA 1280
297 * (Arduino MEGA) with a 4 digit display.
298 * We use PORTA to connect the 8 pins of
299 * the 7 segments display and 4 bit of
300 * PORTC to select which digit of the
301 * display we have to write on.
304 /* Initialize PIN Direction to OUTPUT*/
306 DDRC |= (BV(DDC0) | BV(DDC1) | BV(DDC2) | BV(DDC3));
307 /* Set the display OFF */
311 #endif /* HW_LED_7SEG_H */
313 /** \} */ //defgroup drivers