STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
dev_bus.h
Go to the documentation of this file.
1
#ifndef STAR_DEV_BUS_H
2
#define STAR_DEV_BUS_H
3
4
/*
5
* The only way a portable chip driver (chips/) touches hardware. The board
6
* binds it to board_spi (one chip, one deadline); host tests bind it to a
7
* scripted fake. Drivers never include HAL or RTOS headers.
8
*/
9
10
#include <stdint.h>
11
12
#ifdef __cplusplus
13
extern
"C"
{
14
#endif
15
16
enum
{
17
DEV_OK
= 0,
18
DEV_ERR_BUS
= -1,
/* transfer failed or timed out */
19
DEV_ERR_ID
= -2,
/* identity register did not match */
20
DEV_ERR_VERIFY
= -3,
/* a configuration register did not read back */
21
DEV_ERR_TIMEOUT
= -4,
/* the chip did not finish within its bound */
22
DEV_ERR_PARAM
= -5,
/* caller bug */
23
DEV_ERR_DATA
= -6,
/* chip answered with invalid contents */
24
};
25
26
typedef
struct
{
27
/* One chip-select frame: len bytes out of tx, len bytes into rx (either
28
* may be NULL: NULL tx clocks 0xFF, NULL rx discards). DEV_OK or
29
* DEV_ERR_BUS. */
30
int (*
xfer
)(
void
*
ctx
,
const
uint8_t* tx, uint8_t* rx, uint16_t len);
31
/* Sleep at least ms milliseconds. */
32
void (*
delay_ms
)(
void
*
ctx
, uint32_t ms);
33
void
*
ctx
;
34
}
dev_bus_t
;
35
36
#ifdef __cplusplus
37
}
38
#endif
39
#endif
DEV_ERR_VERIFY
@ DEV_ERR_VERIFY
Definition
dev_bus.h:20
DEV_OK
@ DEV_OK
Definition
dev_bus.h:17
DEV_ERR_DATA
@ DEV_ERR_DATA
Definition
dev_bus.h:23
DEV_ERR_PARAM
@ DEV_ERR_PARAM
Definition
dev_bus.h:22
DEV_ERR_TIMEOUT
@ DEV_ERR_TIMEOUT
Definition
dev_bus.h:21
DEV_ERR_ID
@ DEV_ERR_ID
Definition
dev_bus.h:19
DEV_ERR_BUS
@ DEV_ERR_BUS
Definition
dev_bus.h:18
dev_bus_t
Definition
dev_bus.h:26
dev_bus_t::xfer
int(* xfer)(void *ctx, const uint8_t *tx, uint8_t *rx, uint16_t len)
Definition
dev_bus.h:30
dev_bus_t::ctx
void * ctx
Definition
dev_bus.h:33
dev_bus_t::delay_ms
void(* delay_ms)(void *ctx, uint32_t ms)
Definition
dev_bus.h:32
firmware
Flight_Computer
src
chips
dev_bus.h
Generated by
1.15.0