N K
/
analoghalls_part_4
yup
Fork of analoghalls by
main.cpp
- Committer:
- nki
- Date:
- 2015-02-26
- Revision:
- 5:eeb8af99cb6c
- Parent:
- 4:f18f6bc5e1fd
- Child:
- 6:4960629abb90
File content as of revision 5:eeb8af99cb6c:
#include "mbed.h" #include "constants.h" #include "shared.h" #include "util.h" #include "math.h" #include "isr.h" Serial pc(SERIAL_TX, SERIAL_RX); PwmOut pha(_PH_A); PwmOut phb(_PH_B); PwmOut phc(_PH_C); DigitalOut en(_EN); DigitalIn dummy(D5); AnalogIn throttle(_THROTTLE); AnalogIn analoga(_ANALOGA); AnalogIn analogb(_ANALOGB); AnalogIn ia(_IA); AnalogIn ib(_IB); Motor* motor; #ifdef __DEBUG float *fbuffer; int bufidx = 0; int skipidx = 0; #endif #ifdef __USE_THROTTLE Ticker dtc_upd_ticker; Ticker throttle_upd_ticker; Ticker isense_upd_ticker; #endif float throttle_read; float ia_read; float ib_read; int main() { pc.baud(115200); #ifdef __DEBUG pc.printf("%s\n", "Debug mode ON"); #endif en = 1; #ifdef __DEBUG fbuffer = (float*)malloc(DBG_BUF_SZ*sizeof(float)); #endif initTimers(); initPins(); initData(); while(1) { #ifdef __USE_THROTTLE throttle_read = throttle; #endif ia_read = ia; ib_read = ib; isense_update(); pc.printf("%f",motor->current); pc.printf("\n\r"); pos_update(); #ifndef __USE_THROTTLE dtc_update(); #endif #ifdef __DEBUG if (motor->debug_stop) break; #endif } #ifdef __DEBUG for (int i = 0; i < DBG_BUF_SZ; i++) { pc.printf("%f,", fbuffer[i]); } #endif }