|
|
|
|
@ -34,6 +34,15 @@ void init_timer_100us(){
|
|
|
|
|
TCC0.INTCTRLA |= TC_OVFINTLVL_HI_gc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void io_setup(void){
|
|
|
|
|
// LED
|
|
|
|
|
PORTD.DIRSET = 1 << 5;
|
|
|
|
|
|
|
|
|
|
// pullups for address switch
|
|
|
|
|
PORTCFG.MPCMASK = 0xFF;
|
|
|
|
|
PORTC.PIN1CTRL = PORT_OPC_PULLUP_gc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void modbusGet(void) {
|
|
|
|
|
if (modbusGetBusState() & (1<<ReceiveCompleted))
|
|
|
|
|
{
|
|
|
|
|
@ -50,17 +59,18 @@ void modbusGet(void) {
|
|
|
|
|
|
|
|
|
|
int main(void){
|
|
|
|
|
init_clk();
|
|
|
|
|
PORTD.DIRSET = 1 << 5;
|
|
|
|
|
io_setup();
|
|
|
|
|
|
|
|
|
|
// blink LED on startup
|
|
|
|
|
PORTD.OUTTGL = 1 << 5;
|
|
|
|
|
_delay_ms(500);
|
|
|
|
|
PORTD.OUTTGL = 1 << 5;
|
|
|
|
|
|
|
|
|
|
// init pt100 stuff
|
|
|
|
|
adc_init();
|
|
|
|
|
dma_init();
|
|
|
|
|
|
|
|
|
|
PORTCFG.MPCMASK = 0xFF;
|
|
|
|
|
PORTC.PIN1CTRL = PORT_OPC_PULLUP_gc;
|
|
|
|
|
|
|
|
|
|
// setup modbus tick timer
|
|
|
|
|
init_timer_100us();
|
|
|
|
|
|
|
|
|
|
PMIC.CTRL |= PMIC_LOLVLEN_bm | PMIC_MEDLVLEN_bm | PMIC_HILVLEN_bm;
|
|
|
|
|
|