// Прошивка для удаленного радиомодуля #include #include #include #include "uart/uart.h" #include "uart/uart_addon.h" #include "res/strings.h" #include "onewire/onewire.h" #define UART_BAUD_RATE 19200 unsigned char getcmd(void){ unsigned int res; do{ res = uart_getc(); } while(res & UART_NO_DATA); return (unsigned char) res; } void getListDevices(void){ uint8_t i; uint8_t id[OW_ROMCODE_SIZE]; uint8_t diff, nSensors; char buffer[40]; uart_puts("\r\nScanning 1-wire bus\r\n"); ow_reset(); nSensors = 0; diff = OW_SEARCH_FIRST; while ( diff != OW_LAST_DEVICE) { diff = ow_rom_search( diff, &id[0] ); //if ( diff != OW_PRESENCE_ERR && diff != OW_DATA_ERR && diff != OW_LAST_DEVICE ) { for ( i=0; i < OW_ROMCODE_SIZE; i++ ){ sprintf(buffer,"%02X ",id[i]); uart_puts(buffer); } uart_puts("\r\n"); //} nSensors++; } sprintf(buffer,"Found %d devices",nSensors); uart_puts(buffer); } int main(void){ uart_init(UART_BAUD_SELECT(UART_BAUD_RATE,F_CPU)); #ifndef OW_ONE_BUS ow_set_bus(&PIND,&PORTD,&DDRD,PD6); #endif sei(); char cmd = '0'; while (cmd != 'q'){ uart_puts_p(MainMenuItemTitle); uart_puts_p(MainMenuItem1); uart_puts_p(MainMenuItem2); uart_puts_p(MainMenuItemQuit); uart_puts_p(MainMenuItemPrompt); cmd = getcmd(); if (cmd == '1'){ getListDevices(); } } while(1){ } }