Reply to incoming 'A' with software UART registers dtn & dt0.
Test application:
./main.py
- config.h
#ifndef CONFIG_H
#define CONFIG_H
#include BOARD_H
#define UART HW_SWUARTA( txd, DIABOLO_PIN_TX, \
rxd, DIABOLO_PIN_RX, \
startirq, (DIABOLO_PIN_RX,port,pcic,irq), \
counter, counter1, \
compare, compare0, \
clkdiv, 1, \
autosync, 51, \
fastreg, (shared,gpior0) )
#endif
- main.c
#include "config.h"
void uart_putbyte ( uint8_t byte )
{
while ( !
hw(stat,UART).txc )
}
int
main ( )
{
hwa( configure, PIN_LED, mode, digital_output );
sleep, enabled,
sleep_mode, idle );
#if !defined HW_DEVICE_CLK_SRC_HZ
hwa( write, (core0, osccal), 0xFF );
#endif
hw( enable, interrupts );
for(;;) {
while ( !
hw(stat,UART).sync )
for(;;) {
while ( !
hw(stat,UART).rxc )
uint8_t
byte =
hw( read, UART );
if ( byte=='A' ) {
uint16_t dt ;
dt =
hw( read, (UART,dtn) ) ;
uart_putbyte( (dt>>0) & 0xFF );
uart_putbyte( (dt>>8) & 0xFF );
dt =
hw( read, (UART,dt0) ) ;
uart_putbyte( (dt>>0) & 0xFF );
uart_putbyte( (dt>>8) & 0xFF );
uart_putbyte( '$' );
}
else {
break ;
}
}
}
}