working on l452

This commit is contained in:
ggw
2026-04-28 17:40:30 -05:00
parent d853c57c16
commit 4e4ea8f15e
13 changed files with 266 additions and 4949 deletions
+8 -10
View File
@@ -13,11 +13,10 @@ volatile extern bool usb_ready;
// if not we switch banks and write out the now unactive databank
template<typename packet_type>
void write(packet_type packet) {
if (pos + sizeof(packet) + 4 < sizeof(databank1)) {
*(uint16_t*)(&databank1[pos]) = sizeof(packet);
*(uint16_t*)(&databank1[pos + 2]) = typecode(packet);
memcpy(databank1 + pos + 4, &packet, sizeof(packet));
pos += sizeof(packet) + 4;
if (pos + sizeof(packet) + 2 < sizeof(databank1)) {
*(uint16_t*)(&databank1[pos]) = typecode<packet_type>();
memcpy(databank1 + pos + 2, &packet, sizeof(packet));
pos += sizeof(packet) + 2;
return;
} else if (pos < sizeof(databank1)) {
if (usb_ready) {
@@ -27,12 +26,11 @@ void write(packet_type packet) {
memset(databank2, 0, sizeof(databank2));
pos = sizeof(databank1);
return write(packet);
} else if (pos + sizeof(packet) + 4 <
} else if (pos + sizeof(packet) + 2 <
sizeof(databank1) + sizeof(databank2)) {
*(uint16_t*)(&databank2[pos - sizeof(databank1)]) = sizeof(packet);
*(uint16_t*)(&databank2[pos + 2 - sizeof(databank1)]) = typecode(packet);
memcpy(databank2 + pos + 4 - sizeof(databank1), &packet, sizeof(packet));
pos += sizeof(packet) + 4;
*(uint16_t*)(&databank2[pos - sizeof(databank1)]) = typecode<packet_type>();
memcpy(databank2 + pos + 2 - sizeof(databank1), &packet, sizeof(packet));
pos += sizeof(packet) + 2;
return;
} else {
if (usb_ready) {
@@ -0,0 +1,2 @@
void data_description();
+52 -49
View File
@@ -1,102 +1,105 @@
//#pragma once
#pragma once
//#include "rtc.h"
//#include <refl.hpp>
//#include <type_traits>
//#include <cstdio>
//#include <cstddef>
#include <cstdint>
struct timer_time {
uint16_t tim6_value;
uint16_t tim6_reloads;
};
#include "rtc.h"
struct packet_rtc {
struct timer_time t;
uint32_t t;
RTC_TimeTypeDef sTime;
RTC_DateTypeDef sDate;
};
struct packet_vbatt {
struct timer_time t;
uint32_t t;
uint16_t vbatt_cnts;
};
struct packet_imu {
struct timer_time t;
uint32_t t;
uint16_t readings_cnts[4];
};
struct packet_ekg {
struct timer_time t;
uint32_t t;
uint8_t index;
uint32_t readings_cnts[50];
};
struct packet_strain {
struct timer_time t;
uint32_t t;
uint8_t index;
uint32_t readings_cnts[5];
};
struct packet_outsideT {
struct timer_time t;
uint32_t t;
uint8_t index;
uint32_t readings_cnts[5];
};
struct packet_insideT {
struct timer_time t;
uint32_t t;
uint8_t index;
uint32_t readings_cnts[5];
};
struct packet_button {
struct timer_time t;
uint32_t t;
uint8_t button_vec;
};
struct packet_spo2 {
struct timer_time t;
uint32_t t;
uint32_t green_cnts[25];
uint32_t red_cnts[25];
uint32_t ir_cnts[25];
};
// __inline__ uint8_t typecode(struct packet_rtc) {
// return 1;
// }
template<typename T>
__inline__ uint8_t typecode() {
return 0;
}
// __inline__ uint8_t typecode(struct packet_vbatt) {
// return 2;
// }
template<>
__inline__ uint8_t typecode<struct packet_rtc>() {
return 1;
}
// __inline__ uint8_t typecode(struct packet_ekg) {
// return 3;
// }
template<>
__inline__ uint8_t typecode<struct packet_vbatt>() {
return 2;
}
// __inline__ uint8_t typecode(struct packet_strain) {
// return 4;
// }
template<>
__inline__ uint8_t typecode<struct packet_ekg>() {
return 3;
}
// __inline__ uint8_t typecode(struct packet_outsideT) {
// return 5;
// }
template<>
__inline__ uint8_t typecode<struct packet_strain>() {
return 4;
}
// __inline__ uint8_t typecode(struct packet_insideT) {
// return 6;
// }
template<>
__inline__ uint8_t typecode<struct packet_outsideT>() {
return 5;
}
// __inline__ uint8_t typecode(struct packet_button) {
// return 7;
// }
template<>
__inline__ uint8_t typecode<struct packet_insideT>() {
return 6;
}
// __inline__ uint8_t typecode(struct packet_spo2) {
// return 8;
// }
template<>
__inline__ uint8_t typecode<struct packet_button>() {
return 7;
}
// __inline__ uint8_t typecode(struct packet_imu) {
// return 9;
// }
template<>
__inline__ uint8_t typecode<struct packet_spo2>() {
return 8;
}
template<>
__inline__ uint8_t typecode<struct packet_imu>() {
return 9;
}
File diff suppressed because it is too large Load Diff