Skip to content

Commit

Permalink
[sw/lib] update SLINK HAL
Browse files Browse the repository at this point in the history
  • Loading branch information
stnolting committed May 21, 2024
1 parent 307b700 commit d04f154
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 4 deletions.
18 changes: 14 additions & 4 deletions sw/lib/include/neorv32_slink.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
/**@{*/
/** SLINK module prototype */
typedef volatile struct __attribute__((packed,aligned(4))) {
uint32_t CTRL; /**< offset 0: control register (#NEORV32_SLINK_CTRL_enum) */
const uint32_t reserved; /**< offset 4: reserved */
uint32_t DATA; /**< offset 8: RX/TX data register */
uint32_t DATA_LAST; /**< offset 12: RX/TX data register (+ TX end-of-stream) */
uint32_t CTRL; /**< offset 0: control register (#NEORV32_SLINK_CTRL_enum) */
uint32_t ROUTE; /**< offset 4: routing information (#NEORV32_SLINK_ROUTE_enum) */
uint32_t DATA; /**< offset 8: RX/TX data register */
uint32_t DATA_LAST; /**< offset 12: RX/TX data register (+ TX end-of-stream) */
} neorv32_slink_t;

/** SLINK module hardware access (#neorv32_slink_t) */
Expand Down Expand Up @@ -59,6 +59,14 @@ enum NEORV32_SLINK_CTRL_enum {
SLINK_CTRL_TX_FIFO_MSB = 31 /**< SLINK control register(31) (r/-): log2(TX FIFO size) MSB */
};

/** ROUTE register bits */
enum NEORV32_SLINK_ROUTE_enum {
SLINK_ROUTE_DST_LSB = 0, /**< SLINK routing register(0) (r/w): Destination routing information LSB */
SLINK_ROUTE_DST_MSB = 3, /**< SLINK routing register(3) (r/w): Destination routing information MSB */
SLINK_ROUTE_SRC_LSB = 4, /**< SLINK routing register(4) (r/-): Source routing information LSB */
SLINK_ROUTE_SRC_MSB = 7 /**< SLINK routing register(7) (r/-): Source routing information MSB */
};

enum NEORV32_SLINK_STATUS_enum {
SLINK_FIFO_EMPTY = 0, /**< FIFO is empty */
SLINK_FIFO_HALF = 1, /**< FIFO is at least half full */
Expand All @@ -79,6 +87,8 @@ int neorv32_slink_get_rx_fifo_depth(void);
int neorv32_slink_get_tx_fifo_depth(void);
uint32_t neorv32_slink_get(void);
uint32_t neorv32_slink_check_last(void);
void neorv32_slink_set_dst(uint32_t dst);
uint32_t neorv32_slink_get_src(void);
void neorv32_slink_put(uint32_t tx_data);
void neorv32_slink_put_last(uint32_t tx_data);
int neorv32_slink_rx_status(void);
Expand Down
25 changes: 25 additions & 0 deletions sw/lib/source/neorv32_slink.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,31 @@ inline uint32_t __attribute__((always_inline)) neorv32_slink_check_last(void) {
}


/**********************************************************************//**
* Set TX link routing destination
*
* @param[in] dst Routing destination ID (4-bit, LSB-aligned).
**************************************************************************/
inline void __attribute__((always_inline)) neorv32_slink_set_dst(uint32_t dst) {

NEORV32_SLINK->ROUTE = dst;
}


/**********************************************************************//**
* Get RX link routing source
*
* @note This needs has to be called AFTER reading the actual data word
* using #neorv32_slink_get(void).
*
* @return 4-bit source routing ID.
**************************************************************************/
inline uint32_t __attribute__((always_inline)) neorv32_slink_get_src(void) {

return (NEORV32_SLINK->ROUTE >> SLINK_ROUTE_SRC_LSB) & 0xF;
}


/**********************************************************************//**
* Write data to TX link (non-blocking)
*
Expand Down

0 comments on commit d04f154

Please sign in to comment.