Skip to content

Commit

Permalink
app: document the internal API
Browse files Browse the repository at this point in the history
Document the internal API of the CANnectivity firmware.

Signed-off-by: Henrik Brix Andersen <[email protected]>
  • Loading branch information
henrikbrixandersen committed Aug 29, 2024
1 parent f71bb79 commit 1b598d4
Showing 1 changed file with 88 additions and 0 deletions.
88 changes: 88 additions & 0 deletions app/src/cannectivity.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,122 @@
#include <zephyr/devicetree.h>
#include <cannectivity/usb/class/gs_usb.h>

/**
* @brief The CANnectivity devicetree hardware configuration node identifier
*/
#define CANNECTIVITY_DT_NODE_ID DT_NODELABEL(cannectivity)

/**
* @brief True if one or more CANnectivity channels are present in the devicetree, false otherwise
*/
#define CANNECTIVITY_DT_HAS_CHANNEL DT_HAS_COMPAT_STATUS_OKAY(cannectivity_channel)

/**
* @brief Invokes @p fn for each CANnectivity devicetree channel node with a separator
*
* The macro @p fn must take one parameter, which will be the node identifier of a CANnectivity
* channel node.
*
* @param fn The macro to invoke.
* @param sep Separator (e.g. comma or semicolon). Must be in parentheses;
* this is required to enable providing a comma as separator.
*/
#define CANNECTIVITY_DT_FOREACH_CHANNEL_SEP(fn, sep) \
DT_FOREACH_CHILD_STATUS_OKAY_SEP(CANNECTIVITY_DT_NODE_ID, fn, sep)

/**
* @brief CANnectivity CAN channel LED identify callback
*
* @param dev Pointer to the device structure for the driver instance.
* @param ch CAN channel number.
* @param identify True if the channel identify is active, false otherwise.
* @param user_data User data provided when registering the callback.
* @return 0 on success, negative error number otherwise.
*/
int cannectivity_led_identify(const struct device *dev, uint16_t ch, bool identify,
void *user_data);

/**
* @brief CANnectivity CAN channel LED state callback
*
* @param dev Pointer to the device structure for the driver instance.
* @param ch CAN channel number.
* @param started True if the channel is started, false otherwise.
* @param user_data User data provided when registering the callback.
* @return 0 on success, negative error number otherwise.
*/
int cannectivity_led_state(const struct device *dev, uint16_t ch, bool started, void *user_data);

/**
* @brief CANnectivity CAN channel LED activity callback
*
* @param dev Pointer to the device structure for the driver instance.
* @param ch CAN channel number.
* @param user_data User data provided when registering the callback.
* @return 0 on success, negative error number otherwise.
*/
int cannectivity_led_activity(const struct device *dev, uint16_t ch, void *user_data);

/**
* @brief CANnectivity LED initialization function
*
* @return 0 on success, negative error number otherwise.
*/
int cannectivity_led_init(void);

/**
* @brief CANnectivity CAN channel set CAN bus termination callback
*
* @param dev Pointer to the device structure for the driver instance.
* @param ch CAN channel number.
* @param terminate True if the channel termination is active, false otherwise.
* @param user_data User data provided when registering the callback.
* @return 0 on success, negative error number otherwise.
*/
int cannectivity_set_termination(const struct device *dev, uint16_t ch, bool terminate,
void *user_data);

/**
* @brief CANnectivity CAN channel get CAN bus termination callback
*
* @param dev Pointer to the device structure for the driver instance.
* @param ch CAN channel number.
* @param[out] terminated True if the channel termination is active, false otherwise.
* @param user_data User data provided when registering the callback.
* @return 0 on success, negative error number otherwise.
*/
int cannectivity_get_termination(const struct device *dev, uint16_t ch, bool *terminated,
void *user_data);

/**
* @brief CANnectivity CAN bus termination initialization function
*
* @return 0 on success, negative error number otherwise.
*/
int cannectivity_termination_init(void);

/**
* @brief CANnectivity get hardware timestamp callback
*
* @param dev Pointer to the device structure for the driver instance.
* @param[out] timestamp Current timestamp value.
* @param user_data User data provided when registering the callback.
* @return 0 on success, negative error number otherwise.
*/
int cannectivity_timestamp_get(const struct device *dev, uint32_t *timestamp, void *user_data);

/**
* @brief CANnectivity hardware timestamp initialization function
*
* @return 0 on success, negative error number otherwise.
*/
int cannectivity_timestamp_init(void);

/**
* @brief CANnectivity USB device initialization function
*
* @return 0 on success, negative error number otherwise.
*/
int cannectivity_usb_init(void);

#endif /* CANNECTIVITY_APP_CANNECTIVITY_H_ */

0 comments on commit 1b598d4

Please sign in to comment.