1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 12:52:44 +01:00
This commit is contained in:
mlenders 2011-07-10 22:49:41 +02:00
parent fdc7b764a3
commit 04bcd7718a
21 changed files with 157 additions and 38 deletions

View File

@ -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 ;

View File

@ -7,6 +7,8 @@ BOARD = chronos ;
CPU = cc430 ;
MCU = cc430x6137 ;
HDRS += [ FPath $(TOP) board chronos drivers include ] ;
FLASHER ?= mspdebug ;
FLASHFLAGS ?= rf2500 ;

View File

@ -1,21 +0,0 @@
#include <stdio.h>
#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;
}

View File

@ -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 ;

13
chronos/drivers/battery.c Normal file
View File

@ -0,0 +1,13 @@
#include <stdint.h>
#include <cc430x613x.h>
#include <cc430-adc.h>
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;
}

28
chronos/drivers/buzzer.c Normal file
View File

@ -0,0 +1,28 @@
#include <stdint.h>
#include <buzzer.h>
#include <hwtimer.h>
#include <cc430x613x.h>
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;
}

View File

@ -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];

View File

@ -0,0 +1,42 @@
#include <stdio.h>
#include <display.h>
#include <string.h>
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);
}

View File

@ -0,0 +1,6 @@
#ifndef BATTERY_H
#define BATTERY_H
uint32_t battery_get_voltage(void);
#endif /* BATTERY_H */

View File

@ -0,0 +1,6 @@
#ifndef BUZZER_H
#define BUZZER_H
void buzzer_beep(uint8_t pitch, uint16_t duration);
#endif /* BUZZER_H */

View File

@ -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[];

View File

@ -0,0 +1,6 @@
#ifndef __DISPLAY_PUTCHAR_H
#define __DISPLAY_PUTCHAR_H
void init_display_putchar();
#endif /* __DISPLAY_PUTCHAR_H */

11
chronos/include/buttons.h Normal file
View File

@ -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

11
chronos/putchar.c Normal file
View File

@ -0,0 +1,11 @@
static void _dummy(int c) {
}
void (*_putchar)(int c) = _dummy;
int putchar(int c)
{
_putchar(c);
return c;
}

View File

@ -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) ;

7
msb-430-common/putchar.c Normal file
View File

@ -0,0 +1,7 @@
#include <stdio.h>
void (_putchar(int)) = uart1_putchar;
void putchar(int c) {
_putchar(c);
}

View File

@ -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, &ltc4150_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;
}

View File

@ -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++;

View File

@ -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

View File

@ -2,6 +2,7 @@
#define __BOARD_H
#include <msba2_common.h>
#include <bitarithm.h>
#define LED_RED_PIN (BIT25)
#define LED_GREEN_PIN (BIT26)