Skip to content

Commit

Permalink
fix CI check errors
Browse files Browse the repository at this point in the history
  • Loading branch information
firas-hamdi committed Mar 19, 2024
1 parent 438debe commit 52360c7
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 30 deletions.
49 changes: 26 additions & 23 deletions drivers/at6561/at6561.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@
/**
* @ingroup drivers_at6561
*
* @{
* @file
* @brief Driver for AT6561 CAN transceiver
*
* @author Firas Hamdi <[email protected]>
*
* @}
*/

#include "can/can_trx.h"
Expand All @@ -25,38 +28,38 @@ static int _init(can_trx_t *can_trx);
static int _set_mode(can_trx_t *can_trx, can_trx_mode_t mode);

const trx_driver_t at6561_driver = {
.init = _init,
.set_mode = _set_mode,
.init = _init,
.set_mode = _set_mode,
};

static int _init(can_trx_t *can_trx)
{
at6561_trx_t *dev = container_of(can_trx, at6561_trx_t, trx);
at6561_trx_t *dev = container_of(can_trx, at6561_trx_t, trx);

gpio_init(dev->stby_pin, GPIO_OUT);
/* A high level on the standby pin of the CAN transceiver will
select the standby mode. Check AT6560/1 datasheet, table 1-1 */
gpio_set(dev->stby_pin);
gpio_init(dev->stby_pin, GPIO_OUT);
/* A high level on the standby pin of the CAN transceiver will
select the standby mode. Check AT6560/1 datasheet, table 1-1 */
gpio_set(dev->stby_pin);

return 1;
return 1;
}

/* Set the mode of the CAN transceiver */
static int _set_mode(can_trx_t *can_trx, can_trx_mode_t mode)
{
at6561_trx_t *dev = container_of(can_trx, at6561_trx_t, trx);

/* Check AT6560/1 datasheet, table 1-1 */
switch (mode) {
case TRX_NORMAL_MODE:
gpio_clear(dev->stby_pin);
break;
case TRX_SLEEP_MODE:
gpio_set(dev->stby_pin);
break;
default:
assert(0);
}

return 1;
at6561_trx_t *dev = container_of(can_trx, at6561_trx_t, trx);

/* Check AT6560/1 datasheet, table 1-1 */
switch (mode) {
case TRX_NORMAL_MODE:
gpio_clear(dev->stby_pin);
break;
case TRX_SLEEP_MODE:
gpio_set(dev->stby_pin);
break;
default:
assert(0);
}

return 1;
}
30 changes: 23 additions & 7 deletions drivers/include/at6561.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,40 @@
/**
* @ingroup drivers_at6561
*
* @file
* @brief Driver for AT6561 CAN transceiver
* @{
*
* @file
*
* @author Firas Hamdi <[email protected]>
*/

#ifndef AT6561_H
#define AT6561_H

#include "periph/gpio.h"
#include "can/can_trx.h"

#ifdef __cplusplus
extern "C" {
#endif

/**
* @brief AT6561 CAN transceiver descriptor
*/
typedef struct at6561_trx {
/* AT6561 standby pin */
gpio_t stby_pin;
/* AT6561 interface */
can_trx_t trx;
gpio_t stby_pin; /**< AT6561 standby pin */
can_trx_t trx; /**< AT6561 interface */
} at6561_trx_t;

/* AT6561 driver */
extern const trx_driver_t at6561_driver;
/**
* @brief AT6561 driver
*/
extern const trx_driver_t at6561_driver;

#ifdef __cplusplus
}
#endif

#endif /* AT6561_H */
/** @} */

0 comments on commit 52360c7

Please sign in to comment.