Fixed cpplint

This commit is contained in:
lulko 2025-03-03 11:43:03 +03:00
parent c44edc638d
commit aa1a78117b
2 changed files with 41 additions and 40 deletions

View file

@ -1,3 +1,5 @@
#ifndef REG_CAH_H_
#define REG_CAH_H_
#define ADDR_VAR 0x8040000
#define ADDR_VAR_ID ADDR_VAR
#define ADDR_VAR_P (ADDR_VAR + 1)
@ -8,6 +10,9 @@
#define REG_WRITE 0xA0
/* Startup ID device */
#define START_ID 0x00
/* CAN REGISTER ID */
#define REG_ID 0x01
#define REG_BAUDRATE 0x02
@ -25,3 +30,10 @@
#define REG_RESET 0x88
#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_

View file

@ -149,7 +149,7 @@ void setup_id(uint8_t my_id){
/* Чтобы разблокировать флэш память для записи*/
FLASH->KEYR = 0x45670123; // Первый ключ
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_SNB_1 | FLASH_CR_SNB_2; // 6 SECTOR FOR ERASE
FLASH->CR |= FLASH_CR_SER;
@ -161,7 +161,6 @@ void setup_id(uint8_t my_id){
*(volatile uint8_t*)ADDR_VAR_ID = my_id;
FLASH->CR |= FLASH_CR_LOCK;
}
@ -170,7 +169,6 @@ void send_data() {
send_velocity();
send_angle();
send_motor_enabled();
// read_temperature();
digitalWrite(PC11, !digitalRead(PC11));
}
@ -206,11 +204,9 @@ void send_data() {
void listen_can() {
uint8_t reg_id = CAN_inMsg.id;
if (CAN_inMsg.buf[0] == REG_WRITE) {
switch (reg_id)
{
switch (reg_id) {
case REG_ID:
/* setup new id */
setup_id(CAN_inMsg.buf[1]);
@ -227,8 +223,7 @@ void listen_can(){
if (CAN_inMsg.buf[1] == 1) {
motor.enable();
motor_control_inputs.motor_enabled = 1;
}
else{
} else {
motor.disable();
motor_control_inputs.motor_enabled = 0;
}
@ -237,21 +232,16 @@ void listen_can(){
default:
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:
send_id();
break;
default:
break;
}
}
}
@ -314,7 +304,6 @@ void setup(){
HAL_Delay(1000);
while (Can.read(CAN_inMsg)) {
listen_can();
}
}