![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Memory pools
Dependencies: ELEC350-Practicals-FZ429
Fork of Task632-mbedos54 by
Diff: main.cpp
- Revision:
- 12:087a7d135bf4
- Parent:
- 11:6cfaf7dfecb9
--- a/main.cpp Mon Apr 03 14:16:17 2017 +0000 +++ b/main.cpp Tue Nov 14 15:36:59 2017 +0000 @@ -2,6 +2,7 @@ #include "string.h" #include <stdio.h> #include <ctype.h> +#include "sample_hardware.hpp" #define SWITCH1_RELEASE 1 @@ -9,22 +10,9 @@ void thread2(); void switchISR(); -//Analogue inputs -AnalogIn adcIn(A0); - -//Digital outputs -DigitalOut onBoardLED(LED1); -DigitalOut redLED(D7); -DigitalOut yellowLED(D6); -DigitalOut greenLED(D5); - -//Digital inputs -DigitalIn onBoardSwitch(USER_BUTTON); -DigitalIn sw1(D4); //CONSIDER CHANGING THIS TO AN INTERRUPT -DigitalIn sw2(D3); //Threads -Thread *t1; +Thread t1; //Class type class message_t { @@ -53,8 +41,8 @@ //Read sample - make a copy float sample = adcIn; //Grab switch state - uint32_t switch1State = sw1; - uint32_t switch2State = sw2; + uint32_t switch1State = SW1; + uint32_t switch2State = SW2; //Allocate a block from the memory pool message_t *message = mpool.alloc(); @@ -121,8 +109,7 @@ timer.attach(&adcISR, 0.1); //Threads - t1 = new Thread(); - t1->start(thread1); + t1.start(thread1); printf("Main Thread\n"); while (true) { @@ -130,5 +117,3 @@ puts("Main Thread Alive"); } } - -