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: MPU9150_DMP Neon_F303K8 QuaternionMath iSDIO mbed-rtos mbed
Fork of Neon_F303K8 by
main.cpp@4:636bb3f66dcd, 2016-08-05 (annotated)
- Committer:
- yakatano
- Date:
- Fri Aug 05 15:05:20 2016 +0000
- Revision:
- 4:636bb3f66dcd
- Parent:
- 3:5f0d6133d34c
??????
Who changed what in which revision?
| User | Revision | Line number | New contents of line | 
|---|---|---|---|
| yishii | 0:65a0ae5578da | 1 | #include "mbed.h" | 
| yishii | 0:65a0ae5578da | 2 | #include "rtos.h" | 
| yishii | 0:65a0ae5578da | 3 | #include "math.h" | 
| yishii | 0:65a0ae5578da | 4 | #include "iSDIO.h" | 
| yishii | 0:65a0ae5578da | 5 | #include "gpio_defs.h" | 
| yishii | 0:65a0ae5578da | 6 | |
| yishii | 1:73543a1fbe62 | 7 | #ifndef TARGET_NUCLEO_F303K8 | 
| yishii | 1:73543a1fbe62 | 8 | #error This program only supports to run on Nucleo F303K8. | 
| yishii | 1:73543a1fbe62 | 9 | #endif | 
| yishii | 1:73543a1fbe62 | 10 | |
| yishii | 0:65a0ae5578da | 11 | extern void TaskSensor(void const* ); | 
| yishii | 0:65a0ae5578da | 12 | extern void TaskLed(void const* ); | 
| yakatano | 4:636bb3f66dcd | 13 | //extern void TaskFA(void const* ); | 
| yishii | 0:65a0ae5578da | 14 | |
| yakatano | 4:636bb3f66dcd | 15 | //Thread* threadLed = NULL; | 
| yishii | 0:65a0ae5578da | 16 | Thread* threadSensor = NULL; | 
| yakatano | 4:636bb3f66dcd | 17 | //Thread* threadFA = NULL; | 
| yishii | 0:65a0ae5578da | 18 | |
| yishii | 0:65a0ae5578da | 19 | Serial pc(USBTX, USBRX); | 
| yishii | 0:65a0ae5578da | 20 | |
| yakatano | 4:636bb3f66dcd | 21 | |
| yakatano | 4:636bb3f66dcd | 22 | |
| yishii | 0:65a0ae5578da | 23 | int main() { | 
| yishii | 0:65a0ae5578da | 24 | pc.baud(115200); | 
| yishii | 0:65a0ae5578da | 25 | printf("Startup Neon main program\r\n"); | 
| yishii | 0:65a0ae5578da | 26 | |
| yishii | 0:65a0ae5578da | 27 | Thread::wait(500); // 適当な待ち時間 | 
| yishii | 0:65a0ae5578da | 28 | |
| yakatano | 4:636bb3f66dcd | 29 | //threadLed = new Thread(TaskLed, NULL, osPriorityNormal, DEFAULT_STACK_SIZE, NULL ); | 
| yishii | 1:73543a1fbe62 | 30 | threadSensor = new Thread(TaskSensor, NULL, osPriorityNormal, DEFAULT_STACK_SIZE*2, NULL ); // スタックサイズ未検証 | 
| yishii | 1:73543a1fbe62 | 31 | //threadFA = new Thread(TaskFA, NULL, osPriorityNormal, DEFAULT_STACK_SIZE , NULL ); | 
| yishii | 0:65a0ae5578da | 32 | |
| yakatano | 4:636bb3f66dcd | 33 | //pc.attach(pc_rx, Serial::RxIrq); | 
| yakatano | 4:636bb3f66dcd | 34 | char recv[1024]; | 
| yishii | 0:65a0ae5578da | 35 | while(true){ | 
| yakatano | 4:636bb3f66dcd | 36 | if(pc.readable()) | 
| yakatano | 4:636bb3f66dcd | 37 | { | 
| yakatano | 4:636bb3f66dcd | 38 | char ch = pc.getc(); | 
| yakatano | 4:636bb3f66dcd | 39 | //pc.putc('$'); | 
| yakatano | 4:636bb3f66dcd | 40 | //pc.printf("%s\r\n", ch); | 
| yakatano | 4:636bb3f66dcd | 41 | switch(ch){ | 
| yakatano | 4:636bb3f66dcd | 42 | case 'z': | 
| yakatano | 4:636bb3f66dcd | 43 | |
| yakatano | 4:636bb3f66dcd | 44 | sprintf(recv, ""); | 
| yakatano | 4:636bb3f66dcd | 45 | break; | 
| yakatano | 4:636bb3f66dcd | 46 | case 'a': | 
| yakatano | 4:636bb3f66dcd | 47 | if(StatusLED == 1){StatusLED = 0;} | 
| yakatano | 4:636bb3f66dcd | 48 | else{StatusLED = 1;} | 
| yakatano | 4:636bb3f66dcd | 49 | break; | 
| yakatano | 4:636bb3f66dcd | 50 | case '1': | 
| yakatano | 4:636bb3f66dcd | 51 | if(StatusLED == 1){StatusLED = 0;} | 
| yakatano | 4:636bb3f66dcd | 52 | else{StatusLED = 1;} | 
| yakatano | 4:636bb3f66dcd | 53 | break; | 
| yakatano | 4:636bb3f66dcd | 54 | default: | 
| yakatano | 4:636bb3f66dcd | 55 | printf("%c\r\n", ch); | 
| yakatano | 4:636bb3f66dcd | 56 | //sprintf(recv, "%s%c", recv,ch); | 
| yakatano | 4:636bb3f66dcd | 57 | //pc.printf(recv); | 
| yakatano | 4:636bb3f66dcd | 58 | break; | 
| yakatano | 4:636bb3f66dcd | 59 | } | 
| yakatano | 4:636bb3f66dcd | 60 | } | 
| yakatano | 4:636bb3f66dcd | 61 | /* | 
| yishii | 1:73543a1fbe62 | 62 | StatusLED = 1; | 
| yishii | 1:73543a1fbe62 | 63 | Thread::wait(800); | 
| yishii | 1:73543a1fbe62 | 64 | StatusLED = 0; | 
| yishii | 1:73543a1fbe62 | 65 | Thread::wait(800); | 
| yakatano | 4:636bb3f66dcd | 66 | */ | 
| yishii | 0:65a0ae5578da | 67 | } | 
| yishii | 0:65a0ae5578da | 68 | } | 
| yishii | 1:73543a1fbe62 | 69 | 
