123

Dependencies:   mbed

Fork of LG by igor Apu

Revision:
183:c7a9c309086c
Parent:
182:2bd8ec44998f
--- a/DeviceUserPort.c	Sun Jul 10 05:35:08 2016 +0000
+++ b/DeviceUserPort.c	Sun Jul 31 06:19:02 2016 +0000
@@ -4,11 +4,13 @@
 extern unsigned int SystemCoreClock1;
 
 void InitUserPortDefaultSettings(void) {
+  device.user.port.settings.mode = 0;     //Baud rate usage: 0 - accept baud rate change; 1 - always 921600
   device.user.port.settings.baud = 38400;
 }
 
 void InitUserPortState(void) {
-  device.user.port.state.baud = device.user.port.settings.baud;
+  device.user.port.state.mode = device.user.port.settings.mode;
+  device.user.port.state.baud = userSelectBaudRate(device.user.port.settings.baud);
 }
 
 void DeviceStartUserPort(void)
@@ -28,7 +30,15 @@
   */
 }
 
+uint32_t userSelectBaudRate(uint32_t baud) {
+  if (device.user.port.state.mode == 1)
+    return 921600;
+  else
+    return baud;
+}
+
 void userSetBaudRate(uint32_t baud) {
+  baud = userSelectBaudRate(baud);
   //Peripheral clock of UART1
   uint32_t pclkdiv = (LPC_SC->PCLKSEL0 >> 8) & 0x03;    //Bits 8,9 are for UART1
   uint32_t pclk;