Skip to content

Commit

Permalink
update timer lib
Browse files Browse the repository at this point in the history
  • Loading branch information
trentgill committed Jun 4, 2024
1 parent 7a2d6fb commit 941ce1b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
2 changes: 2 additions & 0 deletions lib/caw.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ void Caw_send_luachunk( char* text )

void Caw_stream_constchar( const char* stream )
{
if(stream == NULL) return;

size_t len = strlen(stream);
size_t space = USB_tx_space();
if( len < (space-2) ){ // leave space for newline
Expand Down
7 changes: 3 additions & 4 deletions ll/timers.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "timers.h"

#include <stm32f7xx.h>
#include <stdlib.h>
#include <stdio.h>

Expand Down Expand Up @@ -33,7 +32,7 @@ static void TIM12_CLK_EN(){ __HAL_RCC_TIM12_CLK_ENABLE(); }
static void TIM13_CLK_EN(){ __HAL_RCC_TIM13_CLK_ENABLE(); }
static void TIM14_CLK_EN(){ __HAL_RCC_TIM14_CLK_ENABLE(); }

const Timer_setup_t _timer[]=
static const Timer_setup_t _timer[]=
{ //{ TIM1 , TIM1_IRQn , TIM1_CLK_EN }
//, { TIM2 , TIM2_IRQn , TIM2_CLK_EN }
{ TIM3 , TIM3_IRQn , TIM3_CLK_EN }
Expand All @@ -50,8 +49,8 @@ const Timer_setup_t _timer[]=
, { TIM14 , TIM8_TRG_COM_TIM14_IRQn , TIM14_CLK_EN }
};

TIM_HandleTypeDef TimHandle[MAX_LL_TIMERS];
Timer_Callback_t callback[MAX_LL_TIMERS];
static TIM_HandleTypeDef TimHandle[MAX_LL_TIMERS];
static Timer_Callback_t callback[MAX_LL_TIMERS];

// FIXME have to manually index the following
void TIM3_IRQHandler( void ){ HAL_TIM_IRQHandler( &(TimHandle[0]) ); }
Expand Down
17 changes: 17 additions & 0 deletions ll/timers.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include <stm32f7xx.h>

// backend to the lib/metro.c functions

// TIMER
Expand Down Expand Up @@ -46,3 +48,18 @@ void Timer_Start( int ix, Timer_Callback_t cb );
void Timer_Stop( int ix );
void Timer_Set_Params( int ix, float seconds );
void Timer_Priority( int ix, int priority_level );

// public declarations of hal lib functions
void HAL_TIM_PeriodElapsedCallback( TIM_HandleTypeDef *htim );

void TIM3_IRQHandler( void );
void TIM4_IRQHandler( void );
void TIM5_IRQHandler( void );
void TIM6_DAC_IRQHandler( void );
void TIM7_IRQHandler( void );
void TIM1_BRK_TIM9_IRQHandler( void );
void TIM1_UP_TIM10_IRQHandler( void );
void TIM1_TRG_COM_TIM11_IRQHandler( void );
void TIM8_BRK_TIM12_IRQHandler( void );
void TIM8_UP_TIM13_IRQHandler( void );
void TIM8_TRG_COM_TIM14_IRQHandler( void );

0 comments on commit 941ce1b

Please sign in to comment.