1,11 → 1,9 |
#include <xc.h> |
#include <plib.h> |
#include "defines.h" |
#include "TIMER4.h" |
|
static TIMER4_DATA *timer_data_ptr; |
|
void TIMER4_Init(TIMER4_DATA *data, void (*callback)(void), unsigned int time_us) { |
void TIMER4_Init(TIMER4_DATA *data, void (*callback)(void), uint32_t time_us) { |
if (data != NULL) // if ptr is null, use existing data |
timer_data_ptr = data; |
|
15,8 → 13,8 |
|
T4CON = 0x0; |
|
// PR5 is 16 bits wide, so we need to determine what pre-scaler to use |
int time; |
// PR4 is 16 bits wide, so we need to determine what pre-scaler to use |
uint16_t time; |
if (time_us < 13107) { |
time = 5 * time_us; |
T4CONSET = 0x0040; // Prescaler at 1:16 |