}
void switchDCDC(uint8_t group, uint8_t val) {
- // de/activate the dcdc themself
+ // de/activate the dcdc itself
if (val == 0) {
shift_register &= ~((uint32_t)1 << (4 + group * 8)); // DCDC off
if (group == 0) {
*/
void getdata(uint8_t buf) {
- // handle the incoming comand and call the correct function
- if (rxcnt != 0 || (buf == 'A' || buf == 'W' || buf == 'R')) {
+ // handle the incoming command and call the correct function
+ if (rxcnt != 0 || (buf == 'A' || buf = 'S' || buf == 'W' || buf == 'R')) {
rxbuf[rxcnt++] = buf;
}
if (buf == '\n' || buf == '\r') { // End of Command
- if (rxbuf[0] == 'A') {
- // answer
+
+ if (rxbuf[0] == 'A' && rxcnt == 11) {
+ // get answer from another MC and transmit it to the next
memcpy((uint8_t *)txbuf, (uint8_t *)rxbuf, 10);
txbuf[11] = 0;
send_answer_buf(txbuf);
- } else if (rxbuf[0] == 'S') { // Scann of chain, returns number of boards
+
+ } else if (rxbuf[0] == 'S') {
+ // Scan of chain, returns number of boards
txbuf[0] = 'S';
uint8_t length = rxcnt - 2; // Length of Counter
// read current counter value
txbuf[length + 2] = 0;
send_answer_buf(txbuf);
rxcnt = 0;
- } else if (rxcnt == 11 && is_my_address(10)) { // message is for this uC
+ } else if (rxcnt == 11 && is_my_address(10)) {
+ // message is for this uC
// } else if (is_my_address(10)) { //answer 0x00d1 works with this line
+
if (rxbuf[0] == 'W') {
// write
switch (hex_to_int(rxbuf[5])) {
}
ISR(USART1_RX_vect) {
- // interupt for incoming comand
+ // interupt for incoming command
uint8_t buf = UDR1;
if (isMaster == 0) {
getdata(buf);
}
__attribute__((naked)) void main(void) {
+ // initialize the board
CLKPR = (1 << CLKPCE); // prescaler 2 = 8 MHz
CLKPR = (1 << CLKPS0); // prescaler 2