aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/templates
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2009-12-04 20:56:51 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2009-12-04 20:56:51 +0000
commit03a0255b043e9a418e96cf3b3e0564ed2f6efe8e (patch)
tree299c695051e588fb6e7e4f25fc0ad830bc1d7477 /os/hal/templates
parent980f0b675138676b1e977ca456dc73c3b2502596 (diff)
downloadChibiOS-03a0255b043e9a418e96cf3b3e0564ed2f6efe8e.tar.gz
ChibiOS-03a0255b043e9a418e96cf3b3e0564ed2f6efe8e.tar.bz2
ChibiOS-03a0255b043e9a418e96cf3b3e0564ed2f6efe8e.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1374 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/templates')
-rw-r--r--os/hal/templates/can_lld.c29
-rw-r--r--os/hal/templates/can_lld.h74
2 files changed, 72 insertions, 31 deletions
diff --git a/os/hal/templates/can_lld.c b/os/hal/templates/can_lld.c
index f2f54e66d..792c4f888 100644
--- a/os/hal/templates/can_lld.c
+++ b/os/hal/templates/can_lld.c
@@ -63,10 +63,6 @@ void can_lld_init(void) {
*/
void can_lld_start(CANDriver *canp) {
- if (canp->can_state == CAN_STOP) {
- /* Clock activation.*/
- }
- /* Configuration.*/
}
/**
@@ -76,8 +72,13 @@ void can_lld_start(CANDriver *canp) {
*/
void can_lld_stop(CANDriver *canp) {
+ /* If in ready state then disables the CAN peripheral.*/
+ if (canp->cd_state == CAN_READY) {
+
+ }
}
+
/**
* @brief Determines whether a frame can be transmitted.
*
@@ -94,16 +95,12 @@ bool_t can_lld_can_transmit(CANDriver *canp) {
/**
* @brief Inserts a frame into the transmit queue.
- *
- * @param[in] canp pointer to the @p CANDriver object
- * @param[in] cfp pointer to the CAN frame to be transmitted
*
- * @return The operation status.
- * @retval RDY_OK frame transmitted.
+ * @param[in] canp pointer to the @p CANDriver object
+ * @param[in] ctfp pointer to the CAN frame to be transmitted
*/
-msg_t can_lld_transmit(CANDriver *canp, const CANFrame *cfp) {
+void can_lld_transmit(CANDriver *canp, const CANTxFrame *ctfp) {
- return RDY_OK;
}
/**
@@ -122,16 +119,12 @@ bool_t can_lld_can_receive(CANDriver *canp) {
/**
* @brief Receives a frame from the input queue.
- *
- * @param[in] canp pointer to the @p CANDriver object
- * @param[out] cfp pointer to the buffer where the CAN frame is copied
*
- * @return The operation status.
- * @retval RDY_OK frame received.
+ * @param[in] canp pointer to the @p CANDriver object
+ * @param[out] crfp pointer to the buffer where the CAN frame is copied
*/
-msg_t can_lld_receive(CANDriver *canp, CANFrame *cfp) {
+void can_lld_receive(CANDriver *canp, CANRxFrame *crfp) {
- return RDY_OK;
}
#if CAN_USE_SLEEP_MODE || defined(__DOXYGEN__)
diff --git a/os/hal/templates/can_lld.h b/os/hal/templates/can_lld.h
index 14588c0d5..9b1124a18 100644
--- a/os/hal/templates/can_lld.h
+++ b/os/hal/templates/can_lld.h
@@ -29,6 +29,10 @@
#if CH_HAL_USE_CAN || defined(__DOXYGEN__)
+/*===========================================================================*/
+/* Driver constants. */
+/*===========================================================================*/
+
/**
* @brief This switch defines whether the driver implementation supports
* a low power switch mode with automatic an wakeup feature.
@@ -53,10 +57,6 @@
#endif /* !CAN_SUPPORTS_SLEEP */
/*===========================================================================*/
-/* Driver constants. */
-/*===========================================================================*/
-
-/*===========================================================================*/
/* Driver data structures and types. */
/*===========================================================================*/
@@ -66,21 +66,63 @@
typedef uint32_t canstatus_t;
/**
- * @brief CAN frame.
+ * @brief CAN transmission frame.
+ * @note Accessing the frame data as word16 or word32 is not portable because
+ * machine data endianness, it can be still useful for a quick filling.
+ */
+typedef struct {
+ struct {
+ uint8_t cf_DLC:4; /**< @brief Data length. */
+ uint8_t cf_RTR:1; /**< @brief Frame type. */
+ uint8_t cf_IDE:1; /**< @brief Identifier type. */
+ };
+ union {
+ struct {
+ uint32_t cf_SID:11; /**< @brief Standard identifier.*/
+ };
+ struct {
+ uint32_t cf_EID:29; /**< @brief Extended identifier.*/
+ };
+ };
+ union {
+ uint8_t cf_data8[8]; /**< @brief Frame data. */
+ uint16_t cf_data16[4]; /**< @brief Frame data. */
+ uint32_t cf_data32[2]; /**< @brief Frame data. */
+ };
+} CANTxFrame;
+
+/**
+ * @brief CAN received frame.
* @note Accessing the frame data as word16 or word32 is not portable because
- * machine data endianness, it can be still useful for a quick filling.
+ * machine data endianness, it can be still useful for a quick filling.
*/
typedef struct {
- uint8_t cf_DLC:4; /**< @brief Data length. */
- uint8_t cf_IDE:1; /**< @brief Identifier type. */
- uint8_t cf_RTR:1; /**< @brief Frame type. */
- uint32_t cf_id; /**< @brief Frame identifier. */
+ struct {
+ uint8_t cf_DLC:4; /**< @brief Data length. */
+ uint8_t cf_RTR:1; /**< @brief Frame type. */
+ uint8_t cf_IDE:1; /**< @brief Identifier type. */
+ };
+ union {
+ struct {
+ uint32_t cf_SID:11; /**< @brief Standard identifier.*/
+ };
+ struct {
+ uint32_t cf_EID:29; /**< @brief Extended identifier.*/
+ };
+ };
union {
uint8_t cf_data8[8]; /**< @brief Frame data. */
uint16_t cf_data16[4]; /**< @brief Frame data. */
uint32_t cf_data32[2]; /**< @brief Frame data. */
};
-} CANFrame;
+} CANRxFrame;
+
+/**
+ * @brief CAN filter.
+ * @note It could not be present on some architectures.
+ */
+typedef struct {
+} CANFilter;
/**
* @brief Driver configuration structure.
@@ -111,6 +153,12 @@ typedef struct {
Semaphore cd_rxsem;
/**
* @brief One or more frames become available.
+ * @note After broadcasting this event it will not be broadcasted again
+ * until the received frames queue has been completely emptied. It
+ * is <b>not</b> broadcasted for each received frame. It is
+ * responsibility of the application to empty the queue by repeatedly
+ * invoking @p chReceive() when listening to this event. This behavior
+ * minimizes the interrupt served by the system because CAN traffic.
*/
EventSource cd_rxfull_event;
/**
@@ -149,9 +197,9 @@ extern "C" {
void can_lld_start(CANDriver *canp);
void can_lld_stop(CANDriver *canp);
bool_t can_lld_can_transmit(CANDriver *canp);
- msg_t can_lld_transmit(CANDriver *canp, const CANFrame *cfp);
+ void can_lld_transmit(CANDriver *canp, const CANTxFrame *crfp);
bool_t can_lld_can_receive(CANDriver *canp);
- msg_t can_lld_receive(CANDriver *canp, CANFrame *cfp);
+ void can_lld_receive(CANDriver *canp, CANRxFrame *ctfp);
#if CAN_USE_SLEEP_MODE
void can_lld_sleep(CANDriver *canp);
void can_lld_wakeup(CANDriver *canp);