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: TextLCD mbed-rtos mbed
Fork of Pacemaker by
Revision 18:e0bc54c0dbeb, committed 2014-12-02
- Comitter:
- Jing_Qiu
- Date:
- Tue Dec 02 22:12:44 2014 +0000
- Parent:
- 17:6c44d5317c49
- Commit message:
- updated with fixes from mbed testing
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Tue Dec 02 00:14:53 2014 +0000
+++ b/main.cpp Tue Dec 02 22:12:44 2014 +0000
@@ -23,8 +23,8 @@
#define VRP_h 500
#define VRP_l 150
#define BM(x) (1<<(x))
-#define PULSE_WIDTH_V 200
-#define PULSE_WIDTH_A 100
+#define PULSE_WIDTH_V 10
+#define PULSE_WIDTH_A 10
TextLCD lcd(p15, p16, p17, p18, p19, p20, TextLCD::LCD16x2);
@@ -46,8 +46,8 @@
InterruptIn atrial_int(p21); // double check me
InterruptIn vent_int(p22); // me too
-const int a_pace = 3; //pin 23 a pace output
-const int v_pace = 2; //pin 24 v pace output
+DigitalOut aPace(p23);
+DigitalOut vPace(p24);
bool aSensed = 0; // 0 means that we are expecting Apace or Asense next
DigitalOut led1(LED1); //apace
@@ -57,9 +57,6 @@
void initTimer();
void startTimer();
-void initGPIO_outputs();
-void setGPIO(const int pinName);
-void clearGPIO(const int pinName);
void asense();
void vsense();
@@ -71,9 +68,9 @@
void apace()
{
led1 = 1;
- setGPIO(a_pace);
- wait_us(PULSE_WIDTH_A);
- clearGPIO(a_pace);
+ aPace = 1;
+ wait_ms(PULSE_WIDTH_A);
+ aPace = 0;
led1 = 0;
beat++;
@@ -82,31 +79,12 @@
void vpace()
{
led2= 1;
- setGPIO(v_pace);
- wait_us(PULSE_WIDTH_V);
- clearGPIO(v_pace);
+ vPace = 1;
+ wait_ms(PULSE_WIDTH_V);
+ vPace = 0;
led2 = 0;
}
-void initGPIO_outputs()
-{
- LPC_SC->PCONP |= 1<<15;
- LPC_GPIO2->FIODIR |= 1<<5;
- LPC_GPIO2->FIODIR |= 1<<3;
- LPC_GPIO2->FIODIR &= ~(1<<1);
- LPC_GPIO2->FIODIR &= ~(1<<2);
-}
-
-void setGPIO(const int pinName)
-{
- LPC_GPIO2->FIOPIN |= (1<<pinName);
-}
-
-void clearGPIO(const int pinName)
-{
- LPC_GPIO2->FIOPIN &= ~(1<<pinName);
-}
-
void initTimer()
{
// set up OS timer (timer0)
@@ -152,6 +130,8 @@
aSensed = 0;
}
led3 = 1;
+ wait_ms(PULSE_WIDTH_A);
+ led3 = 0;
}
@@ -162,6 +142,8 @@
beat++;
}
led4 = 1;
+ wait_ms(PULSE_WIDTH_V);
+ led4 = 0;
}
void button_handler(void const *args)
@@ -222,7 +204,6 @@
void pacemaker_thread_handler(void const *args)
{
- initGPIO_outputs();
/**********************************************************
************Initialize timer to interrupt every 1 ms*********
@@ -231,8 +212,6 @@
initTimer();
startTimer();
- atrial_int.rise(&asense);
- vent_int.rise(&vsense);
while(1){}
}
@@ -280,7 +259,8 @@
int main (void) {
//TODO set parameters
-
+ atrial_int.rise(&asense);
+ vent_int.rise(&vsense);
Thread display(display_thread_handler);
Thread keyboard(button_handler);
