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 FRDM-TFC by
Diff: main.cpp
- Revision:
- 2:ce4a273be708
- Parent:
- 0:cd9427630ad1
- Child:
- 3:23cce037011f
--- a/main.cpp Wed Jul 17 19:30:14 2013 +0000
+++ b/main.cpp Wed Jul 17 19:31:32 2013 +0000
@@ -1,12 +1,79 @@
#include "mbed.h"
-
+#include "TFC.h"
+
DigitalOut myled(LED1);
-
-int main() {
- while(1) {
- myled = 1;
- wait(0.2);
- myled = 0;
- wait(0.2);
+Ticker TFC_TickerObj;
+Serial PC(USBTX,USBRX);
+
+#define NUM_TFC_TICKERS 4
+
+volatile uint32_t TFC_Ticker[NUM_TFC_TICKERS];
+
+void TFC_TickerUpdate()
+{
+ int i;
+
+ for(i=0; i<NUM_TFC_TICKERS; i++) {
+ if(TFC_Ticker[i]<0xFFFFFFFF) {
+ TFC_Ticker[0]++;
+ }
}
}
+
+
+
+
+int main()
+{
+ // int i;
+
+
+ PC.baud(9600);
+ TFC_TickerObj.attach_us(&TFC_TickerUpdate,1000);
+ __disable_irq();
+
+ TFC_Init();
+ __enable_irq();
+// TFC_Init();
+ while(1)
+ {
+
+ if(TFC_ServoTicker >0)
+ {
+ TFC_ServoTicker = 0;
+
+ TFC_SetBatteryLED(TFC_GetDIP_Switch());
+
+ if(TFC_DIP_SWITCH_0_ON) {
+ if(TFC_PUSH_BUTTON_0_PRESSED)
+ TFC_SetServo(0,0.2);
+ else if(TFC_PUSH_BUTTON_1_PRESSED)
+ TFC_SetServo(0,-0.2);
+ else
+ TFC_SetServo(0,TFC_ReadPot(0));
+ }
+
+
+ if(TFC_DIP_SWITCH_1_ON) {
+ TFC_HBRIDGE_ENABLE;
+ TFC_SetMotorPWM(TFC_ReadPot(1) ,TFC_ReadPot(1));
+ } else {
+ TFC_HBRIDGE_DISABLE;
+ }
+
+
+ }
+
+
+ if(TFC_Ticker[0]>500)
+ {
+ TFC_Ticker[0] = 0;
+ PC.printf("Servo Ticker %i",TFC_ServoTicker);
+ }
+
+
+
+ }
+
+}
+
\ No newline at end of file
