-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
438debe
commit 52360c7
Showing
2 changed files
with
49 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,10 +9,13 @@ | |
/** | ||
* @ingroup drivers_at6561 | ||
* | ||
* @{ | ||
* @file | ||
* @brief Driver for AT6561 CAN transceiver | ||
* | ||
* @author Firas Hamdi <[email protected]> | ||
* | ||
* @} | ||
*/ | ||
|
||
#include "can/can_trx.h" | ||
|
@@ -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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 */ | ||
/** @} */ |