75 lines
1.8 KiB
C++
75 lines
1.8 KiB
C++
/*
|
|
* start.cpp
|
|
*
|
|
* Created on: Oct 31, 2024
|
|
* Author: Gabriel
|
|
*/
|
|
|
|
#include "start.h"
|
|
#include <cstdio>
|
|
#include "FreeRTOS.h"
|
|
#include "GPIO_Pin_STM32.hpp"
|
|
#include "LogDriver.hpp"
|
|
#include "GPIO_Pin_STM32.hpp"
|
|
#include "PWM_Pin_STM32.hpp"
|
|
#include "Queue_STM32.hpp"
|
|
#include "CDC_STM32.hpp"
|
|
#include "Encoder_STM32.hpp"
|
|
#include "SoftTimer_STM32.hpp"
|
|
|
|
#include "Components/TelemetryPacket.hpp"
|
|
|
|
#include "main.h"
|
|
#include "usb_device.h"
|
|
#include "usbd_customhid.h"
|
|
extern USBD_HandleTypeDef hUsbDeviceFS;
|
|
|
|
void executableDispatch(void* _executable){
|
|
Executable* executable = static_cast<Executable*>(_executable);
|
|
executable->execute();
|
|
vTaskDelete(NULL);
|
|
}
|
|
|
|
TelemetryPacket pkt;
|
|
|
|
void start(){
|
|
printf("----------------INIT----------------\n");
|
|
printf("X and Y: %u, %u\n", (uint16_t)HAL_GetUIDw0(), (uint16_t)HAL_GetUIDw0()>>16);
|
|
printf("Wafer number: %u\n", (uint8_t)HAL_GetUIDw1());
|
|
printf("Lot number: %c%c%c%c%c%c%c\n",
|
|
(uint8_t)(HAL_GetUIDw1()>>8),
|
|
(uint8_t)(HAL_GetUIDw1()>>16),
|
|
(uint8_t)(HAL_GetUIDw1()>>24),
|
|
(uint8_t)(HAL_GetUIDw2()),
|
|
(uint8_t)(HAL_GetUIDw2()>>8),
|
|
(uint8_t)(HAL_GetUIDw2()>>16),
|
|
(uint8_t)(HAL_GetUIDw2()>>24)
|
|
);
|
|
// Init log facility
|
|
LogDriver::getInstance()->init();
|
|
TaskHandle_t hTaskLogDriver;
|
|
xTaskCreate(executableDispatch, "LogDriver", 256, LogDriver::getInstance(), 5, &hTaskLogDriver);
|
|
|
|
// Init queues
|
|
|
|
// Init shared resources
|
|
|
|
//Init components
|
|
pkt.counter = 0;
|
|
for(uint32_t i=0; i<32; i++){
|
|
pkt.message[i] = 33 + i;
|
|
}
|
|
for(uint32_t i=0; i<23; i++){
|
|
pkt.padding[i] = 0;
|
|
}
|
|
while(true){
|
|
pkt.counter++;
|
|
pkt.timestamp_ms = xTaskGetTickCount();
|
|
uint8_t result = USBD_CUSTOM_HID_SendReport(&hUsbDeviceFS, reinterpret_cast<uint8_t*>(&pkt), 64);
|
|
vTaskDelay(1000);
|
|
}
|
|
|
|
//Init tasks
|
|
vTaskDelete(nullptr);
|
|
}
|