|
@@ -1,6 +1,7 @@
|
|
#include "stm32l0xx_hal.h"
|
|
#include "stm32l0xx_hal.h"
|
|
#include "stm32l0xx_nucleo.h"
|
|
#include "stm32l0xx_nucleo.h"
|
|
#include "usart.h"
|
|
#include "usart.h"
|
|
|
|
+#include "io.h"
|
|
#include "lt8920_trs.h"
|
|
#include "lt8920_trs.h"
|
|
#include "lt8920_test.h"
|
|
#include "lt8920_test.h"
|
|
#include "x-nucleo-6180xa1.h"
|
|
#include "x-nucleo-6180xa1.h"
|
|
@@ -9,11 +10,14 @@
|
|
void clock_hsi_init(void);
|
|
void clock_hsi_init(void);
|
|
static void Error_Handler(void);
|
|
static void Error_Handler(void);
|
|
|
|
|
|
|
|
+//#define SENDER
|
|
|
|
+#define RECEIVER
|
|
|
|
+//#define SCANNER
|
|
|
|
|
|
int main()
|
|
int main()
|
|
{
|
|
{
|
|
HAL_Init();
|
|
HAL_Init();
|
|
-
|
|
|
|
|
|
+
|
|
clock_hsi_init();
|
|
clock_hsi_init();
|
|
|
|
|
|
SystemCoreClockUpdate();
|
|
SystemCoreClockUpdate();
|
|
@@ -25,22 +29,36 @@ int main()
|
|
usart_init();
|
|
usart_init();
|
|
printf("Controller starting...\r\n");
|
|
printf("Controller starting...\r\n");
|
|
|
|
|
|
- XNUCLEO6180XA1_GPIO_Init();
|
|
|
|
|
|
+ //io_init();
|
|
|
|
+ //XNUCLEO6180XA1_GPIO_Init();
|
|
|
|
+
|
|
|
|
+ BSP_LED_On(LED2);
|
|
|
|
|
|
// -------------------------------------------------------------------------- //
|
|
// -------------------------------------------------------------------------- //
|
|
// RF module
|
|
// RF module
|
|
lt_init();
|
|
lt_init();
|
|
|
|
|
|
- //lt_scanner_init();
|
|
|
|
|
|
+#if defined (SCANNER)
|
|
|
|
+ lt_scanner_init();
|
|
|
|
+#elif defined (SENDER) || defined (RECEIVER)
|
|
|
|
+ lt_common_init();
|
|
|
|
+#endif
|
|
|
|
|
|
- lt_sender_init();
|
|
|
|
-
|
|
|
|
while (1)
|
|
while (1)
|
|
{
|
|
{
|
|
- //BSP_LED_Toggle(LED2);
|
|
|
|
|
|
+ BSP_LED_Toggle(LED2);
|
|
|
|
+ //HAL_Delay(200);
|
|
|
|
+
|
|
|
|
+
|
|
//lt_scanner_test();
|
|
//lt_scanner_test();
|
|
//lt_spi_test();
|
|
//lt_spi_test();
|
|
- //HAL_Delay(250);
|
|
|
|
|
|
+#if defined (SENDER)
|
|
|
|
+ lt_sender_test();
|
|
|
|
+#elif defined (RECEIVER)
|
|
|
|
+ lt_receiver_test();
|
|
|
|
+#elif defined (SCANNER)
|
|
|
|
+ lt_scanner_test();
|
|
|
|
+#endif
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -49,8 +67,8 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
|
|
{
|
|
{
|
|
if (GPIO_Pin == KEY_BUTTON_PIN)
|
|
if (GPIO_Pin == KEY_BUTTON_PIN)
|
|
{
|
|
{
|
|
- BSP_LED_Toggle(LED2);
|
|
|
|
- lt_sender_test();
|
|
|
|
|
|
+ //BSP_LED_Toggle(LED2);
|
|
|
|
+ //lt_sender_test();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -63,6 +81,15 @@ void clock_hsi_init(void)
|
|
__HAL_RCC_PWR_CLK_ENABLE();
|
|
__HAL_RCC_PWR_CLK_ENABLE();
|
|
|
|
|
|
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
|
|
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
|
|
|
|
+
|
|
|
|
+/*
|
|
|
|
+ RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK;
|
|
|
|
+ RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSE;
|
|
|
|
+ if(HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK)
|
|
|
|
+ {
|
|
|
|
+ Error_Handler();
|
|
|
|
+ }
|
|
|
|
+*/
|
|
|
|
|
|
/* -2- Enable HSI Oscillator, select it as PLL source and finally activate the PLL */
|
|
/* -2- Enable HSI Oscillator, select it as PLL source and finally activate the PLL */
|
|
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
|
|
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
|
|
@@ -87,6 +114,16 @@ void clock_hsi_init(void)
|
|
{
|
|
{
|
|
Error_Handler();
|
|
Error_Handler();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /* -4- Optional: Disable HSE Oscillator (if the HSE is no more needed by the application) */
|
|
|
|
+ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
|
|
|
|
+ RCC_OscInitStruct.HSEState = RCC_HSE_OFF;
|
|
|
|
+ RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
|
|
|
|
+ if(HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
|
|
|
|
+ {
|
|
|
|
+ /* Initialization Error */
|
|
|
|
+ Error_Handler();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
//
|
|
//
|