From a7ae6d419751632abd442325147368fcf4c1875d Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Wed, 15 Apr 2020 16:12:58 +0200 Subject: [PATCH] Serial experiements --- halconf.h | 2 +- main.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- mcuconf.h | 2 +- sa_core.c | 2 +- 4 files changed, 70 insertions(+), 4 deletions(-) diff --git a/halconf.h b/halconf.h index 1450b9f..af6c283 100644 --- a/halconf.h +++ b/halconf.h @@ -132,7 +132,7 @@ * @brief Enables the SERIAL subsystem. */ #if !defined(HAL_USE_SERIAL) || defined(__DOXYGEN__) -#define HAL_USE_SERIAL FALSE +#define HAL_USE_SERIAL TRUE #endif /** diff --git a/main.c b/main.c index bba6558..84a5b5f 100644 --- a/main.c +++ b/main.c @@ -16,9 +16,14 @@ * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ +//#define HAL_USE_SERIAL 1 +//#define STM32_SERIAL_USE_USART1 1 #include "ch.h" #include "hal.h" + +//#include "hal_serial.h" + #include "usbcfg.h" #ifdef __VNA__ #include "si5351.h" @@ -2591,6 +2596,39 @@ static DACConfig dac1cfg1 = { }; #endif +#if 0 +/* + * UART driver configuration structure. + */ +static UARTConfig uart_cfg_1 = { + NULL, //txend1, + NULL, //txend2, + NULL, //rxend, + NULL, //rxchar, + NULL, //rxerr, + 800000, + 0, + 0, //USART_CR2_LINEN, + 0 +}; +#endif + +#if 1 +static const SerialConfig default_config = +{ + 9600, + 0, + USART_CR2_STOP2_BITS, + 0 +}; +#endif + +myWrite(char *buf) +{ + int len = strlen(buf); + while(len-- > 0) + sdPut(&SD1,*buf++); +} // Main thread stack size defined in makefile USE_PROCESS_STACKSIZE = 0x200 // Profile stack usage (enable threads command by def ENABLE_THREADS_COMMAND) show: @@ -2625,7 +2663,35 @@ int main(void) usbStart(serusbcfg.usbp, &usbcfg); usbConnectBus(serusbcfg.usbp); -/* +#if 0 + /* + * UART initialize + */ + uartStart(&UARTD1, &uart_cfg_1); + + uartStartSend(&UARTD1, 1, "H"); + uartStartReceive(&UARTD1, 1, buf); +#endif + +#if 1 + palSetPadMode(GPIOA, 9, PAL_MODE_ALTERNATE(1)); // USART1 TX. + palSetPadMode(GPIOA,10, PAL_MODE_ALTERNATE(1)); // USART1 RX. + + uint8_t buf[10]; + sdStart(&SD1,&default_config); + osalThreadSleepMilliseconds(10); + myWrite("Hallo!?"); + + osalThreadSleepMilliseconds(10); + + sdReadTimeout(&SD1,buf,10, 10); + + sdWrite(&SD1,(const uint8_t *)"Test123",7); + osalThreadSleepMilliseconds(10); + sdReadTimeout(&SD1,buf,10, 10); +#endif + + /* * SPI LCD Initialize */ ili9341_init(); diff --git a/mcuconf.h b/mcuconf.h index 6d4550a..e04096c 100644 --- a/mcuconf.h +++ b/mcuconf.h @@ -201,7 +201,7 @@ /* * UART driver system settings. */ -#define STM32_UART_USE_USART1 TRUE +#define STM32_UART_USE_USART1 FALSE #define STM32_UART_USE_USART2 FALSE #define STM32_UART_USART1_IRQ_PRIORITY 3 #define STM32_UART_USART2_IRQ_PRIORITY 3 diff --git a/sa_core.c b/sa_core.c index ebf9998..3175531 100644 --- a/sa_core.c +++ b/sa_core.c @@ -888,7 +888,7 @@ float perform(bool break_on_operation, int i, int32_t f, int tracking) return(0); float signal_path_loss; if (setting_mode == M_LOW) - signal_path_loss = -9.5; // Loss in dB + signal_path_loss = -9.5; // Loss in dB, -9.5 for v0.1, -12.5 for v0.2 else signal_path_loss = 7; // Loss in dB (+ is gain) float subRSSI = SI4432_RSSI(lf, MODE_SELECT(setting_mode))+settingLevelOffset()+ setting_attenuate - signal_path_loss;