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: mbed-dev-f303 FastPWM3
Revision 55:081470dee393, committed 2020-01-02
- Comitter:
- monkey61
- Date:
- Thu Jan 02 09:11:07 2020 +0000
- Branch:
- Cheetah_noflash
- Parent:
- 54:59575833d16f
- Commit message:
- test
Changed in this revision
| PositionSensor/PositionSensor.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 |
--- a/PositionSensor/PositionSensor.cpp Thu Aug 08 17:39:43 2019 +0000
+++ b/PositionSensor/PositionSensor.cpp Thu Jan 02 09:11:07 2020 +0000
@@ -30,7 +30,9 @@
//raw = spi->write(readAngleCmd);
//raw &= 0x3FFF;
raw = spi->write(0);
- raw = raw>>2; //Extract last 14 bits
+ //raw = raw>>2; //Extract last 14 bits
+ raw &= 0x7FFF;
+ raw = raw>>1;
GPIOA->ODR |= (1 << 15);
int off_1 = offset_lut[raw>>7];
int off_2 = offset_lut[((raw>>7)+1)%128];
--- a/main.cpp Thu Aug 08 17:39:43 2019 +0000
+++ b/main.cpp Thu Jan 02 09:11:07 2020 +0000
@@ -101,7 +101,13 @@
wait_us(10);
printf(" z - Set Zero Position\n\r");
wait_us(10);
- printf(" esc - Exit to Menu\n\r");
+ printf(" p - Print flash data\n\r");
+ wait_us(10);
+ printf(" o - Write flash data\n\r");
+ wait_us(10);
+ printf(" i - Read flash data\n\r");
+ wait_us(10);
+ printf(" q - Exit to Menu\n\r");
wait_us(10);
state_change = 0;
gpio.led->write(0);
@@ -150,7 +156,7 @@
calibrate(&spi, &gpio, &controller, &prefs); // Perform calibration procedure
gpio.led->write(0);; // Turn off status LED
wait(.2);
- printf("\n\r Calibration complete. Press 'esc' to return to menu\n\r");
+ printf("\n\r Calibration complete. Press 'q' to return to menu\n\r");
drv.disable_gd();
//gpio.enable->write(0);
state_change = 0;
@@ -253,7 +259,8 @@
void serial_interrupt(void){
while(pc.readable()){
char c = pc.getc();
- if(c == 27){
+ //if(c == 27){
+ if(c == 'q'){
state = REST_MODE;
state_change = 1;
char_count = 0;
@@ -279,6 +286,24 @@
state = SETUP_MODE;
state_change = 1;
break;
+ case 'p':
+ printf("__int_reg\r\n");
+ for(int i = 0; i<=132; i++){printf("i:%d,int:%d\n\r", i,__int_reg[i]);}
+ printf("__float_reg\r\n");
+ for(int i = 0; i<=9; i++){printf("i:%d,float:%0.5f\n\r", i,__float_reg[i]);}
+ printf("Print data over");
+ break;
+ case 'o':
+ if (!prefs.ready()) prefs.open();
+ prefs.flush(); // Write new prefs to flash
+ prefs.close();
+ prefs.load();
+ printf("Write flash data over");
+ break;
+ case 'i':
+ prefs.load();
+ printf("Read flash data over");
+ break;
case 'z':
spi.SetMechOffset(0);
spi.Sample(DT);
@@ -342,7 +367,7 @@
}
else if (state == ENCODER_MODE){
switch (c){
- case 27:
+ case 'q':
state = REST_MODE;
state_change = 1;
break;
@@ -363,8 +388,8 @@
controller.v_bus = V_BUS;
controller.mode = 0;
Init_All_HW(&gpio); // Setup PWM, ADC, GPIO
- wait(.1);
-
+ //wait(.1);
+ wait(1);
gpio.enable->write(1);
wait_us(100);
drv.calibrate();
@@ -435,8 +460,9 @@
printf(" CAN ID: %d\n\r", CAN_ID);
-
-
+
+
+
//printf(" %d\n\r", drv.read_register(DCR));
//wait_us(100);
//printf(" %d\n\r", drv.read_register(CSACR));
@@ -463,6 +489,7 @@
wait(.002);
}
*/
+
}
}