I didn't see an update in SVN, so I didn't implement these changes myself baring your latest code. Here is how I would add periodic service...
void UARTstart(void){
//open, start bridge
//start
//UART2Enable();
U2STA &= (~0b10); //clear overrun error if exists
uartSettings.eu=1;//open uart
modeConfig.periodicService=1;//start periodic service calls
bpWline(OUMSG_UART_LIVE_DISPLAY_ON);
}
void UARTstop(void){
//close bridge
//UART2Disable();
uartSettings.eu=0;// uart
modeConfig.periodicService=0;//start periodic service calls
bpWline(OUMSG_UART_LIVE_DISPLAY_OFF);
}
Add individual functions for these to uart.c
#ifdef BP_USE_HWUART
,
{ UARTStart, // start
UARTStart, // startR
UARTstop, // stop
UARTstop, // stopR
UARTwrite, // send
UARTread, // read
nullfunc1, // clkh
nullfunc1, // clkl
nullfunc1, // dath
nullfunc1, // datl
nullfunc1, // dats
nullfunc1, // clk
nullfunc1, // bitr
UARTmacro, // macro
UARTsetup, // setup
UARTcleanup, // cleanup
"UART" // name
}
Add call those function in buspiratecore.c from the start and stop reference.
typedef struct _proto {
void (*protocol_start)(void);
void (*protocol_startR)(void);
void (*protocol_stop)(void);
void (*protocol_stopR)(void);
void (*protocol_send)(unsigned int);
void (*protocol_read)(void);
void (*protocol_clkh)(void);
void (*protocol_clkl)(void);
void (*protocol_dath)(void);
void (*protocol_datl)(void);
void (*protocol_dats)(void);
void (*protocol_clk)(void);
void (*protocol_bitr)(void);
void (*protocol_macro)(unsigned int);
void (*protocol_setup)(void);
void(*protocol_periodicservice)(void);
void (*protocol_cleanup)(void);
char protocol_name[8];
} proto;
Add a periodic service function.
//send the periodic service command to the current protocol
//allows to check UART for async RX bytes, etc, independent of user input
if(modeConfig.periodicService==1){
protos[bpConfig.busMode].protocol_periodicservice();
}
Reinstate the periodic service function in the main loop. I'm not sure of the scope there though.
// cvd: Better to use a ISR to service this?? only the
if(modeConfig.periodicService==1)
{
protos[bpConfig.busMode].protocol_periodicservice();
}
I saw that you already had this in the userservice loop, so I'm probably missing part of the picture.