Skip to content
Permalink
Browse files

ext clock event rather, ms time counting functions

  • Loading branch information
tehn committed Mar 28, 2016
1 parent ebb7a9b commit c38e268c22cc4c6740b1c8acd75c8407dd77d79e
Showing with 26 additions and 3 deletions.
  1. +1 −0 src/events.h
  2. +7 −3 src/init_trilogy.c
  3. +15 −0 src/timers.c
  4. +3 −0 src/timers.h
@@ -17,6 +17,7 @@ typedef enum {
kEventKeyTimer,
kEventSaveFlash,
kEventClockNormal,
kEventClockExt,
/// connect/disconnect FTDI-based devices
kEventFtdiConnect,
kEventFtdiDisconnect,
@@ -114,9 +114,13 @@ static void irq_port1_line1(void) {
// clock in
if(gpio_get_pin_interrupt_flag(B08)) {
// CLOCK BOUNCY WITHOUT THESE PRINTS
print_dbg("\rclk: ");
print_dbg_ulong(gpio_get_pin_value(B08));
(*clock_pulse)(gpio_get_pin_value(B08));
// print_dbg("\rclk: ");
// print_dbg_ulong(gpio_get_pin_value(B08));
// (*clock_pulse)(gpio_get_pin_value(B08));
static event_t e;
e.type = kEventClockExt;
e.data = gpio_get_pin_value(B08);
event_post(&e);
gpio_clear_pin_interrupt_flag(B08);
}
}
@@ -12,6 +12,8 @@ static volatile softTimer_t* head = NULL;
static volatile softTimer_t* tail = NULL;
static volatile u32 num = 0;

static volatile u32 now = 0;

//------------------------------
//--- extern functions

@@ -145,6 +147,8 @@ void process_timers( void ) {
u32 i;
volatile softTimer_t* t = head;

now++;

// print_dbg("\r\n processing timers. head: 0x");
// print_dbg_hex((u32)head);

@@ -188,3 +192,14 @@ void timer_manual(softTimer_t* timer) {
timer->ticksRemain = 1;
}



u32 time_now() {
return now;
}

void time_clear() {
now = 0;
}


@@ -43,6 +43,9 @@ void timer_reset(softTimer_t* timer);
void timer_reset_set(softTimer_t* timer, u32 ticks);
void timer_manual(softTimer_t* timer);

u32 time_now(void);
void time_clear(void);

// clear the list
extern void timers_clear(void) ;

0 comments on commit c38e268

Please sign in to comment.