Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: MAX30003 max32630fthr DS1307
Diff: main.cpp
- Revision:
- 16:520034b124b6
- Parent:
- 15:0356e9454a60
- Child:
- 17:f0008ebb1040
--- a/main.cpp Thu Mar 11 21:22:19 2021 +0000
+++ b/main.cpp Wed Jun 09 17:04:56 2021 +0000
@@ -7,8 +7,8 @@
#include <string>
//#include <Serial.h>
-#define TARGET_TX_PIN P3_1
-#define TARGET_RX_PIN P3_0
+#define TARGET_TX_PIN P0_1
+#define TARGET_RX_PIN P0_0
Timer timer_fast;
Timer t;
@@ -17,6 +17,10 @@
void task_fast(void);
DigitalOut ledA(LED2);
+DigitalOut EN(P1_7);
+DigitalOut A0(P1_4);
+DigitalOut A1(P7_2);
+
void ecg_config(MAX30003 &ecgAFE);
//BufferedSerial pc(P3_1,P3_0); // Use USB debug probe for serial link static Unbuffered
static BufferedSerial pc(TARGET_TX_PIN, TARGET_RX_PIN, 230400); // 230400 works well
@@ -51,6 +55,15 @@
}
int main(void)
{
+ int t=0;
+
+ EN=0;
+ EN=1;
+ A0=0;
+ A1=1;
+
+
+
// Constants
const int EINT_STATUS_MASK = 1 << 23;
const int FIFO_OVF_MASK = 0x7;
@@ -100,7 +113,7 @@
uint8_t p_2 = 0;
uint8_t p_3 = 0;
uint8_t p_4 = 0;
-
+ uint8_t channel_num[1]= {1};
uint8_t data_len_1 = 0;
uint8_t data_len_2 = 0;
uint32_t packet_1 = 0;
@@ -114,24 +127,24 @@
bool flip = true;
int sampleps = 0;
- char buf[20];
+ char buf[20];//={"1622326341"};
// pc.write("Welcome",8*sizeof(char));
// printf("In the main loop"); //printf("In the main loop");
bool flag_first = false;
bool timestamp_reader = false;
- do
- {
- if (pc.readable())
- {
- scanf("%s",buf);
- //printf("The entered string is %s : \n ",buf);
-
- packet_1 = atoi(buf);
+ /* do
+ {
+ if (pc.readable())
+ {
+ scanf("%s",buf);
+ printf("The entered string is %s : \n ",buf);*/
+ // buf[20] = 1621297647;
+ packet_1 = 1623243727; //atoi(buf);
set_time(packet_1);
- if ((packet_1 % 60) == 0)
+ /* if ((packet_1 % 60) == 0)
{
- /* for (int u = 0;u<3;u++)
+ for (int u = 0;u<3;u++)
{
if (pc.readable())
{
@@ -141,19 +154,19 @@
packet_1 = atoi(buf);
set_time(packet_1);
}
- }*/
- timestamp_reader = true;
- }
- else
- {
+ }
+ timestamp_reader = true;
+ }
+ else
+ {
//printf("The timestamp is not divisible by 60 \n");
- }
- //flag_first = true;
+ /* }
+ flag_first = true;
}
- }while (timestamp_reader==false); // take the third timestamp
- while(1)
+ } while (timestamp_reader==false); */ // take the third timestamp
+while(1)
{
@@ -162,12 +175,14 @@
//t.start();
//ledA = !ledA;
-
+
+
+
pc.write((uint8_t *)header_device_id, sizeof(header_device_id));
pc.write((uint8_t *)header_packet_type, sizeof(header_packet_type));
- time_t seconds = time(NULL);
- packet_1 = seconds;
+ time_t seconds = time(NULL); // if remove it the timestamp will be static
+ packet_1 = seconds; //
//packet_1 ++;
// printf("Time as seconds since January 1, 1970 = %d\n", packet_1);
p_1 = packet_1 & 0xff;
@@ -178,6 +193,7 @@
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 *)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;