/PIC Stuff/PICX_16F1825_Sabertooth/funclist |
---|
1,32 → 1,31 |
___awdiv: CODE, 3925 0 84 |
_LED_2_On: CODE, 3201 0 3 |
_LED_2_Off: CODE, 2045 0 3 |
_I2C1_Init: CODE, 1856 0 91 |
_I2C1_Interrupt_Slave: CODE, 1430 0 426 |
_UART_Read: CODE, 3842 0 83 |
_I2C1_Read_Buffer: CODE, 3608 0 72 |
_I2C1_Master_Restart: CODE, 3680 0 79 |
_UART_Init: CODE, 3431 0 57 |
_main: CODE, 741 0 689 |
_Interrupt_Enable: CODE, 2042 0 3 |
_LED_2_On: CODE, 2041 0 3 |
_LED_2_Off: CODE, 2038 0 3 |
_I2C1_Init: CODE, 1681 0 78 |
_I2C1_Interrupt_Slave: CODE, 677 0 386 |
_UART_Read: CODE, 1598 0 83 |
_I2C1_Read_Buffer: CODE, 1907 0 65 |
_I2C1_Master_Restart: CODE, 1835 0 72 |
_UART_Init: CODE, 4039 0 57 |
_main: CODE, 1063 0 359 |
_Interrupt_Enable: CODE, 2035 0 3 |
_InterruptHandler: CODE, 4 0 29 |
_I2C1_Process_Receive: CODE, 3192 0 3 |
_UART_TX_Interrupt_Handler: CODE, 3488 0 58 |
_PWM_1_Set: CODE, 3311 0 37 |
_Interrupt_Init: CODE, 3 0 1 |
__initialization: CODE, 2037 0 2 |
_Controller_Read: CODE, 4009 0 87 |
_I2C1_Configure_Master: CODE, 3385 0 46 |
_Controller_Init: CODE, 2 0 1 |
_PWM_1_Init: CODE, 3253 0 27 |
_PWM_2_Set: CODE, 3348 0 37 |
_I2C1_Master_Send: CODE, 3759 0 83 |
_I2C1_Interrupt_Handler: CODE, 3227 0 26 |
_UART_RX_Interrupt_Handler: CODE, 1947 0 90 |
_PWM_2_Init: CODE, 3280 0 31 |
_I2C1_Get_Status: CODE, 3546 0 62 |
_LED_1_On: CODE, 3195 0 3 |
_I2C1_Interrupt_Master: CODE, 35 0 706 |
_LED_1_Off: CODE, 3198 0 3 |
_Pins_Init: CODE, 3204 0 23 |
Total: 2945 |
_I2C1_Process_Receive: CODE, 3754 0 3 |
_UART_TX_Interrupt_Handler: CODE, 1972 0 58 |
_PWM_1_Set: CODE, 3865 0 37 |
_Interrupt_Init: CODE, 2047 0 1 |
__initialization: CODE, 2030 0 2 |
_Controller_Read: CODE, 1512 0 86 |
_I2C1_Configure_Master: CODE, 3939 0 45 |
_Controller_Init: CODE, 3 0 1 |
_PWM_1_Init: CODE, 3807 0 27 |
_PWM_2_Set: CODE, 3902 0 37 |
_I2C1_Master_Send: CODE, 1759 0 76 |
_I2C1_Interrupt_Handler: CODE, 3783 0 24 |
_UART_RX_Interrupt_Handler: CODE, 1422 0 90 |
_PWM_2_Init: CODE, 3834 0 31 |
_I2C1_Get_Status: CODE, 3984 0 55 |
_LED_1_On: CODE, 3757 0 3 |
_I2C1_Interrupt_Master: CODE, 35 0 642 |
_LED_1_Off: CODE, 2044 0 3 |
_Pins_Init: CODE, 3760 0 23 |
Total: 2382 |
/PIC Stuff/PICX_16F1825_Sabertooth/l.obj |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/PIC Stuff/PICX_16F1825_Sabertooth/main.c |
---|
116,14 → 116,64 |
uint16_t pwm_left = PWM_NOMINAL; |
uint16_t pwm_right = PWM_NOMINAL; |
uint8_t median; |
int16_t L_X, L_Y, R_X, R_Y; |
#ifdef CONTROL_FROM_UART |
uint8_t buffer[32]; |
uint8_t length; |
uint8_t uart_state = UART_STATE_READ_CMD; |
uint8_t uart_cmd; |
while(1) { |
length = UART_Read(buffer); |
for (uint8_t i = 0; i < length; i++) { |
if (uart_state == UART_STATE_READ_CMD) { |
if (buffer[i] == UART_CMD_RESET) { |
RESET(); |
} else { |
// Read and save first byte (command) |
uart_cmd = buffer[i]; |
uart_state = UART_STATE_READ_DATA; |
} |
} else if (uart_state == UART_STATE_READ_DATA) { |
uart_state = UART_STATE_READ_CMD; |
// Process received data |
if (uart_cmd == UART_CMD_LEFT_FORWARD) { |
pwm_left = PWM_NOMINAL + (uint16_t)(buffer[i] * 2); |
if (buffer[i] != 0) LED_2_On(); |
else LED_2_Off(); |
} else if (uart_cmd == UART_CMD_LEFT_BACKWARD) { |
pwm_left = PWM_NOMINAL - (uint16_t)(buffer[i] * 2); |
if (buffer[i] != 0) LED_2_On(); |
else LED_2_Off(); |
} else if (uart_cmd == UART_CMD_RIGHT_FORWARD) { |
pwm_right = PWM_NOMINAL + (uint16_t)(buffer[i] * 2); |
if (buffer[i] != 0) LED_1_On(); |
else LED_1_Off(); |
} else if (uart_cmd == UART_CMD_RIGHT_BACKWARD) { |
pwm_right = PWM_NOMINAL - (uint16_t)(buffer[i] * 2); |
if (buffer[i] != 0) LED_1_On(); |
else LED_1_Off(); |
} |
if (pwm_left > PWM_MAX) |
pwm_left = PWM_MAX; |
if (pwm_left < PWM_MIN) |
pwm_left = PWM_MIN; |
if (pwm_right > PWM_MAX) |
pwm_right = PWM_MAX; |
if (pwm_right < PWM_MIN) |
pwm_right = PWM_MIN; |
PWM_1_Set(pwm_right); |
PWM_2_Set(pwm_left); |
} |
} |
} |
#endif |
#ifdef CONTROL_FROM_CONTROLLER |
uint8_t median; |
int16_t L_X, L_Y, R_X, R_Y; |
while (1) { |
if (!Controller_Read(&ctrl)) { |
median = ctrl.REF / 2; |
180,56 → 230,7 |
LED_1_Off(); |
LED_2_Off(); |
// If no controller is attached, switch control to UART |
while(1) { |
length = UART_Read(buffer); |
for (uint8_t i = 0; i < length; i++) { |
if (uart_state == UART_STATE_READ_CMD) { |
if (buffer[i] == UART_CMD_RESET) { |
RESET(); |
} else { |
// Read and save first byte (command) |
uart_cmd = buffer[i]; |
uart_state = UART_STATE_READ_DATA; |
} |
} else if (uart_state == UART_STATE_READ_DATA) { |
uart_state = UART_STATE_READ_CMD; |
// Process received data |
if (uart_cmd == UART_CMD_LEFT_FORWARD) { |
pwm_left = PWM_NOMINAL + (uint16_t) (buffer[i] * 2); |
if (buffer[i] != 0) LED_2_On(); |
else LED_2_Off(); |
} else if (uart_cmd == UART_CMD_LEFT_BACKWARD) { |
pwm_left = PWM_NOMINAL - (uint16_t) (buffer[i] * 2); |
if (buffer[i] != 0) LED_2_On(); |
else LED_2_Off(); |
} else if (uart_cmd == UART_CMD_RIGHT_FORWARD) { |
pwm_right = PWM_NOMINAL + (uint16_t) (buffer[i] * 2); |
if (buffer[i] != 0) LED_1_On(); |
else LED_1_Off(); |
} else if (uart_cmd == UART_CMD_RIGHT_BACKWARD) { |
pwm_right = PWM_NOMINAL - (uint16_t) (buffer[i] * 2); |
if (buffer[i] != 0) LED_1_On(); |
else LED_1_Off(); |
} |
if (pwm_left > PWM_MAX) |
pwm_left = PWM_MAX; |
if (pwm_left < PWM_MIN) |
pwm_left = PWM_MIN; |
if (pwm_right > PWM_MAX) |
pwm_right = PWM_MAX; |
if (pwm_right < PWM_MIN) |
pwm_right = PWM_MIN; |
PWM_1_Set(pwm_right); |
PWM_2_Set(pwm_left); |
#endif |
} |
} |
} |
} |
} |
} |
/PIC Stuff/PICX_16F1825_Sabertooth/nbproject/Makefile-genesis.properties |
---|
1,5 → 1,5 |
# |
#Mon Apr 21 17:09:08 EDT 2014 |
#Sun Apr 20 17:21:55 EDT 2014 |
default.languagetoolchain.dir=C\:\\Program Files (x86)\\Microchip\\xc8\\v1.20\\bin |
com-microchip-mplab-nbide-embedded-makeproject-MakeProject.md5=1f98a0eed69cb2a45c12981fa9470927 |
default.languagetoolchain.version=1.20 |