90 vsprintf(buf, format, argList);
92 if (len > 0 && buf[len - 1] !=
'\n' && buf[len - 2] !=
'\r')
100 va_start(argList, format);
109 HAL_StatusTypeDef res;
114 for (uint8_t addr = 1; addr < 127; addr++)
116 res = HAL_I2C_IsDeviceReady(hi2c, addr << 1, 2, 2);
119 writeLog(
"Found I2C device at 0x%02X", addr);
144 HAL_StatusTypeDef status;
148 writeLog(
"UART read: %d", (
int) status);
201 HAL_StatusTypeDef status;
204 if (status == HAL_OK)
223 writeLog(
"checkResetRestart failed!, status:%d",(
int)status);
237 int8_t afterStandby = 0, status;
238 uint8_t countChanges;
248 HAL_PWREx_SetRadioBusyTrigger(PWR_RADIO_IRQ_TRIGGER_WU_IT);
285 for (
int i = 0; i < 2; i++)
293 HAL_DBGMCU_DisableDBGStandbyMode();
312 writeLog(
"nfc tag: Init %s", (status == HAL_OK) ?
"OK" :
"failed");
441 writeLog(
"nfc_WriteSystemParams: changes:%d status:%s", (
int) countChanges, (status == HAL_OK) ?
"OK" :
"failed");
455 RCC_OscInitTypeDef RCC_OscInitStruct =
457 RCC_ClkInitTypeDef RCC_ClkInitStruct =
462 HAL_PWR_EnableBkUpAccess();
463 __HAL_RCC_LSEDRIVE_CONFIG(RCC_LSEDRIVE_LOW);
467 __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE2);
471 RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSE | RCC_OSCILLATORTYPE_MSI;
472 RCC_OscInitStruct.LSEState = RCC_LSE_ON;
473 RCC_OscInitStruct.MSIState = RCC_MSI_ON;
474 RCC_OscInitStruct.MSICalibrationValue = RCC_MSICALIBRATION_DEFAULT;
475 RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_8;
476 RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
477 if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
484 RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK3 | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
485 RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_MSI;
486 RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
487 RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
488 RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
489 RCC_ClkInitStruct.AHBCLK3Divider = RCC_SYSCLK_DIV1;
491 if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK)
517#ifdef USE_FULL_ASSERT
525void assert_failed(uint8_t *file, uint32_t line)
void MX_LoRaWAN_Process(void)
Entry Lora Process or scheduling.
void MX_LoRaWAN_Init(void)
Init Lora Application.
Header of application of the LRWAN Middleware.
This file contains all the function prototypes for the dma.c file.
void MX_DMA_Init(void)
Initialise DMA1 channels used by USART1 (TX via DMA) and other peripherals. Must be called before MX_...
This file contains all the function prototypes for the gpio.c file.
void MX_GPIO_Init(void)
Initialise all GPIO pins and ports as configured by STM32CubeMX. Enables GPIO clocks,...
This file contains all the function prototypes for the i2c.c file.
void MX_I2C2_Init(void)
Initialise the I2C2 peripheral (hi2c2) as configured by STM32CubeMX. Sets clock speed,...
void LoRaWAN_Init(void)
Init Lora Application.
void systemParams_SetLoRaWanParams()
set the lorawan parameters from _systemParams before start of loraWan
Header of application of the LRWAN Middleware.
void uart_Start()
start of UART reading
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
called from GPIO interrupt
void Error_Handler(void)
This function is executed in case of error occurrence.
static modeDevice_t _modeDevice
void writeLog(const char *format,...)
Format and send a log message over UART (printf-style). Available only when WRITELOG is defined; comp...
static UTIL_TIMER_Object_t _nfcAfterTrigger
static void checkResetRestart()
void SystemClock_Config(void)
System Clock Configuration.
void writeLogVA(const char *format, va_list argList)
Format and send a log message using a va_list argument list. Used internally by writeLog(); can also ...
void setModeDevice(modeDevice_t mod)
set new device mode
int main(void)
The application entry point.
void togle_LedOff(int off)
togle led
void writeLogNL(const char *buf)
Send a pre-formatted C string to the UART log followed by a newline.
static void Uart_RxProcessing()
static volatile int _nfcTagged
void I2C_Scan(I2C_HandleTypeDef *hi2c)
static void sensors_NFCInt()
The interrupt of NFC4 tag.
: Header for main.c file. This file contains the common defines of the application.
modeDevice_t
Device power/sleep mode selector.
#define USER_LED_GPIO_Port
void GetTimeDate()
Filled up _currentTime & _currentDate.
void myloraWan_Init(uint32_t myloraWanAppBit)
initialization of myloraWan process, sequencer
uint8_t mems_WriteToSystemParams()
write data from memory to systemParams
void mems_Init()
Initialise NFC and external flash; load the main block and system parameters. Verifies the flash sign...
HAL_StatusTypeDef mems_Reset()
memory reset - remove sign from chip
void setBackUpRegister(uint32_t backupRegister, uint32_t value)
Write a value to an RTC backup register.
uint32_t getBackUpRegister(uint32_t backupRegister)
Read a value from an RTC backup register.
void sensors_Init(I2C_HandleTypeDef *hi2c)
Initialization of all sensors, must be called before for store of hi2c handler.
void sensorsSeq_Init(uint32_t sensortAppBit, uint32_t mylorawanAppBit)
the sensors sequencer initialization and set the process in sequencer
void i2c_OnOff(uint8_t onOff)
possible to I2C turn on/off - cumulative
systemParams_t _systemParams
void systemParams_Log(const char *info)
Log the current _systemParams fields to the UART debug output.
void sensorsBase_Init()
Initialization of base sensor data structure.
HAL_StatusTypeDef nfc_WriteSystemParams(I2C_HandleTypeDef *hi2c)
Write system params to NFC.
HAL_StatusTypeDef nfc_ReadSystemParams(I2C_HandleTypeDef *hi2c)
reading _systemParams from NFC - all data will be rewrite in _systemParams
HAL_StatusTypeDef nfc_FactoryReset(I2C_HandleTypeDef *hi2c)
reset NFC data to factory - default state
HAL_StatusTypeDef nfc_Init(I2C_HandleTypeDef *hi2c)
NFC initialization and read NFC tag systemParams from addr 0. If data there are not valid,...
This file contains all the function prototypes for the rtc.c file.
void MX_RTC_Init(void)
Initialise the RTC peripheral with settings generated by STM32CubeMX. Configures the prescalers,...
This file contains all the function prototypes for the spi.c file.
void MX_SPI1_Init(void)
Initialise SPI1 peripheral (hspi1) as configured by STM32CubeMX. Sets clock polarity/phase,...
void HAL_Delay(__IO uint32_t Delay)
uint32_t HAL_GetTick(void)
Function prototypes for sys_app.c file.
void SystemApp_Init(void)
initialize the system (dbg pins, trace, mbmux, sys timer, LPM, ...)
configuration of the timer_if.c instances
#define RTC_BKP_STANDBY_SIGN
Magic value stored in RTC_BKP_STANDBY before entering standby mode. On wakeup, if getBackUpRegister(R...
#define RTC_BKP_STANDBY
RTC backup register index used to persist the standby-mode flag across a system reset / wakeup from O...
This file contains all the function prototypes for the usart.c file.
UART_HandleTypeDef huart1
void MX_USART1_UART_Init(void)
Initialise USART1 (huart1) as configured by STM32CubeMX. Sets baud rate, word length,...
Header for USART interface configuration.
UTIL_ADV_TRACE_Status_t Uart_Info(const char *strInfo)
Write to UART1.
UTIL_ADV_TRACE_Status_t Uart_NextReceving()
continue with next reading if data arrived
UTIL_ADV_TRACE_Status_t Uart_StartReceving(UART_HandleTypeDef *uart)
start reading
@ CFG_SEQ_Task_MyLoraSend