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/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/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; -} - - diff --git a/chronos/drivers/Jamfile b/chronos/drivers/Jamfile index 4b2a0d0a85..71ee1c982c 100644 --- a/chronos/drivers/Jamfile +++ b/chronos/drivers/Jamfile @@ -1,4 +1,11 @@ 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 ; +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 new file mode 100644 index 0000000000..bae37d3295 --- /dev/null +++ b/chronos/drivers/battery.c @@ -0,0 +1,13 @@ +#include +#include +#include + +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 + * --> (A11/4095)*4V=AVCC --> AVCC=(A11*4)/4095 */ + voltage = (voltage * 2 * 2 * 1000) / 4095; + return voltage; +} diff --git a/chronos/drivers/buzzer.c b/chronos/drivers/buzzer.c new file mode 100644 index 0000000000..5e0bc2ca34 --- /dev/null +++ b/chronos/drivers/buzzer.c @@ -0,0 +1,28 @@ +#include +#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/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/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/battery.h b/chronos/drivers/include/battery.h new file mode 100644 index 0000000000..c6381b721b --- /dev/null +++ b/chronos/drivers/include/battery.h @@ -0,0 +1,6 @@ +#ifndef BATTERY_H +#define BATTERY_H + +uint32_t battery_get_voltage(void); + +#endif /* BATTERY_H */ 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 99% rename from chronos/drivers/display.h rename to chronos/drivers/include/display.h index 805d801d2e..3b7c2e131f 100644 --- a/chronos/drivers/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/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/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 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/Jamfile b/msb-430-common/Jamfile index 17bf86c9bb..78807c1441 100644 --- a/msb-430-common/Jamfile +++ b/msb-430-common/Jamfile @@ -27,8 +27,8 @@ SubDir TOP board msb-430-common ; -Module board : board_init.c debug_uart.c ; -Module board_config : board_config.c ; +Module board : board_init.c uart1.c ; +Module board_config : board_config.c : flashrom ; UseModule board ; SubInclude TOP cpu $(CPU) ; 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); +} 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 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; } 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++; 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)