Fixed cpplint
This commit is contained in:
parent
c44edc638d
commit
aa1a78117b
2 changed files with 41 additions and 40 deletions
|
@ -1,3 +1,5 @@
|
||||||
|
#ifndef REG_CAH_H_
|
||||||
|
#define REG_CAH_H_
|
||||||
#define ADDR_VAR 0x8040000
|
#define ADDR_VAR 0x8040000
|
||||||
#define ADDR_VAR_ID ADDR_VAR
|
#define ADDR_VAR_ID ADDR_VAR
|
||||||
#define ADDR_VAR_P (ADDR_VAR + 1)
|
#define ADDR_VAR_P (ADDR_VAR + 1)
|
||||||
|
@ -8,6 +10,9 @@
|
||||||
#define REG_WRITE 0xA0
|
#define REG_WRITE 0xA0
|
||||||
|
|
||||||
|
|
||||||
|
/* Startup ID device */
|
||||||
|
#define START_ID 0x00
|
||||||
|
|
||||||
/* CAN REGISTER ID */
|
/* CAN REGISTER ID */
|
||||||
#define REG_ID 0x01
|
#define REG_ID 0x01
|
||||||
#define REG_BAUDRATE 0x02
|
#define REG_BAUDRATE 0x02
|
||||||
|
@ -25,3 +30,10 @@
|
||||||
|
|
||||||
#define REG_RESET 0x88
|
#define REG_RESET 0x88
|
||||||
#define REG_LED_BLINK 0x8B
|
#define REG_LED_BLINK 0x8B
|
||||||
|
|
||||||
|
#define FOC_STATE 0x60
|
||||||
|
|
||||||
|
#define MOTOR_VELOCITY 0x70
|
||||||
|
#define MOTOR_ENABLED 0x71
|
||||||
|
#define MOTOR_ANGLE 0x72
|
||||||
|
#endif // REG_CAH_H_
|
||||||
|
|
|
@ -149,7 +149,7 @@ void setup_id(uint8_t my_id){
|
||||||
/* Чтобы разблокировать флэш память для записи*/
|
/* Чтобы разблокировать флэш память для записи*/
|
||||||
FLASH->KEYR = 0x45670123; // Первый ключ
|
FLASH->KEYR = 0x45670123; // Первый ключ
|
||||||
FLASH->KEYR = 0xCDEF89AB; // Второй ключ
|
FLASH->KEYR = 0xCDEF89AB; // Второй ключ
|
||||||
while (FLASH->SR & FLASH_SR_BSY);
|
while (FLASH->SR & FLASH_SR_BSY) { }
|
||||||
FLASH->CR &= ~FLASH_CR_PSIZE_0 & ~FLASH_CR_PSIZE_1; // Data write = 8bit
|
FLASH->CR &= ~FLASH_CR_PSIZE_0 & ~FLASH_CR_PSIZE_1; // Data write = 8bit
|
||||||
FLASH->CR |= FLASH_CR_SNB_1 | FLASH_CR_SNB_2; // 6 SECTOR FOR ERASE
|
FLASH->CR |= FLASH_CR_SNB_1 | FLASH_CR_SNB_2; // 6 SECTOR FOR ERASE
|
||||||
FLASH->CR |= FLASH_CR_SER;
|
FLASH->CR |= FLASH_CR_SER;
|
||||||
|
@ -161,7 +161,6 @@ void setup_id(uint8_t my_id){
|
||||||
*(volatile uint8_t*)ADDR_VAR_ID = my_id;
|
*(volatile uint8_t*)ADDR_VAR_ID = my_id;
|
||||||
|
|
||||||
FLASH->CR |= FLASH_CR_LOCK;
|
FLASH->CR |= FLASH_CR_LOCK;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -170,7 +169,6 @@ void send_data() {
|
||||||
send_velocity();
|
send_velocity();
|
||||||
send_angle();
|
send_angle();
|
||||||
send_motor_enabled();
|
send_motor_enabled();
|
||||||
|
|
||||||
// read_temperature();
|
// read_temperature();
|
||||||
digitalWrite(PC11, !digitalRead(PC11));
|
digitalWrite(PC11, !digitalRead(PC11));
|
||||||
}
|
}
|
||||||
|
@ -206,11 +204,9 @@ void send_data() {
|
||||||
|
|
||||||
|
|
||||||
void listen_can() {
|
void listen_can() {
|
||||||
|
|
||||||
uint8_t reg_id = CAN_inMsg.id;
|
uint8_t reg_id = CAN_inMsg.id;
|
||||||
if (CAN_inMsg.buf[0] == REG_WRITE) {
|
if (CAN_inMsg.buf[0] == REG_WRITE) {
|
||||||
switch (reg_id)
|
switch (reg_id) {
|
||||||
{
|
|
||||||
case REG_ID:
|
case REG_ID:
|
||||||
/* setup new id */
|
/* setup new id */
|
||||||
setup_id(CAN_inMsg.buf[1]);
|
setup_id(CAN_inMsg.buf[1]);
|
||||||
|
@ -227,8 +223,7 @@ void listen_can(){
|
||||||
if (CAN_inMsg.buf[1] == 1) {
|
if (CAN_inMsg.buf[1] == 1) {
|
||||||
motor.enable();
|
motor.enable();
|
||||||
motor_control_inputs.motor_enabled = 1;
|
motor_control_inputs.motor_enabled = 1;
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
motor.disable();
|
motor.disable();
|
||||||
motor_control_inputs.motor_enabled = 0;
|
motor_control_inputs.motor_enabled = 0;
|
||||||
}
|
}
|
||||||
|
@ -237,21 +232,16 @@ void listen_can(){
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
} else if (CAN_inMsg.buf[0] == REG_READ) {
|
||||||
|
switch (reg_id) {
|
||||||
else if(CAN_inMsg.buf[0] == REG_READ){
|
|
||||||
switch (reg_id)
|
|
||||||
{
|
|
||||||
case REG_ID:
|
case REG_ID:
|
||||||
send_id();
|
send_id();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -314,7 +304,6 @@ void setup(){
|
||||||
HAL_Delay(1000);
|
HAL_Delay(1000);
|
||||||
while (Can.read(CAN_inMsg)) {
|
while (Can.read(CAN_inMsg)) {
|
||||||
listen_can();
|
listen_can();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue