Skip to content

Commit

Permalink
clockblock is now a nativ avr application
Browse files Browse the repository at this point in the history
  • Loading branch information
mcous committed Oct 10, 2013
1 parent 31c8375 commit b9acb78
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 8 deletions.
34 changes: 29 additions & 5 deletions firmware/src/clockblock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// ************************************
// AVR includes necessary for this file
// ************************************

#include <util/delay.h>

// ********************
// application includes
Expand All @@ -19,10 +19,11 @@
// **************************
// INTERRUPT SERVICE ROUTINES
// **************************
ISR(RTC_INT_vect) {
ISR(INT0_vect) {
tick = true;
}


#ifdef BREADBOARD
// ISR for serial data input into TLC5940
ISR(TIMER0_COMPA_vect) {
Expand All @@ -40,7 +41,7 @@ int main() {
tick = false;

// application variables
uint8_t tm[3] = {0, 0, 0};
uint8_t tm[3] = {0, 0, 12};

// initialize the RTC
rtc.init();
Expand All @@ -64,9 +65,32 @@ int main() {
EIMSK = (1 << RTC_INT);
sei();

//uint16_t count = 0;
//int8_t dir = 1;
// get lost
for (;;) {

/*
// give it some new data
for (uint8_t i=0; i<TLC5940_LED_N; i++) {
tlc.setGS(i, count);
}
// tell the driver to update
tlc.update();
// set loop direction
if (dir==1 && count>=4000) {
dir = -1;
}
else if (dir==-1 && count<=300) {
dir = 1;
}
// increment counter
count += dir*100;
// delay
_delay_ms(50);
*/

// check the set time flag
if (timeSet) {

Expand All @@ -90,7 +114,7 @@ int main() {
// update the clock arms
// dots array structure: { hr0, mn0, sc0, hr1, mn1, sc1, ... , hr11, mn11, sc11 }
void updateArms(uint8_t hour, uint8_t min, uint8_t sec) {
static uint16_t dots[NUM_DOTS];
uint16_t dots[NUM_DOTS];

// hands
uint8_t minHand = min/5;
Expand Down
13 changes: 10 additions & 3 deletions firmware/src/rtcTest/rtcTest.ino
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@ void setup() {

// setup interrupt
pinMode(RTC_INT_PIN, INPUT);
attachInterrupt(0, intFlag, FALLING);
//attachInterrupt(0, intFlag, FALLING);
cli();
EICRA = (1 << 1);
EIMSK = (1 << 0);
sei();
}

void loop() {
Expand Down Expand Up @@ -174,7 +178,6 @@ void updateArms() {
// intialize timers for TLC5940 control
void initTLCTimers() {
cli();

// user timer 1 to toggle the gs clock pin
TCCR1A = 0;
TCCR1B = 0;
Expand Down Expand Up @@ -203,15 +206,19 @@ void initTLCTimers() {
TCCR0B |= ( (1 << CS02) | (1 << CS00) );
// enable the interrupt of output compare A match
TIMSK0 |= (1 << OCIE0A);

sei();
}


// ISRs
/*
void intFlag() {
secFlag = true;
}
*/
ISR(INT0_vect) {
secFlag = true;
}

// ISR for serial data input into TLC5940
ISR(TIMER0_COMPA_vect) {
Expand Down

0 comments on commit b9acb78

Please sign in to comment.