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.
Fork of mbed-os-example-ble-LED by
Revision 20:f9f18052df0c, committed 2017-03-08
- Comitter:
- jurica238814
- Date:
- Wed Mar 08 13:51:28 2017 +0000
- Parent:
- 19:41b1396c50d2
- Child:
- 21:837783a9ea32
- Commit message:
- Before UART.
Changed in this revision
| source/main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/source/main.cpp Thu Feb 23 13:07:54 2017 +0000
+++ b/source/main.cpp Wed Mar 08 13:51:28 2017 +0000
@@ -30,12 +30,12 @@
#define LANC_PIN (p3) // Lanc bus pin (to scan for START/STOP bits)
-#define LANC_BIT_DURATION (104) // One LANC bit duration in ms
-#define LANC_MIN_DELAY (5000)
-#define NUMBER_OF_REPETITIONS (1)
+#define LANC_BIT_DURATION (92) // One LANC bit duration in ms
+#define LANC_MIN_DELAY (5)
+#define NUMBER_OF_REPETITIONS (4)
-#define REC_CMD_1 (0x18)
-#define REC_CMD_2 (0x33)
+#define REC_CMD_1 (0xAA)
+#define REC_CMD_2 (0xAA)
#define ZOOM_IN_CMD_4_1 (0x28)
#define ZOOM_IN_CMD_4_2 (0x08)
#define ZOOM_OUT_CMD_4_1 (0x28)
@@ -177,36 +177,37 @@
while(command_counter < NUMBER_OF_REPETITIONS){
- //Arduino's PulseIn function (inline implemetation)
- while (lanc_pin == 0); // Waiting for HIGH
- timer.start();
- while(lanc_pin == 1); // Waiting for LOW
- timer.stop();
- if(timer.read_ms()>LANC_MIN_DELAY){
- break;
+ while(1){
+ //Arduino's PulseIn function (inline implemetation)
+ while (lanc_pin == 0); // Waiting for HIGH
+ timer.start();
+ while(lanc_pin == 1); // Waiting for LOW
+ timer.stop();
+ if(timer.read_us()>LANC_MIN_DELAY){
+ break;
+ }
}
- }
// Program is out of the while loop -> bus is LOW -> START bit of BYTE_0 is here
// Write Byte 0 to the bus
for(int i=0; i<8; i++){
command_pin = (command_1 & (1<<i));
- wait_ms(LANC_BIT_DURATION);
+ wait_us(LANC_BIT_DURATION);
}
// Put LANC bus back to HIGH
command_pin = 0;
// Make sure to be in the stop bit before the Byte 1
- wait_ms(10);
+ wait_us(5);
// Look while lanc bus is HIGH for STOP bit
while(lanc_pin == 1);
- wait_ms(LANC_BIT_DURATION);
+ //wait_us(LANC_BIT_DURATION);
//Write Byte 1 to the bus
for(int i=0; i<8; i++){
command_pin = (command_2 & (1<<i));
- wait_ms(LANC_BIT_DURATION);
+ wait_us(LANC_BIT_DURATION);
}
// Put LANC bus back to HIGH
command_pin = 0;
@@ -217,6 +218,7 @@
* Bytes 2-7 and just waits for next start bit after a long pause to send
* command again
*/
+ }
}
