Skip to content

Commit 32b801b

Browse files
committed
Coding style
1 parent eec6e10 commit 32b801b

File tree

1 file changed

+16
-33
lines changed

1 file changed

+16
-33
lines changed

targets/TARGET_STM/can_api.c

Lines changed: 16 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ 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)
33-
{
32+
void can_init(can_t *obj, PinName rd, PinName td) {
3433
CANName can_rd = (CANName)pinmap_peripheral(rd, PinMap_CAN_RD);
3534
CANName can_td = (CANName)pinmap_peripheral(td, PinMap_CAN_TD);
3635

@@ -86,23 +85,20 @@ void can_init(can_t *obj, PinName rd, PinName td)
8685
can_filter(obj, 0, 0, CANStandard, filter_number);
8786
}
8887

89-
void can_irq_init(can_t *obj, can_irq_handler handler, uint32_t id)
90-
{
88+
void can_irq_init(can_t *obj, can_irq_handler handler, uint32_t id) {
9189
irq_handler = handler;
9290
can_irq_ids[obj->index] = id;
9391
}
9492

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

9996
can->IER &= ~(CAN_IT_FMP0 | CAN_IT_FMP1 | CAN_IT_TME | \
10097
CAN_IT_ERR | CAN_IT_EPV | CAN_IT_BOF);
10198
can_irq_ids[obj->can] = 0;
10299
}
103100

104-
void can_free(can_t *obj)
105-
{
101+
void can_free(can_t *obj) {
106102
// Reset CAN and disable clock
107103
if (obj->can == CAN_1) {
108104
__HAL_RCC_CAN1_FORCE_RESET();
@@ -148,8 +144,7 @@ static const int timing_pts[23][2] = {
148144
{0xF, 0x7}, // 24, 67%
149145
};
150146

151-
static unsigned int can_speed(unsigned int pclk, unsigned int cclk, unsigned char psjw)
152-
{
147+
static unsigned int can_speed(unsigned int pclk, unsigned int cclk, unsigned char psjw) {
153148
uint32_t btr;
154149
uint16_t brp = 0;
155150
uint32_t calcbit;
@@ -184,8 +179,7 @@ static unsigned int can_speed(unsigned int pclk, unsigned int cclk, unsigned cha
184179

185180
}
186181

187-
int can_frequency(can_t *obj, int f)
188-
{
182+
int can_frequency(can_t *obj, int f) {
189183
int pclk = HAL_RCC_GetPCLK1Freq();
190184
int btr = can_speed(pclk, (unsigned int)f, 1);
191185
CAN_TypeDef *can = (CAN_TypeDef *)(obj->can);
@@ -204,8 +198,7 @@ int can_frequency(can_t *obj, int f)
204198
}
205199
}
206200

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

@@ -248,8 +241,7 @@ int can_write(can_t *obj, CAN_Message msg, int cc)
248241
return 1;
249242
}
250243

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

255247
CAN_TypeDef *can = (CAN_TypeDef *)(obj->can);
@@ -295,27 +287,23 @@ int can_read(can_t *obj, CAN_Message *msg, int handle)
295287
return 1;
296288
}
297289

298-
void can_reset(can_t *obj)
299-
{
290+
void can_reset(can_t *obj) {
300291
CAN_TypeDef *can = (CAN_TypeDef *)(obj->can);
301292
can->MCR |= CAN_MCR_RESET;
302293
can->ESR = 0x0;
303294
}
304295

305-
unsigned char can_rderror(can_t *obj)
306-
{
296+
unsigned char can_rderror(can_t *obj) {
307297
CAN_TypeDef *can = (CAN_TypeDef *)(obj->can);
308298
return (can->ESR >> 24) & 0xFF;
309299
}
310300

311-
unsigned char can_tderror(can_t *obj)
312-
{
301+
unsigned char can_tderror(can_t *obj) {
313302
CAN_TypeDef *can = (CAN_TypeDef *)(obj->can);
314303
return (can->ESR >> 16) & 0xFF;
315304
}
316305

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

321309
can->MCR |= CAN_MCR_INRQ ;
@@ -333,8 +321,7 @@ void can_monitor(can_t *obj, int silent)
333321
}
334322
}
335323

336-
int can_mode(can_t *obj, CanMode mode)
337-
{
324+
int can_mode(can_t *obj, CanMode mode) {
338325
int success = 0;
339326
CAN_TypeDef *can = (CAN_TypeDef *)(obj->can);
340327

@@ -374,8 +361,7 @@ int can_mode(can_t *obj, CanMode mode)
374361
return success;
375362
}
376363

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

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

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

@@ -496,8 +481,7 @@ void CAN2_SCE_IRQHandler(void) {
496481
#endif // defined(CAN2_BASE) && (CAN_NUM == 2)
497482
#endif // else
498483

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

502486
CAN_TypeDef *can = (CAN_TypeDef *)(obj->can);
503487
IRQn_Type irq_n = (IRQn_Type)0;
@@ -583,4 +567,3 @@ void can_irq_set(can_t *obj, CanIrqType type, uint32_t enable)
583567
}
584568

585569
#endif // DEVICE_CAN
586-

0 commit comments

Comments
 (0)