BSP+Drivers for EE24+INA

This commit is contained in:
2024-02-24 19:24:00 +01:00
parent 26022126e1
commit af18558f1a
18 changed files with 728 additions and 4 deletions

View File

@@ -32,6 +32,8 @@
#include "ulog.h"
#include "stdio.h"
#include "tim.h"
#include "BSP_EE24.h"
#include "BSP_INA.h"
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
@@ -57,7 +59,7 @@
osThreadId_t defaultTaskHandle;
const osThreadAttr_t defaultTask_attributes = {
.name = "defaultTask",
.stack_size = 128 * 4,
.stack_size = 512 * 4,
.priority = (osPriority_t) osPriorityNormal,
};
@@ -175,11 +177,28 @@ void StartDefaultTask(void *argument)
uint8_t light_data[2] = {0};
BSP_EE24_Init();
BSP_INA_Init();
char INA_LOG[72];
/* Infinite loop */
for(;;)
{
osDelay(1000);
uint16_t current = BSP_INA_Current()*10;
uint16_t voltage = BSP_INA_Voltage();
uint32_t power = (current * voltage)/1000; // milli watts
float power_W = (float)power/1000.0;
float voltage_V =(float) voltage /1000.0;
snprintf(INA_LOG, sizeof(INA_LOG),"Voltage[mV] %.2f Current[mA] %d P[W]: %.2f", voltage_V, current, power_W);
ULOG_INFO(INA_LOG);
light_data[0]++;
light_data[1] = (light_data[0]/10)%4;