- fixed baudrate calculation

[Bootloader]
- set baudrate top 115200

[HendiCtrl]
- set baudrate top 115200
- revised and fixed command interpreter
- added new commands: SW_VERSION, SW_IDENTIFIER, DEBUG on/on, Remote enter, Remote exit
- oven is switched off on entering / exiting remote


git-svn-id: http://moon:8086/svn/projects/HendiControl@173 fda53097-d464-4ada-af97-ba876c37ca34
This commit is contained in:
2019-03-30 11:48:05 +00:00
parent e1be187d03
commit feaf3666be
8 changed files with 175 additions and 81 deletions
+1 -8
View File
@@ -9,13 +9,6 @@
#ifndef MACHINE_H_
#define MACHINE_H_
#if ARDUINO_NANO
#define F_CPU (16000000UL) // MHz
#else
#define F_CPU (18432000UL) // MHz
#endif
#define F_CPU (18432000UL) // MHz
#endif /* MACHINE_H_ */
+1 -1
View File
@@ -96,7 +96,7 @@ int main(void)
{
bootloader_enter();
led_bsel(1);
uart_init(9600);
uart_init(115200);
uart_puts("Hendi-Control Bootloader v1.2\n");
size_t image_size = 0;
uint16_t page_addr = 0xFFFF;
+9 -8
View File
@@ -12,14 +12,14 @@
void uart_init(uint32_t baudrate)
{
uint16_t prescale8 = UART_PRESCALE(baudrate, 8UL);
uint16_t prescale16 = UART_PRESCALE(baudrate, 16UL);
uint32_t prescale8 = UART_PRESCALE(baudrate, 8UL);
uint32_t prescale16 = UART_PRESCALE(baudrate, 16UL);
uint32_t baud8 = ((prescale8+1) * 8);
uint32_t baud16 = ((prescale16+1) * 16);
uint32_t fcpu8 = (prescale8 * baudrate * 8);
uint32_t fcpu16 = (prescale16 * baudrate * 16);
uint32_t err8 = abs(baudrate - baud8);
uint32_t err16 = abs(baudrate - baud16);
uint32_t err8 = abs(fcpu8 - F_CPU);
uint32_t err16 = abs(fcpu16 - F_CPU);
uint16_t prescale = prescale16;
if (err8 < err16)
@@ -31,8 +31,9 @@ void uart_init(uint32_t baudrate)
}
// Set baud rate
UBRR0L = (uint8_t)prescale;
UBRR0H = (uint8_t)(prescale >> 8);
uint16_t reg = prescale - 1;
UBRR0L = (uint8_t)reg;
UBRR0H = (uint8_t)(reg >> 8);
// Enable receiver and transmitter
UCSR0B = (1<<TXEN0)|(1<<RXEN0);
+1 -1
View File
@@ -13,7 +13,7 @@
#define XON 17 /* XON Zeichen */
#define XOFF 19 /* XOFF Zeichen */
#define UART_PRESCALE(baudrate, smpPerBit) ((5+ 10*F_CPU / (baudrate*smpPerBit) - 1)/10)
#define UART_PRESCALE(baudrate, smpPerBit) ((5 + (10*F_CPU) / (baudrate*smpPerBit))/10)
void uart_init(uint32_t baudrate);
void uart_putc(char c);