Skip to content

Commit 30565cb

Browse files
committed
Revert "Coding style"
This reverts commit 32b801b.
1 parent 02653ad commit 30565cb

File tree

1 file changed

+33
-16
lines changed

1 file changed

+33
-16
lines changed

targets/TARGET_STM/can_api.c

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ static CAN_HandleTypeDef CanHandle;
2929
static uint32_t can_irq_ids[CAN_NUM] = {0};
3030
static can_irq_handler irq_handler;
3131

32-
void can_init(can_t *obj, PinName rd, PinName td) {
32+
void can_init(can_t *obj, PinName rd, PinName td)
33+
{
3334
CANName can_rd = (CANName)pinmap_peripheral(rd, PinMap_CAN_RD);
3435
CANName can_td = (CANName)pinmap_peripheral(td, PinMap_CAN_TD);
3536

@@ -85,20 +86,23 @@ void can_init(can_t *obj, PinName rd, PinName td) {
8586
can_filter(obj, 0, 0, CANStandard, filter_number);
8687
}
8788

88-
void can_irq_init(can_t *obj, can_irq_handler handler, uint32_t id) {
89+
void can_irq_init(can_t *obj, can_irq_handler handler, uint32_t id)
90+
{
8991
irq_handler = handler;
9092
can_irq_ids[obj->index] = id;
9193
}
9294

93-
void can_irq_free(can_t *obj) {
95+
void can_irq_free(can_t *obj)
96+
{
9497
CAN_TypeDef *can = (CAN_TypeDef *)(obj->can);
9598

9699
can->IER &= ~(CAN_IT_FMP0 | CAN_IT_FMP1 | CAN_IT_TME | \
97100
CAN_IT_ERR | CAN_IT_EPV | CAN_IT_BOF);
98101
can_irq_ids[obj->can] = 0;
99102
}
100103

101-
void can_free(can_t *obj) {
104+
void can_free(can_t *obj)
105+
{
102106
// Reset CAN and disable clock
103107
if (obj->can == CAN_1) {
104108
__HAL_RCC_CAN1_FORCE_RESET();
@@ -144,7 +148,8 @@ static const int timing_pts[23][2] = {
144148
{0xF, 0x7}, // 24, 67%
145149
};
146150

147-
static unsigned int can_speed(unsigned int pclk, unsigned int cclk, unsigned char psjw) {
151+
static unsigned int can_speed(unsigned int pclk, unsigned int cclk, unsigned char psjw)
152+
{
148153
uint32_t btr;
149154
uint16_t brp = 0;
150155
uint32_t calcbit;
@@ -179,7 +184,8 @@ static unsigned int can_speed(unsigned int pclk, unsigned int cclk, unsigned cha
179184

180185
}
181186

182-
int can_frequency(can_t *obj, int f) {
187+
int can_frequency(can_t *obj, int f)
188+
{
183189
int pclk = HAL_RCC_GetPCLK1Freq();
184190
int btr = can_speed(pclk, (unsigned int)f, 1);
185191
CAN_TypeDef *can = (CAN_TypeDef *)(obj->can);
@@ -198,7 +204,8 @@ int can_frequency(can_t *obj, int f) {
198204
}
199205
}
200206

201-
int can_write(can_t *obj, CAN_Message msg, int cc) {
207+
int can_write(can_t *obj, CAN_Message msg, int cc)
208+
{
202209
uint32_t transmitmailbox = 5;
203210
CAN_TypeDef *can = (CAN_TypeDef *)(obj->can);
204211

@@ -241,7 +248,8 @@ int can_write(can_t *obj, CAN_Message msg, int cc) {
241248
return 1;
242249
}
243250

244-
int can_read(can_t *obj, CAN_Message *msg, int handle) {
251+
int can_read(can_t *obj, CAN_Message *msg, int handle)
252+
{
245253
//handle is the FIFO number
246254

247255
CAN_TypeDef *can = (CAN_TypeDef *)(obj->can);
@@ -287,23 +295,27 @@ int can_read(can_t *obj, CAN_Message *msg, int handle) {
287295
return 1;
288296
}
289297

290-
void can_reset(can_t *obj) {
298+
void can_reset(can_t *obj)
299+
{
291300
CAN_TypeDef *can = (CAN_TypeDef *)(obj->can);
292301
can->MCR |= CAN_MCR_RESET;
293302
can->ESR = 0x0;
294303
}
295304

296-
unsigned char can_rderror(can_t *obj) {
305+
unsigned char can_rderror(can_t *obj)
306+
{
297307
CAN_TypeDef *can = (CAN_TypeDef *)(obj->can);
298308
return (can->ESR >> 24) & 0xFF;
299309
}
300310

301-
unsigned char can_tderror(can_t *obj) {
311+
unsigned char can_tderror(can_t *obj)
312+
{
302313
CAN_TypeDef *can = (CAN_TypeDef *)(obj->can);
303314
return (can->ESR >> 16) & 0xFF;
304315
}
305316

306-
void can_monitor(can_t *obj, int silent) {
317+
void can_monitor(can_t *obj, int silent)
318+
{
307319
CAN_TypeDef *can = (CAN_TypeDef *)(obj->can);
308320

309321
can->MCR |= CAN_MCR_INRQ ;
@@ -321,7 +333,8 @@ void can_monitor(can_t *obj, int silent) {
321333
}
322334
}
323335

324-
int can_mode(can_t *obj, CanMode mode) {
336+
int can_mode(can_t *obj, CanMode mode)
337+
{
325338
int success = 0;
326339
CAN_TypeDef *can = (CAN_TypeDef *)(obj->can);
327340

@@ -361,7 +374,8 @@ int can_mode(can_t *obj, CanMode mode) {
361374
return success;
362375
}
363376

364-
int can_filter(can_t *obj, uint32_t id, uint32_t mask, CANFormat format, int32_t handle) {
377+
int can_filter(can_t *obj, uint32_t id, uint32_t mask, CANFormat format, int32_t handle)
378+
{
365379
int retval = 0;
366380

367381
// filter for CANAny format cannot be configured for STM32
@@ -394,7 +408,8 @@ int can_filter(can_t *obj, uint32_t id, uint32_t mask, CANFormat format, int32_t
394408
return retval;
395409
}
396410

397-
static void can_irq(CANName name, int id) {
411+
static void can_irq(CANName name, int id)
412+
{
398413
uint32_t tmp1 = 0, tmp2 = 0, tmp3 = 0;
399414
CanHandle.Instance = (CAN_TypeDef *)name;
400415

@@ -481,7 +496,8 @@ void CAN2_SCE_IRQHandler(void) {
481496
#endif // defined(CAN2_BASE) && (CAN_NUM == 2)
482497
#endif // else
483498

484-
void can_irq_set(can_t *obj, CanIrqType type, uint32_t enable) {
499+
void can_irq_set(can_t *obj, CanIrqType type, uint32_t enable)
500+
{
485501

486502
CAN_TypeDef *can = (CAN_TypeDef *)(obj->can);
487503
IRQn_Type irq_n = (IRQn_Type)0;
@@ -567,3 +583,4 @@ void can_irq_set(can_t *obj, CanIrqType type, uint32_t enable) {
567583
}
568584

569585
#endif // DEVICE_CAN
586+

0 commit comments

Comments
 (0)