mirror of
https://github.com/travisgoodspeed/goodwatch
synced 2024-11-22 16:59:57 +00:00
Merge branch 'master' of git@github.com:travisgoodspeed/goodwatch.git into alarm
# Conflicts: # firmware/Makefile # firmware/apps/alarm.c # firmware/apps/alarm.h # firmware/rtc.c
This commit is contained in:
commit
9daf841882
@ -7,12 +7,12 @@ CC = msp430-gcc -mmcu=cc430f6137 -Wall -I. -Os
|
||||
|
||||
BSL = ../bin/cc430-bsl.py -r 38400 -p $(PORT)
|
||||
|
||||
modules=rtcasm.o main.o lcd.o lcdtext.o rtc.o keypad.o apps.o applist.o buzzer.o \
|
||||
sidebutton.o power.o uart.o monitor.o ucs.o \
|
||||
modules=rtcasm.o main.o lcd.o lcdtext.o rtc.o keypad.o apps.o applist.o \
|
||||
sidebutton.o power.o uart.o monitor.o ucs.o buzz.o \
|
||||
radio.o packet.o dmesg.o codeplug.o rng.o \
|
||||
libs/assembler.o libs/morse.o
|
||||
|
||||
apps= apps/clock.o apps/alarm.o apps/rpn.o apps/hex.o apps/stopwatch.o apps/dice.o \
|
||||
apps= apps/clock.o apps/rpn.o apps/hex.o apps/stopwatch.o apps/dice.o \
|
||||
apps/rngapp.o apps/tuner.o apps/morse.o apps/beacon.o apps/iclicker.o \
|
||||
apps/submenu.o
|
||||
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "codeplug.h"
|
||||
#include "power.h"
|
||||
#include "dmesg.h"
|
||||
#include "buzz.h"
|
||||
#include "gittag.h" //Autogenerated
|
||||
|
||||
//Handy libraries. These are tested host-side.
|
||||
|
@ -15,10 +15,6 @@ const struct app apps[]={
|
||||
{.name="clock", .init=clock_init, .draw=clock_draw, .exit=clock_exit,
|
||||
.keypress=clock_keypress
|
||||
},
|
||||
//Alarm
|
||||
{.name="alarm", .init=alarm_init, .draw=alarm_draw, .exit=alarm_exit,
|
||||
.keypress=alarm_keypress
|
||||
},
|
||||
//Stopwatch
|
||||
{.name="timer", .init=stopwatch_init, .draw=stopwatch_draw, .exit=stopwatch_exit,
|
||||
.keypress=stopwatch_keypress
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
//Non-radio apps first.
|
||||
#include "apps/clock.h"
|
||||
#include "apps/alarm.h"
|
||||
#include "apps/stopwatch.h"
|
||||
#include "apps/rpn.h"
|
||||
#include "apps/hex.h"
|
||||
|
60
firmware/buzz.c
Normal file
60
firmware/buzz.c
Normal file
@ -0,0 +1,60 @@
|
||||
/*! \file buzz.c
|
||||
\brief Handy buzzer functions.
|
||||
|
||||
These are currently untested, as the buzzer causes the GoodWatch20
|
||||
to glitch out. We hope to have proper buzzer support in the
|
||||
GoodWatch21.
|
||||
*/
|
||||
|
||||
#include<msp430.h>
|
||||
|
||||
#include<stdio.h>
|
||||
|
||||
//! Make a quick buzz.
|
||||
void buzz(unsigned int count){
|
||||
//Start the timer.
|
||||
if(count){
|
||||
//Output select mode for P2.7.
|
||||
P2DIR|=0x80;
|
||||
P2SEL|=0x80;
|
||||
|
||||
//P2.7 might need high drive strength for the piezo.
|
||||
//P2DS|=0x80;
|
||||
|
||||
|
||||
TA1CCR0 = count;
|
||||
TA1CTL |= MC__UP;
|
||||
}else{
|
||||
//Stop the timer when it's not in use.
|
||||
TA1CTL = TACLR | TASSEL__SMCLK | MC__STOP;
|
||||
|
||||
//Input mode for the pin, so we don't accidentally leak power.
|
||||
P2DIR&=~0x80;
|
||||
P2SEL&=~0x80;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//! Initializes the buzzer port.
|
||||
void buzz_init(){
|
||||
TA1CTL=0;
|
||||
|
||||
//Unlock port mapping.
|
||||
PMAPKEYID=0x2d52;
|
||||
if(PMAPCTL&1)
|
||||
printf("Ugh, port mapping is locked.\n");
|
||||
|
||||
//Route timera1 to the pin. This might conflict with rng.c.
|
||||
P2MAP7=PM_TA1CCR0A;;
|
||||
|
||||
//Lock port mapping.
|
||||
PMAPKEYID=0x96a5;
|
||||
|
||||
|
||||
TA1CTL = TACLR | TASSEL__SMCLK | MC__STOP;
|
||||
TA1CCTL0 = OUTMOD_4;
|
||||
TA1CCTL0 &= ~CCIE;
|
||||
|
||||
P2SEL|=0x80;
|
||||
}
|
||||
|
10
firmware/buzz.h
Normal file
10
firmware/buzz.h
Normal file
@ -0,0 +1,10 @@
|
||||
/*! \file buzz.h
|
||||
\brief Handy buzzer functions.
|
||||
*/
|
||||
|
||||
//! Initializes the buzzer port.
|
||||
void buzz_init();
|
||||
|
||||
//! Make a quick buzz.
|
||||
void buzz(int);
|
||||
|
@ -20,16 +20,19 @@ void key_init(){
|
||||
/* Columns 2.2, 2.1, 2.0, and 1.7 are set to output mode pulled
|
||||
high, so that any low row indicates a button press. */
|
||||
|
||||
P2SEL=0x00; //All of port 2 are IO.
|
||||
P2DIR=BIT2|BIT1|BIT0; //Rows are input, columns are output.
|
||||
P2SEL&=~0x7F; //All of port 2 except the buzzer are IO.
|
||||
P2DIR=BIT2|BIT1|BIT0; //These columns are output.
|
||||
P2REN|=0xFF; //All resistor.
|
||||
P2OUT=BIT2|BIT1|BIT0; //Pull all of them down.
|
||||
|
||||
P1SEL&=~0x80; //P1.7 is IO.
|
||||
P1DIR|=0x80; //P1.7 is output.
|
||||
P1DIR|=0x80; //P1.7 is output.
|
||||
P1REN|=0x80;
|
||||
P1OUT|=0x80; //Output high.
|
||||
|
||||
|
||||
P2DIR|=BIT7; // Buzzer is on P2.7.
|
||||
|
||||
//Trigger interrupts for keypresses so we needn't scan.
|
||||
P2IE|=BIT2|BIT1|BIT0;
|
||||
}
|
||||
@ -44,8 +47,8 @@ int key_row(){
|
||||
int row;
|
||||
P1DIR|=0x80; //P1.7 out.
|
||||
P1OUT|=0x80; //P1.7 high.
|
||||
P2DIR= 0x07; //P2.0, 2.1, 2.2 out.
|
||||
P2OUT= 0x07; //P2.0, 2.1, 2.2 high.
|
||||
P2DIR|=0x07; //P2.0, 2.1, 2.2 out.
|
||||
P2OUT|=0x07; //P2.0, 2.1, 2.2 high.
|
||||
|
||||
//We'll return this result, but after cleaning up.
|
||||
row=(P2IN>>3)&0x0F;
|
||||
@ -60,8 +63,11 @@ int key_col(){
|
||||
int col;
|
||||
P1DIR&=~0x80; //Input
|
||||
P1OUT&=~0x80; //Low
|
||||
P2DIR= 0xF8; //P2.1.3, 2.4, 2.5, 2.6 out
|
||||
P2OUT= 0xF8; //P2.1.3, 2.4, 2.5, 2.6 high
|
||||
|
||||
P2DIR&=~0x07; //P2.3, 2.4, 2.5, 2.6 out
|
||||
P2DIR|= 0x78;
|
||||
P2OUT&=~0x07; //P2.3, 2.4, 2.5, 2.6 high
|
||||
P2OUT|= 0x78;
|
||||
|
||||
//We'll return this result, but after cleaning up.
|
||||
col=((P2IN&0x7)<<1) | ((P2IN&0x80)>>7);
|
||||
|
@ -72,7 +72,7 @@ const int letterfont[]={
|
||||
E|G|C|D|B, //D
|
||||
A|F|E|G|D, //E
|
||||
A|G|F|E, //F
|
||||
A|F|E|C|D, //G
|
||||
A|F|G|E|C|D, //G
|
||||
F|G|E|C, //h
|
||||
F|E, //I, distinguished from a 1 by being on the left side.
|
||||
E|B|C|D, //J
|
||||
|
@ -89,6 +89,15 @@ int main(void) {
|
||||
lcd_string("OSC INIT");
|
||||
ucs_init();
|
||||
|
||||
/* TODO Enable this once we have hardware with a working buzzer.
|
||||
|
||||
lcd_zero();
|
||||
printf("buzz ");
|
||||
lcd_string("BUZZINIT");
|
||||
buzz_init();
|
||||
buzz(1024);
|
||||
*/
|
||||
|
||||
lcd_zero();
|
||||
lcd_string("UARTINIT");
|
||||
uart_init();
|
||||
|
@ -164,7 +164,6 @@ void __attribute__ ((interrupt(RTC_VECTOR))) RTC_ISR (void){
|
||||
//! Sound the alarm
|
||||
alarm_trigger();
|
||||
}
|
||||
|
||||
break;
|
||||
case 8: break; // RT0PSIFG
|
||||
case 10: break; // RT1PSIFG
|
||||
|
Loading…
Reference in New Issue
Block a user