From 7b5f3900adeee7a161259f0ae7cb14ab4ed6a69f Mon Sep 17 00:00:00 2001 From: Oliver Hahm Date: Mon, 13 Dec 2010 21:19:58 +0100 Subject: [PATCH 01/11] [board/chronos/drivers] * simple buzzer driver --- chronos/Jamrules.chronos | 2 ++ chronos/drivers/Jamfile | 3 +++ chronos/drivers/buzzer.c | 27 +++++++++++++++++++++++++ chronos/drivers/include/buzzer.h | 6 ++++++ chronos/drivers/{ => include}/display.h | 0 5 files changed, 38 insertions(+) create mode 100644 chronos/drivers/buzzer.c create mode 100644 chronos/drivers/include/buzzer.h rename chronos/drivers/{ => include}/display.h (100%) diff --git a/chronos/Jamrules.chronos b/chronos/Jamrules.chronos index 4c975ae1f9..4c17a9a9ae 100644 --- a/chronos/Jamrules.chronos +++ b/chronos/Jamrules.chronos @@ -7,6 +7,8 @@ BOARD = chronos ; CPU = cc430 ; MCU = cc430x6137 ; +HDRS += [ FPath $(TOP) board chronos drivers include ] ; + FLASHER ?= mspdebug ; FLASHFLAGS ?= rf2500 ; diff --git a/chronos/drivers/Jamfile b/chronos/drivers/Jamfile index 4b2a0d0a85..d89390029d 100644 --- a/chronos/drivers/Jamfile +++ b/chronos/drivers/Jamfile @@ -1,4 +1,7 @@ SubDir TOP board chronos drivers ; +HDRS += $(TOP)/board/$(CPU)/drivers/include ; + Module board_display : display.c display1.c ; Module board_cc110x : cc430-cc110x.c : cc110x_cc430 ; +Module board_buzzer : buzzer.c : hwtimer ; diff --git a/chronos/drivers/buzzer.c b/chronos/drivers/buzzer.c new file mode 100644 index 0000000000..79002f992c --- /dev/null +++ b/chronos/drivers/buzzer.c @@ -0,0 +1,27 @@ +#include +#include +#include + +void buzzer_beep(uint8_t pitch, uint16_t duration) { + // Reset TA1R, set up mode, TA1 runs from 32768Hz ACLK + TA1CTL = TACLR | MC_1 | TASSEL__ACLK; + + // Set PWM frequency + TA1CCR0 = pitch; + + // Enable IRQ, set output mode "toggle" + TA1CCTL0 = OUTMOD_4; + + // Allow buzzer PWM output on P2.7 + P2SEL |= BIT7; + + hwtimer_wait(duration); + + // Stop PWM timer + TA1CTL &= ~(BIT4 | BIT5); + + // Reset and disable buzzer PWM output + P2OUT &= ~BIT7; + P2SEL &= ~BIT7; + TA1CCTL0 &= ~CCIE; +} diff --git a/chronos/drivers/include/buzzer.h b/chronos/drivers/include/buzzer.h new file mode 100644 index 0000000000..1786b0c513 --- /dev/null +++ b/chronos/drivers/include/buzzer.h @@ -0,0 +1,6 @@ +#ifndef BUZZER_H +#define BUZZER_H + +void buzzer_beep(uint8_t pitch, uint16_t duration); + +#endif /* BUZZER_H */ diff --git a/chronos/drivers/display.h b/chronos/drivers/include/display.h similarity index 100% rename from chronos/drivers/display.h rename to chronos/drivers/include/display.h From d2e45cdf5942870739e13651c5edd24f5276550c Mon Sep 17 00:00:00 2001 From: Oliver Hahm Date: Tue, 14 Dec 2010 00:24:42 +0100 Subject: [PATCH 02/11] [cpu/cc430/gpioint] * introduced gpioint to make buttons usable --- chronos/drivers/buzzer.c | 1 + chronos/include/buttons.h | 11 +++++++++++ 2 files changed, 12 insertions(+) create mode 100644 chronos/include/buttons.h diff --git a/chronos/drivers/buzzer.c b/chronos/drivers/buzzer.c index 79002f992c..5e0bc2ca34 100644 --- a/chronos/drivers/buzzer.c +++ b/chronos/drivers/buzzer.c @@ -1,5 +1,6 @@ #include #include +#include #include void buzzer_beep(uint8_t pitch, uint16_t duration) { diff --git a/chronos/include/buttons.h b/chronos/include/buttons.h new file mode 100644 index 0000000000..4e7ab28dca --- /dev/null +++ b/chronos/include/buttons.h @@ -0,0 +1,11 @@ +#ifndef BUTTONS_H +#define BUTTONS_H + +// Button ports +#define BUTTON_STAR_PIN (BIT2) +#define BUTTON_NUM_PIN (BIT1) +#define BUTTON_UP_PIN (BIT4) +#define BUTTON_DOWN_PIN (BIT0) +#define BUTTON_BACKLIGHT_PIN (BIT3) + +#endif From 6ff96f0ab104064b55851e32e2ffb625a3e370c8 Mon Sep 17 00:00:00 2001 From: Kaspar Schleiser Date: Tue, 14 Dec 2010 11:39:52 +0100 Subject: [PATCH 03/11] * minor file rename --- msb-430-common/Jamfile | 2 +- msb-430-common/{debug_uart.c => uart1.c} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename msb-430-common/{debug_uart.c => uart1.c} (100%) diff --git a/msb-430-common/Jamfile b/msb-430-common/Jamfile index 17bf86c9bb..b59f8c4748 100644 --- a/msb-430-common/Jamfile +++ b/msb-430-common/Jamfile @@ -27,7 +27,7 @@ SubDir TOP board msb-430-common ; -Module board : board_init.c debug_uart.c ; +Module board : board_init.c uart1.c ; Module board_config : board_config.c ; UseModule board ; diff --git a/msb-430-common/debug_uart.c b/msb-430-common/uart1.c similarity index 100% rename from msb-430-common/debug_uart.c rename to msb-430-common/uart1.c From b473e44b561a74dd60616b2c0f95eab6d0749991 Mon Sep 17 00:00:00 2001 From: Kaspar Schleiser Date: Tue, 14 Dec 2010 16:40:47 +0100 Subject: [PATCH 04/11] * chronos display putchar included --- chronos/Jamfile | 2 +- chronos/drivers/Jamfile | 2 ++ chronos/drivers/display_putchar.c | 42 +++++++++++++++++++++++ chronos/drivers/include/display_putchar.h | 6 ++++ chronos/putchar.c | 11 ++++++ msb-430-common/putchar.c | 7 ++++ 6 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 chronos/drivers/display_putchar.c create mode 100644 chronos/drivers/include/display_putchar.h create mode 100644 chronos/putchar.c create mode 100644 msb-430-common/putchar.c diff --git a/chronos/Jamfile b/chronos/Jamfile index bf3341d785..0899e4631b 100644 --- a/chronos/Jamfile +++ b/chronos/Jamfile @@ -2,7 +2,7 @@ SubDir TOP board chronos ; HDRS += $(TOP)/board/$(CPU)/include ; -Module board : debug_uart.c board_init.c ; +Module board : putchar.c board_init.c ; UseModule board ; SubInclude TOP board $(BOARD) drivers ; diff --git a/chronos/drivers/Jamfile b/chronos/drivers/Jamfile index d89390029d..54d2fb4e7b 100644 --- a/chronos/drivers/Jamfile +++ b/chronos/drivers/Jamfile @@ -5,3 +5,5 @@ HDRS += $(TOP)/board/$(CPU)/drivers/include ; Module board_display : display.c display1.c ; Module board_cc110x : cc430-cc110x.c : cc110x_cc430 ; Module board_buzzer : buzzer.c : hwtimer ; + +Module display_putchar : display_putchar.c : board_display ; diff --git a/chronos/drivers/display_putchar.c b/chronos/drivers/display_putchar.c new file mode 100644 index 0000000000..2f1d9468af --- /dev/null +++ b/chronos/drivers/display_putchar.c @@ -0,0 +1,42 @@ +#include +#include +#include + +extern int toupper(int c); +extern void (*_putchar)(int c); + +static char display_buf[11]; + +void putchar_to_display(); + +void init_display_putchar() { + memset(display_buf, '\0', 11); + _putchar = putchar_to_display; +} + +void putchar_to_display(int c) { + if (c == '\n') { + display_buf[4] = 1; + return; + } + + if (display_buf[4]) { + memset(display_buf, '\0', 11); + } else { + display_buf[0] = display_buf[1]; + display_buf[1] = display_buf[2]; + display_buf[2] = display_buf[3]; + display_buf[3] = display_buf[5]; + display_buf[5] = display_buf[6]; + display_buf[6] = display_buf[7]; + display_buf[7] = display_buf[8]; + display_buf[8] = display_buf[9]; + } + + display_buf[9] = toupper(c); + + clear_display_all(); + + display_chars(LCD_SEG_L1_3_0, display_buf, SEG_ON); + display_chars(LCD_SEG_L2_5_0, display_buf+4, SEG_ON); +} diff --git a/chronos/drivers/include/display_putchar.h b/chronos/drivers/include/display_putchar.h new file mode 100644 index 0000000000..6adbb9c9c0 --- /dev/null +++ b/chronos/drivers/include/display_putchar.h @@ -0,0 +1,6 @@ +#ifndef __DISPLAY_PUTCHAR_H +#define __DISPLAY_PUTCHAR_H + +void init_display_putchar(); + +#endif /* __DISPLAY_PUTCHAR_H */ diff --git a/chronos/putchar.c b/chronos/putchar.c new file mode 100644 index 0000000000..436d350f51 --- /dev/null +++ b/chronos/putchar.c @@ -0,0 +1,11 @@ +static void _dummy(int c) { +} + +void (*_putchar)(int c) = _dummy; + +int putchar(int c) +{ + _putchar(c); + return c; +} + diff --git a/msb-430-common/putchar.c b/msb-430-common/putchar.c new file mode 100644 index 0000000000..4193c0db42 --- /dev/null +++ b/msb-430-common/putchar.c @@ -0,0 +1,7 @@ +#include + +void (_putchar(int)) = uart1_putchar; + +void putchar(int c) { + _putchar(c); +} From 7d1da05452bcb50ccf438ba7534e83585c1b351e Mon Sep 17 00:00:00 2001 From: Kaspar Schleiser Date: Tue, 14 Dec 2010 16:41:06 +0100 Subject: [PATCH 05/11] file obsoleted --- chronos/debug_uart.c | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 chronos/debug_uart.c diff --git a/chronos/debug_uart.c b/chronos/debug_uart.c deleted file mode 100644 index d80c9c6e83..0000000000 --- a/chronos/debug_uart.c +++ /dev/null @@ -1,21 +0,0 @@ -#include -#include "board.h" - -#define UART1_TX TXBUF1 -#define UART1_WAIT_TXDONE() while( (UTCTL1 & TXEPT) == 0 ) { _NOP(); } - - -int putchar(int c) -{ -// UART1_TX = c; -// UART1_WAIT_TXDONE(); -// -// if (c == 10) { -// UART1_TX = 13; -// UART1_WAIT_TXDONE(); -// } - - return c; -} - - From fd8224303767ef225dbbc0eddf41754a66da0775 Mon Sep 17 00:00:00 2001 From: Oliver Hahm Date: Tue, 14 Dec 2010 16:44:32 +0100 Subject: [PATCH 06/11] * moved flashrom from msp430-common to msb430x16x --- msb-430-common/Jamfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/msb-430-common/Jamfile b/msb-430-common/Jamfile index 17bf86c9bb..147e49ea23 100644 --- a/msb-430-common/Jamfile +++ b/msb-430-common/Jamfile @@ -28,7 +28,7 @@ SubDir TOP board msb-430-common ; Module board : board_init.c debug_uart.c ; -Module board_config : board_config.c ; +Module board_config : board_config.c : flashrom ; UseModule board ; SubInclude TOP cpu $(CPU) ; From 27afca63aacd80388643364dbfb1b5070b1c0e5e Mon Sep 17 00:00:00 2001 From: Oliver Hahm Date: Fri, 17 Dec 2010 13:38:03 +0100 Subject: [PATCH 07/11] [board/chronos] * introduced battery driver --- chronos/drivers/Jamfile | 1 + chronos/drivers/battery.c | 13 +++++++++++++ chronos/drivers/include/battery.h | 6 ++++++ 3 files changed, 20 insertions(+) create mode 100644 chronos/drivers/battery.c create mode 100644 chronos/drivers/include/battery.h diff --git a/chronos/drivers/Jamfile b/chronos/drivers/Jamfile index 54d2fb4e7b..286616c5d9 100644 --- a/chronos/drivers/Jamfile +++ b/chronos/drivers/Jamfile @@ -5,5 +5,6 @@ HDRS += $(TOP)/board/$(CPU)/drivers/include ; Module board_display : display.c display1.c ; Module board_cc110x : cc430-cc110x.c : cc110x_cc430 ; Module board_buzzer : buzzer.c : hwtimer ; +Module battery : battery.c : adc hwtimer ; Module display_putchar : display_putchar.c : board_display ; diff --git a/chronos/drivers/battery.c b/chronos/drivers/battery.c new file mode 100644 index 0000000000..69553fc451 --- /dev/null +++ b/chronos/drivers/battery.c @@ -0,0 +1,13 @@ +#include +#include +#include + +uint16_t battery_get_voltate(void) { + uint16_t voltage; + voltage = adc12_single_conversion(REFVSEL_1, ADC12SHT0_10, ADC12INCH_11); + + /* Ideally we have A11=0->AVCC=0V ... A11=4095(2^12-1)->AVCC=4V + * --> (A11/4095)*4V=AVCC --> AVCC=(A11*4)/4095 */ + voltage = (voltage * 2 * 2 * 1000) / 4095; + return voltage; +} diff --git a/chronos/drivers/include/battery.h b/chronos/drivers/include/battery.h new file mode 100644 index 0000000000..6b206c6eca --- /dev/null +++ b/chronos/drivers/include/battery.h @@ -0,0 +1,6 @@ +#ifndef BATTERY_H +#define BATTERY_H + +uint16_t battery_get_voltate(void); + +#endif /* BATTERY_H */ From 1933006138e282f932afd9a91fec8b727284a06b Mon Sep 17 00:00:00 2001 From: Oliver Hahm Date: Mon, 31 Jan 2011 18:25:20 +0100 Subject: [PATCH 08/11] * introduced energy profiling (yet in a very early state) --- msba2-common/drivers/msba2-ltc4150.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/msba2-common/drivers/msba2-ltc4150.c b/msba2-common/drivers/msba2-ltc4150.c index c590dee8db..4e6534c022 100644 --- a/msba2-common/drivers/msba2-ltc4150.c +++ b/msba2-common/drivers/msba2-ltc4150.c @@ -45,19 +45,19 @@ and the mailinglist (subscription via web site) #include "ltc4150_arch.h" #include "gpioint.h" -void ltc4150_disable_int(void) { +void __attribute__((__no_instrument_function__)) ltc4150_disable_int(void) { gpioint_set(0, BIT4, GPIOINT_DISABLE, NULL); } -void ltc4150_enable_int(void) { +void __attribute__((__no_instrument_function__)) ltc4150_enable_int(void) { gpioint_set(0, BIT4, GPIOINT_FALLING_EDGE, <c4150_interrupt); } -void ltc4150_sync_blocking(void) { +void __attribute__((__no_instrument_function__)) ltc4150_sync_blocking(void) { while(!(FIO0PIN & BIT4)) {}; } -void ltc4150_arch_init() { +void __attribute__((__no_instrument_function__)) ltc4150_arch_init() { FIO0DIR |= BIT5; FIO0SET = BIT5; } From 0a05f0901e2d815bf2cda77d017cc327dbcfb18c Mon Sep 17 00:00:00 2001 From: Oliver Hahm Date: Fri, 4 Mar 2011 16:46:20 +0100 Subject: [PATCH 09/11] [board msba2] * fixed header guards [drivers ltc4150] * added joule conversion --- msba2-common/include/msba2_common.h | 6 +++--- msba2/include/board.h | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/msba2-common/include/msba2_common.h b/msba2-common/include/msba2_common.h index a9d9d3e72c..fff12f965d 100644 --- a/msba2-common/include/msba2_common.h +++ b/msba2-common/include/msba2_common.h @@ -24,8 +24,8 @@ and the mailinglist (subscription via web site) scatterweb@lists.spline.inf.fu-berlin.de *******************************************************************************/ -#ifndef __BOARD_H -#define __BOARD_H +#ifndef __MSBA2_COMMON_H +#define __MSBA2_COMMON_H /** * @ingroup msb_a2 @@ -48,4 +48,4 @@ and the mailinglist (subscription via web site) #define VICIntEnClear VICIntEnClr /** @} */ -#endif // __BOARD_H +#endif // __MSBA2_COMMON_H diff --git a/msba2/include/board.h b/msba2/include/board.h index bf596f0ee1..2b1f28fd2a 100644 --- a/msba2/include/board.h +++ b/msba2/include/board.h @@ -2,6 +2,7 @@ #define __BOARD_H #include +#include #define LED_RED_PIN (BIT25) #define LED_GREEN_PIN (BIT26) From cdab9a9a885a4d630610c3dbf2e22c510dc3eabe Mon Sep 17 00:00:00 2001 From: Stephan Zeisberg Date: Tue, 8 Mar 2011 11:43:21 +0100 Subject: [PATCH 10/11] changed types irq_callback, hashtable, posix_io, s_display_flags, seq_buffer_entry, tcb, toprint to type_t" --- chronos/drivers/display.c | 2 +- chronos/drivers/include/display.h | 4 ++-- msba2-common/drivers/msba2-uart0.c | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/chronos/drivers/display.c b/chronos/drivers/display.c index 39774279b3..063ade5855 100644 --- a/chronos/drivers/display.c +++ b/chronos/drivers/display.c @@ -57,7 +57,7 @@ void display_symbol(uint8_t symbol, uint8_t mode); * Global Variable section */ /* Display flags */ -volatile s_display_flags display; +volatile s_display_flags_t display; /* Global return string for itoa function */ char itoa_str[8]; diff --git a/chronos/drivers/include/display.h b/chronos/drivers/include/display.h index 805d801d2e..3b7c2e131f 100644 --- a/chronos/drivers/include/display.h +++ b/chronos/drivers/include/display.h @@ -67,9 +67,9 @@ typedef union { uint16_t update_acceleration : 1; // 1 = Acceleration data was updated } flag; uint16_t all_flags; // Shortcut to all display flags (for reset) -} s_display_flags; +} s_display_flags_t; -extern volatile s_display_flags display; +extern volatile s_display_flags_t display; // Constants defined in library extern const uint8_t lcd_font[]; diff --git a/msba2-common/drivers/msba2-uart0.c b/msba2-common/drivers/msba2-uart0.c index 3107e8d40c..31a9870aaf 100644 --- a/msba2-common/drivers/msba2-uart0.c +++ b/msba2-common/drivers/msba2-uart0.c @@ -49,13 +49,13 @@ and the mailinglist (subscription via web site) * @note $Id$ */ -typedef struct toprint { +typedef struct toprint_t { unsigned int len; char content[]; -}toprint; +}toprint_t; #define QUEUESIZE 255 -static volatile toprint* queue[QUEUESIZE]; +static volatile toprint_t* queue[QUEUESIZE]; static volatile unsigned char queue_head = 0; static volatile unsigned char queue_tail = 0; static volatile unsigned char queue_items = 0; @@ -64,7 +64,7 @@ static volatile unsigned int actual_pos = 0; static volatile unsigned int running = 0; static volatile unsigned int fifo = 0; -static volatile toprint* actual = NULL; +static volatile toprint_t* actual = NULL; static inline void enqueue(void) { queue_items++; From 34ad51eca5f25e2f7b3797140e422286ff400246 Mon Sep 17 00:00:00 2001 From: Oliver Hahm Date: Fri, 18 Mar 2011 15:59:50 +0100 Subject: [PATCH 11/11] * some changes to chronos (not yet finished) --- chronos/drivers/Jamfile | 1 + chronos/drivers/battery.c | 4 ++-- chronos/drivers/include/battery.h | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/chronos/drivers/Jamfile b/chronos/drivers/Jamfile index 286616c5d9..71ee1c982c 100644 --- a/chronos/drivers/Jamfile +++ b/chronos/drivers/Jamfile @@ -6,5 +6,6 @@ Module board_display : display.c display1.c ; Module board_cc110x : cc430-cc110x.c : cc110x_cc430 ; Module board_buzzer : buzzer.c : hwtimer ; Module battery : battery.c : adc hwtimer ; +Module vti_ps_twi : vti_ps_twi.c : hwtimer ; Module display_putchar : display_putchar.c : board_display ; diff --git a/chronos/drivers/battery.c b/chronos/drivers/battery.c index 69553fc451..bae37d3295 100644 --- a/chronos/drivers/battery.c +++ b/chronos/drivers/battery.c @@ -2,8 +2,8 @@ #include #include -uint16_t battery_get_voltate(void) { - uint16_t voltage; +uint32_t battery_get_voltage(void) { + uint32_t voltage; voltage = adc12_single_conversion(REFVSEL_1, ADC12SHT0_10, ADC12INCH_11); /* Ideally we have A11=0->AVCC=0V ... A11=4095(2^12-1)->AVCC=4V diff --git a/chronos/drivers/include/battery.h b/chronos/drivers/include/battery.h index 6b206c6eca..c6381b721b 100644 --- a/chronos/drivers/include/battery.h +++ b/chronos/drivers/include/battery.h @@ -1,6 +1,6 @@ #ifndef BATTERY_H #define BATTERY_H -uint16_t battery_get_voltate(void); +uint32_t battery_get_voltage(void); #endif /* BATTERY_H */