GR_Peach_Abhinav_Rahul
/
pwm_send_fpga
For communication between GR Peach and FPGA using PWM.
Revision 1:769aa85d78de, committed 2016-12-03
- Comitter:
- akverma
- Date:
- Sat Dec 03 07:39:39 2016 +0000
- Parent:
- 0:46fb3f8071e7
- Commit message:
- Updated for checking.
Changed in this revision
backup/main_backup.cpp | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 46fb3f8071e7 -r 769aa85d78de backup/main_backup.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/backup/main_backup.cpp Sat Dec 03 07:39:39 2016 +0000 @@ -0,0 +1,76 @@ + + +#include "mbed.h" +#include "rtos.h" + +DigitalOut led1(P8_13); +DigitalOut led2(LED2); +DigitalOut led3(LED3); +DigitalOut dataOutFPGA(P8_11); + +uint8_t data[3]; +const int factor = 100; + +/*void send_fpga_thread ()//void const *args) +{ + led1 = 1; + wait_us((data[0]+1)*1000); + led1 = 0; + wait_us((255-data[0])*1000); + led1 = 1; + wait_us((data[1]+1)*1000); + led1 = 0; + wait_us((255-data[1])*1000); + led1 = 1; + wait_us((data[2]+1)*1000); + led1 = 0; + wait_us((255-data[2])*1000); +}*/ + +/*void send_fpga_thread ()//void const *args) +{ + led1 = 1; + wait_us((data[0]+1)); + led1 = 0; + wait_us((255-data[0])); + led1 = 1; + wait_us((data[1]+1)); + led1 = 0; + wait_us((255-data[1])); + led1 = 1; + wait_us((data[2]+1)); + led1 = 0; + wait_us((255-data[2])); +}*/ + +void send_fpga_thread ()//void const *args) +{ + led1 = 1; + wait_us(factor*(data[0]+1)); + led1 = 0; + wait_us(factor*(255-data[0])); + led1 = 1; + wait_us(factor*(data[1]+1)); + led1 = 0; + wait_us(factor*(255-data[1])); + led1 = 1; + wait_us(factor*(data[2]+1)); + led1 = 0; + wait_us(factor*(255-data[2])); +} + +int main() { + led1=0; + data[0] = 0x44; + data[1] = 0x82; + data[2] = 0xC1; + wait(3); + //Thread thread(blink_thread); + //Thread thread(send_fpga_thread); + send_fpga_thread(); + while (true) + { + led2=!led2; + wait_ms(100); + } +}
diff -r 46fb3f8071e7 -r 769aa85d78de main.cpp --- a/main.cpp Sat Dec 03 07:35:23 2016 +0000 +++ b/main.cpp Sat Dec 03 07:39:39 2016 +0000 @@ -1,3 +1,5 @@ +//I am adding this comment to ust see the changes in repository. + #include "mbed.h" #include "rtos.h"