![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
k
Dependencies: MAX30003 max32630fthr
Diff: main.cpp
- Revision:
- 18:101042d225ef
- Parent:
- 17:f0008ebb1040
- Child:
- 19:7a084dc2f09d
diff -r f0008ebb1040 -r 101042d225ef main.cpp --- a/main.cpp Wed Jun 09 17:24:31 2021 +0000 +++ b/main.cpp Fri Jun 11 23:20:20 2021 +0000 @@ -8,8 +8,8 @@ //#include <Serial.h> #include "ds3231.h" -#define TARGET_TX_PIN P0_1 -#define TARGET_RX_PIN P0_0 +#define TARGET_TX_PIN P3_1 +#define TARGET_RX_PIN P3_0 #define SDA P3_4 #define SCL P3_5 @@ -19,7 +19,7 @@ MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3); void task_fast(void); -DigitalOut ledA(LED2); +//DigitalOut ledA(LED2); DigitalOut EN(P1_7); DigitalOut A0(P1_4); @@ -82,14 +82,14 @@ uint16_t rtn_val; //time = 12:00:00 AM 12hr mode - ds3231_time_t time = {0,50,14,1, 0}; // seconds, min, hours, am_pm, mode + ds3231_time_t time = {25,20,9,1, 0}; // seconds, min, hours, am_pm, mode rtn_val = rtc.set_time(time); //see datasheet for calendar format - ds3231_calendar_t calendar = {1, 8, 06, 21}; // day date month year + ds3231_calendar_t calendar = {6, 11, 6, 21}; // day date month year rtn_val = rtc.set_calendar(calendar); @@ -146,6 +146,7 @@ uint8_t p_2 = 0; uint8_t p_3 = 0; uint8_t p_4 = 0; + // uint8_t channel_num= 1; uint8_t channel_num[1]= {1}; uint8_t data_len_1 = 0; uint8_t data_len_2 = 0; @@ -187,13 +188,10 @@ { //t.start(); //ledA = !ledA; - - - - - pc.write((uint8_t *)header_device_id, sizeof(header_device_id)); + pc.write((uint8_t *)header_device_id, sizeof(header_device_id)); // device ID - pc.write((uint8_t *)header_packet_type, sizeof(header_packet_type)); + pc.write((uint8_t *)header_packet_type, sizeof(header_packet_type)); // packet type + epoch_time = rtc.get_epoch(); //time_t seconds = time(NULL); // if remove it the timestamp will be static packet_1 = epoch_time; // @@ -206,8 +204,11 @@ // checksum_ = checksum_ + (packet_1 & 0xffff) + ((packet_1 >> 16) & 0xffff) ; checksum_ = checksum_ + p_1 + p_2 + p_3 + p_4 ; uint8_t header_packet_id[4] = {p_4,p_3,p_2,p_1}; - pc.write((uint8_t *)header_packet_id, sizeof(header_packet_id)); + pc.write((uint8_t *)header_packet_id, sizeof(header_packet_id)); // packet ID + + pc.write((uint8_t *)channel_num, sizeof(channel_num)); + onesec_counter_temp = onesec_counter * 2; data_len_1 = onesec_counter_temp & 0xff; data_len_2 = (onesec_counter_temp >> 8) & 0xff; @@ -215,6 +216,7 @@ //pc.write((uint32_t *)packet_1, sizeof(packet_1)); uint8_t header_ecg_datalen[2] = {data_len_2,data_len_1}; pc.write((uint8_t *)header_ecg_datalen, sizeof(header_ecg_datalen)); + mod_checksum = checksum_ % 65536 ; cksm_1 = mod_checksum & 0xff; cksm_2 = (mod_checksum >> 8) & 0xff;