Commit bdeaa192 authored by Thodoris Nestoridis's avatar Thodoris Nestoridis

smoke detector

parent 6a27d948
...@@ -35,6 +35,19 @@ ...@@ -35,6 +35,19 @@
//#define MSGQUEUE_OBJECTS 1 // number of Message Queue Objects //#define MSGQUEUE_OBJECTS 1 // number of Message Queue Objects
#define FLAG_DATA 0x00000001U #define FLAG_DATA 0x00000001U
#define FLAG_SLEEP 0x00000001U #define FLAG_SLEEP 0x00000001U
// Define I2C address and register addresses
#define ADPD188BI 0x64
#define MODE 0x10
#define SAMPLE_CLK 0x4B
#define PROGRAM_MODE_MSB 0b00000000
#define PROGRAM_MODE_LSB 0b00000001
#define NORMAL_MODE_MSB 0b00000000
#define NORMAL_MODE_LSB 0b00000010
#define SAMPLE_CLK_ENABLED_MSB 0b01001100
#define SAMPLE_CLK_ENABLED_LSB 0b10010010
/* USER CODE END PD */ /* USER CODE END PD */
/* Private macro -------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/
...@@ -48,7 +61,7 @@ ADC_HandleTypeDef hadc; ...@@ -48,7 +61,7 @@ ADC_HandleTypeDef hadc;
DAC_HandleTypeDef hdac; DAC_HandleTypeDef hdac;
SPI_HandleTypeDef hspi1; SPI_HandleTypeDef hspi1;
I2C_HandleTypeDef hi2c2;
TIM_HandleTypeDef htim6; TIM_HandleTypeDef htim6;
UART_HandleTypeDef huart2; UART_HandleTypeDef huart2;
...@@ -81,21 +94,23 @@ int ContactBounceTime = 0; // Timer to avoid contact bounce in interrupt routine ...@@ -81,21 +94,23 @@ int ContactBounceTime = 0; // Timer to avoid contact bounce in interrupt routine
int WindSpeed; // speed miles per hour int WindSpeed; // speed miles per hour
int counter=-1; int counter=-1;
osEventFlagsId_t evt_data; osEventFlagsId_t evt_data;
osEventFlagsId_t evt_sleep; osEventFlagsId_t evt_sleep;
/* USER CODE END PV */ /* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void); void SystemClock_Config(void);
static void MX_GPIO_Init(void); static void MX_GPIO_Init(void);
static void MX_USART2_UART_Init(void); static void MX_USART2_UART_Init(void);
static void MX_ADC_Init(void); static void MX_ADC_Init(void);
static void MX_DAC_Init(void); static void MX_DAC_Init(void);
static void MX_TIM6_Init(void); static void MX_TIM6_Init(void);
static void MX_SPI1_Init(void); static void MX_SPI1_Init(void);
static void MX_I2C2_Init(void);
void SendDataTask(void *argument); void SendDataTask(void *argument);
void CommandTask(void *argument); void CommandTask(void *argument);
void DataCollectionTask(void *argument); void DataCollectionTask(void *argument);
...@@ -106,7 +121,7 @@ void DataCollectionTask(void *argument); ...@@ -106,7 +121,7 @@ void DataCollectionTask(void *argument);
/* Private user code ---------------------------------------------------------*/ /* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */ /* USER CODE BEGIN 0 */
uint16_t SENSOR_DATA[3]; uint16_t SENSOR_DATA[4];
int STAND_BY = 0; int STAND_BY = 0;
#define PUTCHAR_PROTOTYPE int __io_putchar(int ch) #define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
...@@ -156,6 +171,62 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) ...@@ -156,6 +171,62 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
} }
uint8_t i2c_readRegisterByte(uint8_t deviceAddress, uint8_t registerAddress) {
uint8_t data;
HAL_I2C_Mem_Read(&hi2c2, deviceAddress << 1, registerAddress, 1, &data, 1, HAL_MAX_DELAY);
return data;
}
uint8_t i2c_writeRegisterByte(uint8_t deviceAddress, uint8_t registerAddress, uint8_t MSB_RegisterByte, uint8_t LSB_RegisterByte) {
uint8_t data[2] = {MSB_RegisterByte, LSB_RegisterByte};
return HAL_I2C_Mem_Write(&hi2c2, deviceAddress << 1, registerAddress, 1, data, 2, HAL_MAX_DELAY);
}
void ADPD188BI_StartSampling(void) {
// Set CLK32K_EN bit to 1 and force the device into program mode
i2c_writeRegisterByte(ADPD188BI, SAMPLE_CLK, SAMPLE_CLK_ENABLED_MSB, SAMPLE_CLK_ENABLED_LSB);
i2c_writeRegisterByte(ADPD188BI, MODE, PROGRAM_MODE_MSB, PROGRAM_MODE_LSB);
// Recommended settings ADPD188BI (Table 26 from Data Sheet)
i2c_writeRegisterByte(ADPD188BI, 0x11, 0x30, 0x68);
i2c_writeRegisterByte(ADPD188BI, 0x12, 0x02, 0x00);
i2c_writeRegisterByte(ADPD188BI, 0x14, 0x01, 0x1D);
i2c_writeRegisterByte(ADPD188BI, 0x15, 0x00, 0x00);
i2c_writeRegisterByte(ADPD188BI, 0x17, 0x00, 0x09);
i2c_writeRegisterByte(ADPD188BI, 0x18, 0x00, 0x00);
i2c_writeRegisterByte(ADPD188BI, 0x19, 0x3F, 0xFF);
i2c_writeRegisterByte(ADPD188BI, 0x1A, 0x3F, 0xFF);
i2c_writeRegisterByte(ADPD188BI, 0x1B, 0x3F, 0xFF);
i2c_writeRegisterByte(ADPD188BI, 0x1D, 0x00, 0x09);
i2c_writeRegisterByte(ADPD188BI, 0x1E, 0x00, 0x00);
i2c_writeRegisterByte(ADPD188BI, 0x1F, 0x3F, 0xFF);
i2c_writeRegisterByte(ADPD188BI, 0x20, 0x3F, 0xFF);
i2c_writeRegisterByte(ADPD188BI, 0x21, 0x3F, 0xFF);
i2c_writeRegisterByte(ADPD188BI, 0x22, 0x35, 0x39);
i2c_writeRegisterByte(ADPD188BI, 0x23, 0x35, 0x36);
i2c_writeRegisterByte(ADPD188BI, 0x24, 0x15, 0x30);
i2c_writeRegisterByte(ADPD188BI, 0x25, 0x63, 0x0C);
i2c_writeRegisterByte(ADPD188BI, 0x30, 0x03, 0x20);
i2c_writeRegisterByte(ADPD188BI, 0x31, 0x04, 0x0E);
i2c_writeRegisterByte(ADPD188BI, 0x35, 0x03, 0x20);
i2c_writeRegisterByte(ADPD188BI, 0x36, 0x04, 0x0E);
i2c_writeRegisterByte(ADPD188BI, 0x39, 0x22, 0xF0);
i2c_writeRegisterByte(ADPD188BI, 0x3B, 0x22, 0xF0);
i2c_writeRegisterByte(ADPD188BI, 0x3C, 0x31, 0xC6);
i2c_writeRegisterByte(ADPD188BI, 0x42, 0x1C, 0x34);
i2c_writeRegisterByte(ADPD188BI, 0x43, 0xAD, 0xA5);
i2c_writeRegisterByte(ADPD188BI, 0x44, 0x1C, 0x34);
i2c_writeRegisterByte(ADPD188BI, 0x45, 0xAD, 0xA5);
i2c_writeRegisterByte(ADPD188BI, 0x58, 0x05, 0x44);
i2c_writeRegisterByte(ADPD188BI, 0x11, 0x30, 0xA9);
// Start normal Sampling operation
i2c_writeRegisterByte(ADPD188BI, MODE, NORMAL_MODE_MSB, NORMAL_MODE_LSB);
}
// Function for SPI Communication to send data to IoT Tracker // Function for SPI Communication to send data to IoT Tracker
int iot_tracker_communication(uint8_t* TX_Data, uint8_t* RX_Data ) { int iot_tracker_communication(uint8_t* TX_Data, uint8_t* RX_Data ) {
//char spimsg[50]; //char spimsg[50];
...@@ -172,7 +243,7 @@ int iot_tracker_communication(uint8_t* TX_Data, uint8_t* RX_Data ) { ...@@ -172,7 +243,7 @@ int iot_tracker_communication(uint8_t* TX_Data, uint8_t* RX_Data ) {
uint8_t i = *RX_Data; uint8_t i = *RX_Data;
//NEED TO MAKE NORMILIZATION FOR THE SENSOR DATA //NEED TO MAKE NORMILIZATION FOR THE SENSOR DATA
if (i == 0){ if (i == 0 || i == 3){
*TX_Data = SENSOR_DATA[i]; *TX_Data = SENSOR_DATA[i];
//sprintf(msg, "I got the command to send the %d st and i will send the value: %d \r\n", i, *TX_Data); //sprintf(msg, "I got the command to send the %d st and i will send the value: %d \r\n", i, *TX_Data);
//HAL_UART_Transmit(&huart2, (uint16_t*)msg, strlen(msg), HAL_MAX_DELAY); //HAL_UART_Transmit(&huart2, (uint16_t*)msg, strlen(msg), HAL_MAX_DELAY);
...@@ -219,6 +290,7 @@ int main(void) ...@@ -219,6 +290,7 @@ int main(void)
MX_DAC_Init(); MX_DAC_Init();
MX_TIM6_Init(); MX_TIM6_Init();
MX_SPI1_Init(); MX_SPI1_Init();
MX_I2C2_Init();
/* USER CODE BEGIN 2 */ /* USER CODE BEGIN 2 */
/* USER CODE END 2 */ /* USER CODE END 2 */
...@@ -253,6 +325,8 @@ int main(void) ...@@ -253,6 +325,8 @@ int main(void)
/* creation of Command */ /* creation of Command */
CommandHandle = osThreadNew(CommandTask, NULL, &Command_attributes); CommandHandle = osThreadNew(CommandTask, NULL, &Command_attributes);
/* USER CODE BEGIN RTOS_THREADS */ /* USER CODE BEGIN RTOS_THREADS */
/* add threads, ... */ /* add threads, ... */
/* USER CODE END RTOS_THREADS */ /* USER CODE END RTOS_THREADS */
...@@ -673,7 +747,7 @@ void SendDataTask(void *argument) ...@@ -673,7 +747,7 @@ void SendDataTask(void *argument)
TX_Data = SENSOR_DATA[0]; TX_Data = SENSOR_DATA[0];
while(counter !=3){ while(counter !=4){
iot_tracker_communication((uint8_t*) &TX_Data,(uint8_t*) &RX_Data ); iot_tracker_communication((uint8_t*) &TX_Data,(uint8_t*) &RX_Data );
counter = RX_Data; counter = RX_Data;
} }
...@@ -706,6 +780,7 @@ void DataCollectionTask(void *argument) ...@@ -706,6 +780,7 @@ void DataCollectionTask(void *argument)
uint8_t wind_speed_val; uint8_t wind_speed_val;
uint16_t wind_direction_val; uint16_t wind_direction_val;
uint16_t flame_val; uint16_t flame_val;
uint16_t smoke_detection_data;
char msg[50]; char msg[50];
...@@ -790,7 +865,23 @@ void DataCollectionTask(void *argument) ...@@ -790,7 +865,23 @@ void DataCollectionTask(void *argument)
SENSOR_DATA[2] = flame_val; SENSOR_DATA[2] = flame_val;
sprintf(msg, "DATA COLLECTION TASK END!2!! %d %d %d \r\n", wind_speed_val, wind_direction_val/16, flame_val/16 );
ADPD188BI_StartSampling(); // Start sampling operation
// Add your main loop logic here
smoke_detection_data = i2c_readRegisterByte(ADPD188BI, 0x64) << 8;
smoke_detection_data |= i2c_readRegisterByte(ADPD188BI, 0x65);
// Process the data as needed
//char buffer[20]; // A buffer to hold the string representation of the data
//sprintf(buffer, "Smoke data: %02d\r\n", smoke_detection_data);
//HAL_UART_Transmit(&huart2, buffer, strlen((char*)buffer), HAL_MAX_DELAY);
i2c_writeRegisterByte(ADPD188BI, MODE, 0x00, 0x00); //sleep mode
SENSOR_DATA[3] = smoke_detection_data/125;
sprintf(msg, "DATA COLLECTION TASK END!2!! %d %d %d %d \r\n", wind_speed_val, wind_direction_val/16, flame_val/16, smoke_detection_data/125 );
HAL_UART_Transmit(&huart2, (uint16_t*)msg, strlen(msg), HAL_MAX_DELAY); HAL_UART_Transmit(&huart2, (uint16_t*)msg, strlen(msg), HAL_MAX_DELAY);
osEventFlagsSet(evt_data, FLAG_DATA); osEventFlagsSet(evt_data, FLAG_DATA);
...@@ -821,6 +912,51 @@ void Error_Handler(void) ...@@ -821,6 +912,51 @@ void Error_Handler(void)
/* USER CODE END Error_Handler_Debug */ /* USER CODE END Error_Handler_Debug */
} }
static void MX_I2C2_Init(void)
{
/* USER CODE BEGIN I2C2_Init 0 */
/* USER CODE END I2C2_Init 0 */
/* USER CODE BEGIN I2C2_Init 1 */
/* USER CODE END I2C2_Init 1 */
hi2c2.Instance = I2C2;
hi2c2.Init.Timing = 0x00707CBB;
hi2c2.Init.OwnAddress1 = 0;
hi2c2.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
hi2c2.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
hi2c2.Init.OwnAddress2 = 0;
hi2c2.Init.OwnAddress2Masks = I2C_OA2_NOMASK;
hi2c2.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
hi2c2.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
if (HAL_I2C_Init(&hi2c2) != HAL_OK)
{
Error_Handler();
}
/** Configure Analogue filter
*/
if (HAL_I2CEx_ConfigAnalogFilter(&hi2c2, I2C_ANALOGFILTER_ENABLE) != HAL_OK)
{
Error_Handler();
}
/** Configure Digital filter
*/
if (HAL_I2CEx_ConfigDigitalFilter(&hi2c2, 0) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN I2C2_Init 2 */
/* USER CODE END I2C2_Init 2 */
}
#ifdef USE_FULL_ASSERT #ifdef USE_FULL_ASSERT
/** /**
* @brief Reports the name of the source file and the source line number * @brief Reports the name of the source file and the source line number
......
...@@ -202,6 +202,73 @@ void HAL_DAC_MspDeInit(DAC_HandleTypeDef* hdac) ...@@ -202,6 +202,73 @@ void HAL_DAC_MspDeInit(DAC_HandleTypeDef* hdac)
} }
/**
* @brief I2C MSP Initialization
* This function configures the hardware resources used in this example
* @param hi2c: I2C handle pointer
* @retval None
*/
void HAL_I2C_MspInit(I2C_HandleTypeDef* hi2c)
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
if(hi2c->Instance==I2C2)
{
/* USER CODE BEGIN I2C2_MspInit 0 */
/* USER CODE END I2C2_MspInit 0 */
__HAL_RCC_GPIOB_CLK_ENABLE();
/**I2C2 GPIO Configuration
PB10 ------> I2C2_SCL
PB11 ------> I2C2_SDA
*/
GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_11;
GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF6_I2C2;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
/* Peripheral clock enable */
__HAL_RCC_I2C2_CLK_ENABLE();
/* USER CODE BEGIN I2C2_MspInit 1 */
/* USER CODE END I2C2_MspInit 1 */
}
}
/**
* @brief I2C MSP De-Initialization
* This function freeze the hardware resources used in this example
* @param hi2c: I2C handle pointer
* @retval None
*/
void HAL_I2C_MspDeInit(I2C_HandleTypeDef* hi2c)
{
if(hi2c->Instance==I2C2)
{
/* USER CODE BEGIN I2C2_MspDeInit 0 */
/* USER CODE END I2C2_MspDeInit 0 */
/* Peripheral clock disable */
__HAL_RCC_I2C2_CLK_DISABLE();
/**I2C2 GPIO Configuration
PB10 ------> I2C2_SCL
PB11 ------> I2C2_SDA
*/
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_10);
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_11);
/* USER CODE BEGIN I2C2_MspDeInit 1 */
/* USER CODE END I2C2_MspDeInit 1 */
}
}
/** /**
* @brief SPI MSP Initialization * @brief SPI MSP Initialization
* This function configures the hardware resources used in this example * This function configures the hardware resources used in this example
......
../Core/Src/main.c:116:6:HAL_GPIO_EXTI_Callback 72 static,ignoring_inline_asm ../Core/Src/main.c:131:6:HAL_GPIO_EXTI_Callback 72 static,ignoring_inline_asm
../Core/Src/main.c:160:5:iot_tracker_communication 32 static ../Core/Src/main.c:174:9:i2c_readRegisterByte 48 static
../Core/Src/main.c:196:5:main 8 static ../Core/Src/main.c:180:9:i2c_writeRegisterByte 48 static
../Core/Src/main.c:275:6:SystemClock_Config 136 static ../Core/Src/main.c:186:6:ADPD188BI_StartSampling 8 static
../Core/Src/main.c:326:13:MX_ADC_Init 16 static ../Core/Src/main.c:231:5:iot_tracker_communication 32 static
../Core/Src/main.c:390:13:MX_DAC_Init 16 static ../Core/Src/main.c:267:5:main 8 static
../Core/Src/main.c:430:13:MX_SPI1_Init 8 static ../Core/Src/main.c:349:6:SystemClock_Config 136 static
../Core/Src/main.c:468:13:MX_TIM6_Init 16 static ../Core/Src/main.c:400:13:MX_ADC_Init 16 static
../Core/Src/main.c:506:13:MX_USART2_UART_Init 8 static ../Core/Src/main.c:464:13:MX_DAC_Init 16 static
../Core/Src/main.c:541:13:MX_GPIO_Init 56 static ../Core/Src/main.c:504:13:MX_SPI1_Init 8 static
../Core/Src/main.c:592:1:__io_putchar 16 static ../Core/Src/main.c:542:13:MX_TIM6_Init 16 static
../Core/Src/main.c:612:6:CommandTask 80 static,ignoring_inline_asm ../Core/Src/main.c:580:13:MX_USART2_UART_Init 8 static
../Core/Src/main.c:656:6:SendDataTask 88 static ../Core/Src/main.c:615:13:MX_GPIO_Init 56 static
../Core/Src/main.c:703:6:DataCollectionTask 112 static,ignoring_inline_asm ../Core/Src/main.c:666:1:__io_putchar 16 static
../Core/Src/main.c:808:6:Error_Handler 64 static,ignoring_inline_asm ../Core/Src/main.c:686:6:CommandTask 80 static,ignoring_inline_asm
../Core/Src/main.c:730:6:SendDataTask 88 static
../Core/Src/main.c:777:6:DataCollectionTask 120 static,ignoring_inline_asm
../Core/Src/main.c:899:6:Error_Handler 64 static,ignoring_inline_asm
../Core/Src/main.c:916:13:MX_I2C2_Init 8 static
...@@ -3,9 +3,11 @@ ...@@ -3,9 +3,11 @@
../Core/Src/stm32l0xx_hal_msp.c:121:6:HAL_ADC_MspDeInit 16 static ../Core/Src/stm32l0xx_hal_msp.c:121:6:HAL_ADC_MspDeInit 16 static
../Core/Src/stm32l0xx_hal_msp.c:150:6:HAL_DAC_MspInit 48 static ../Core/Src/stm32l0xx_hal_msp.c:150:6:HAL_DAC_MspInit 48 static
../Core/Src/stm32l0xx_hal_msp.c:183:6:HAL_DAC_MspDeInit 16 static ../Core/Src/stm32l0xx_hal_msp.c:183:6:HAL_DAC_MspDeInit 16 static
../Core/Src/stm32l0xx_hal_msp.c:211:6:HAL_SPI_MspInit 56 static ../Core/Src/stm32l0xx_hal_msp.c:211:6:HAL_I2C_MspInit 48 static
../Core/Src/stm32l0xx_hal_msp.c:257:6:HAL_SPI_MspDeInit 16 static ../Core/Src/stm32l0xx_hal_msp.c:247:6:HAL_I2C_MspDeInit 16 static
../Core/Src/stm32l0xx_hal_msp.c:290:6:HAL_TIM_Base_MspInit 16 static ../Core/Src/stm32l0xx_hal_msp.c:278:6:HAL_SPI_MspInit 56 static
../Core/Src/stm32l0xx_hal_msp.c:312:6:HAL_TIM_Base_MspDeInit 16 static ../Core/Src/stm32l0xx_hal_msp.c:324:6:HAL_SPI_MspDeInit 16 static
../Core/Src/stm32l0xx_hal_msp.c:334:6:HAL_UART_MspInit 48 static ../Core/Src/stm32l0xx_hal_msp.c:357:6:HAL_TIM_Base_MspInit 16 static
../Core/Src/stm32l0xx_hal_msp.c:370:6:HAL_UART_MspDeInit 16 static ../Core/Src/stm32l0xx_hal_msp.c:379:6:HAL_TIM_Base_MspDeInit 16 static
../Core/Src/stm32l0xx_hal_msp.c:401:6:HAL_UART_MspInit 48 static
../Core/Src/stm32l0xx_hal_msp.c:437:6:HAL_UART_MspDeInit 16 static
This diff is collapsed.
...@@ -4,19 +4,22 @@ FREERTOS.IPParameters=Tasks01,FootprintOK ...@@ -4,19 +4,22 @@ FREERTOS.IPParameters=Tasks01,FootprintOK
FREERTOS.Tasks01=Communications,24,128,CommunicationsTask,Default,NULL,Dynamic,NULL,NULL;Sensor,24,128,SensorTask,Default,NULL,Dynamic,NULL,NULL FREERTOS.Tasks01=Communications,24,128,CommunicationsTask,Default,NULL,Dynamic,NULL,NULL;Sensor,24,128,SensorTask,Default,NULL,Dynamic,NULL,NULL
File.Version=6 File.Version=6
GPIO.groupedBy=Group By Peripherals GPIO.groupedBy=Group By Peripherals
I2C2.IPParameters=Timing
I2C2.Timing=0x00707CBB
KeepUserPlacement=false KeepUserPlacement=false
Mcu.CPN=STM32L073RZT3 Mcu.CPN=STM32L073RZT3
Mcu.Family=STM32L0 Mcu.Family=STM32L0
Mcu.IP0=ADC Mcu.IP0=ADC
Mcu.IP1=DAC Mcu.IP1=DAC
Mcu.IP2=FREERTOS Mcu.IP2=FREERTOS
Mcu.IP3=NVIC Mcu.IP3=I2C2
Mcu.IP4=RCC Mcu.IP4=NVIC
Mcu.IP5=SPI1 Mcu.IP5=RCC
Mcu.IP6=SYS Mcu.IP6=SPI1
Mcu.IP7=TIM6 Mcu.IP7=SYS
Mcu.IP8=USART2 Mcu.IP8=TIM6
Mcu.IPNb=9 Mcu.IP9=USART2
Mcu.IPNb=10
Mcu.Name=STM32L073R(B-Z)Tx Mcu.Name=STM32L073R(B-Z)Tx
Mcu.Package=LQFP64 Mcu.Package=LQFP64
Mcu.Pin0=PC13 Mcu.Pin0=PC13
...@@ -24,16 +27,18 @@ Mcu.Pin1=PC14-OSC32_IN ...@@ -24,16 +27,18 @@ Mcu.Pin1=PC14-OSC32_IN
Mcu.Pin10=PA6 Mcu.Pin10=PA6
Mcu.Pin11=PA7 Mcu.Pin11=PA7
Mcu.Pin12=PB1 Mcu.Pin12=PB1
Mcu.Pin13=PA9 Mcu.Pin13=PB10
Mcu.Pin14=PA10 Mcu.Pin14=PB11
Mcu.Pin15=PA13 Mcu.Pin15=PA9
Mcu.Pin16=PA14 Mcu.Pin16=PA10
Mcu.Pin17=PA15 Mcu.Pin17=PA13
Mcu.Pin18=PB3 Mcu.Pin18=PA14
Mcu.Pin19=VP_FREERTOS_VS_CMSIS_V2 Mcu.Pin19=PA15
Mcu.Pin2=PC15-OSC32_OUT Mcu.Pin2=PC15-OSC32_OUT
Mcu.Pin20=VP_SYS_VS_Systick Mcu.Pin20=PB3
Mcu.Pin21=VP_TIM6_VS_ClockSourceINT Mcu.Pin21=VP_FREERTOS_VS_CMSIS_V2
Mcu.Pin22=VP_SYS_VS_Systick
Mcu.Pin23=VP_TIM6_VS_ClockSourceINT
Mcu.Pin3=PH0-OSC_IN Mcu.Pin3=PH0-OSC_IN
Mcu.Pin4=PA0 Mcu.Pin4=PA0
Mcu.Pin5=PA1 Mcu.Pin5=PA1
...@@ -41,7 +46,7 @@ Mcu.Pin6=PA2 ...@@ -41,7 +46,7 @@ Mcu.Pin6=PA2
Mcu.Pin7=PA3 Mcu.Pin7=PA3
Mcu.Pin8=PA4 Mcu.Pin8=PA4
Mcu.Pin9=PA5 Mcu.Pin9=PA5
Mcu.PinsNb=22 Mcu.PinsNb=24
Mcu.ThirdPartyNb=0 Mcu.ThirdPartyNb=0
Mcu.UserConstants= Mcu.UserConstants=
Mcu.UserName=STM32L073RZTx Mcu.UserName=STM32L073RZTx
...@@ -96,6 +101,10 @@ PA9.Locked=true ...@@ -96,6 +101,10 @@ PA9.Locked=true
PA9.Signal=GPXTI9 PA9.Signal=GPXTI9
PB1.Locked=true PB1.Locked=true
PB1.Signal=GPXTI1 PB1.Signal=GPXTI1
PB10.Mode=I2C
PB10.Signal=I2C2_SCL
PB11.Mode=I2C
PB11.Signal=I2C2_SDA
PB3.Mode=Full_Duplex_Slave PB3.Mode=Full_Duplex_Slave
PB3.Signal=SPI1_SCK PB3.Signal=SPI1_SCK
PC13.Locked=true PC13.Locked=true
...@@ -126,14 +135,14 @@ ProjectManager.FreePins=false ...@@ -126,14 +135,14 @@ ProjectManager.FreePins=false
ProjectManager.HalAssertFull=false ProjectManager.HalAssertFull=false
ProjectManager.HeapSize=0x200 ProjectManager.HeapSize=0x200
ProjectManager.KeepUserCode=true ProjectManager.KeepUserCode=true
ProjectManager.LastFirmware=true ProjectManager.LastFirmware=false
ProjectManager.LibraryCopy=1 ProjectManager.LibraryCopy=1
ProjectManager.MainLocation=Core/Src ProjectManager.MainLocation=Core/Src
ProjectManager.NoMain=false ProjectManager.NoMain=false
ProjectManager.PreviousToolchain= ProjectManager.PreviousToolchain=
ProjectManager.ProjectBuild=false ProjectManager.ProjectBuild=false
ProjectManager.ProjectFileName=final_project.ioc ProjectManager.ProjectFileName=LoRa_Nucleo.ioc
ProjectManager.ProjectName=final_project ProjectManager.ProjectName=LoRa_Nucleo
ProjectManager.RegisterCallBack= ProjectManager.RegisterCallBack=
ProjectManager.StackSize=0x400 ProjectManager.StackSize=0x400
ProjectManager.TargetToolchain=STM32CubeIDE ProjectManager.TargetToolchain=STM32CubeIDE
......
...@@ -137,6 +137,7 @@ typedef struct ...@@ -137,6 +137,7 @@ typedef struct
uint8_t wind_speed; uint8_t wind_speed;
uint8_t wind_direction; uint8_t wind_direction;
uint8_t flame_sensor; uint8_t flame_sensor;
uint8_t smoke_data;
/**more may be added*/ /**more may be added*/
} sensor_t; } sensor_t;
......
...@@ -167,6 +167,7 @@ typedef void (*pCmdHandlerFunc_t)(char *pcInStr); ...@@ -167,6 +167,7 @@ typedef void (*pCmdHandlerFunc_t)(char *pcInStr);
uint8_t wind_speed; uint8_t wind_speed;
uint8_t wind_direction; uint8_t wind_direction;
uint8_t flame_sensor; uint8_t flame_sensor;
uint8_t smoke_data;
} LogData_t; } LogData_t;
......
...@@ -134,7 +134,7 @@ static uint32_t SpiFrequency( uint32_t hz ); ...@@ -134,7 +134,7 @@ static uint32_t SpiFrequency( uint32_t hz );
/* Buffer used for transmission */ /* Buffer used for transmission */
uint8_t aRxBuffer = 0x6FU; uint8_t aRxBuffer = 0x6FU;
uint8_t aTxBuffer = 0xA1U; uint8_t aTxBuffer = 0xA1U;
uint8_t nucleo_data[3]; uint8_t nucleo_data[4];
HAL_StatusTypeDef status = HAL_OK; HAL_StatusTypeDef status = HAL_OK;
/*! /*!
...@@ -362,7 +362,7 @@ void receive_SPI_data() { ...@@ -362,7 +362,7 @@ void receive_SPI_data() {
aRxBuffer = 0x0; aRxBuffer = 0x0;
aTxBuffer = 0x0; aTxBuffer = 0x0;
//HW_SPI_InOut_Message(); //HW_SPI_InOut_Message();
for(int i=0; i<4; i++){ for(int i=0; i<5; i++){
HW_SPI_InOut_Message(); HW_SPI_InOut_Message();
aTxBuffer++; aTxBuffer++;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment