1. void general_init(void) {
  2. // Check if stop bits and parity settings in the EEPROM are legal
  3. uint8_t stop_bits = eeprom_read_byte(MODBUS_EEPROM_STOPBITS);
  4. if((stop_bits != USART_SBMODE_1BIT_gc) && (stop_bits != USART_SBMODE_2BIT_gc)) {
  5. //eeprom_write_byte(MODBUS_EEPROM_STOPBITS, USART_SBMODE_1BIT_gc); // DEFAULT STOPP BITS: 1
  6. eeprom_write_byte(MODBUS_EEPROM_STOPBITS, USART_SBMODE_2BIT_gc); // DEFAULT STOPP BITS: 2
  7. }
  8. uint8_t parity = eeprom_read_byte(MODBUS_EEPROM_PARITY);
  9. if((parity != USART_PMODE_DISABLED_gc) && (parity != USART_PMODE_EVEN_gc) && (parity != USART_PMODE_ODD_gc)) {
  10. eeprom_write_byte(MODBUS_EEPROM_PARITY, USART_PMODE_DISABLED_gc); // DEFAULT PARITY: NONE
  11. //eeprom_write_byte(MODBUS_EEPROM_PARITY, USART_PMODE_EVEN_gc); // DEFAULT PARITY: EVEN
  12. //eeprom_write_byte(MODBUS_EEPROM_PARITY, USART_PMODE_ODD_gc); // DEFAULT PARITY: ODD
  13. }
  14. (...)
  15. }