24 #define ACDC_START_FRAME 0xFE
26 #define ACDC_TIMEOUT_MS 2000
30 static uint8_t retval = 0;
44 bool _acdcIn(
char *c )
47 if(
bfEmpty(ACDC_UART->rxfifo))
return false;
50 bfRead(ACDC_UART->rxfifo,(uint8_t*) c);
53 printf(
"rx -> 0x%x\n",*c);
77 if (c == ACDC_START_FRAME || iloop >0 )
79 if(iloop == 1) fr->temp = (uint8_t) c;
80 else if(iloop == 2) fr->volt = (uint8_t) c;
82 fr->current = (uint8_t) c;
97 fr->current = retval++;
102 int acdcGetNFrames(
AcdcFrame* framevect ,
int nRequested)
105 while(got < nRequested){
106 if(!_acdcGetFrame(framevect))
break;
static bool bfEmpty(ByteFifo *const bf)
Returns whether or not the byte-fifo is empty.
static void __irqEnable()
Enabled IRQ's on a global level.
static void __irqDisable()
Disables IRQ's on a global level.
void acdcEnable(bool ena)
enables the ACDC rx
void suartInit(SUART_Descriptor *desc, unsigned int baudrate)
Initializes the simple UART.
void irqMaskSet(int irq, bool set)
Set/clear the interrupt mask for the specified IRQ.
#define E_ACDC_TIMEOUT
Receive timeout.
static uint32_t timeOutInit(uint32_t msec)
Initializes a timeout with the specified no of msecs.
static bool timeOut(uint32_t to)
Checks whether or not the timeout has expired.
Manages the global system error.
void acdcInit(bool active)
Initializes the ACDC.
bool bfRead(ByteFifo *const bf, uint8_t *const b)
Reads a byte from the byte-fifo.
bool errSet(uint32_t code, const char *error, const char *name)
Sets an error.
#define ERROR(CODE,...)
Expands an error code to an error code with a description (if ERROR_W_DESCR is declared).
#define ACDC_BAUDRATE_DEFAULT
Default Baudrate.