9 static void _mutex_init(
const struct heivs_bus_t *bus)
14 static void _mutex_get(
const struct heivs_bus_t *bus)
19 static void _mutex_put(
const struct heivs_bus_t *bus)
25 #if !INCLUDE_vTaskSuspend
26 #error INCLUDE_vTaskSuspend is necessary for bus mutexes
29 static void _mutex_init(
const struct heivs_bus_t *bus)
31 if (!bus->
var->mutex_ignore && bus->
var->mutex == NULL)
33 bus->
var->mutex = xSemaphoreCreateMutexNamed(bus->
name);
37 static void _mutex_get(
const struct heivs_bus_t *bus)
39 if (bus->
var->mutex == NULL)
44 if (bus->
var->mutex && !bus->
var->mutex_ignore)
46 xSemaphoreTake(bus->
var->mutex, portMAX_DELAY);
50 static void _mutex_put(
const struct heivs_bus_t *bus)
52 if (bus->
var->mutex && !bus->
var->mutex_ignore)
54 xSemaphoreGive(bus->
var->mutex);
71 return ERROR_BUS_BUSY;
83 status = bus->
_init(bus);
102 if (bus->
var->state == required_state)
107 switch (bus->
var->state)
131 return ERROR_NOT_YET_IMPLEMENTED;
233 status = bus->
_read(bus, address, data, len, rlen);
269 status = bus->_write(bus, address, data, len);
293 if (!src_len && !dst_len)
301 return bus_write(bus, address, src, src_len);
307 return bus_read(bus, address, dst, dst_len, rlen);
326 status = bus->_writeread(bus, address, src, src_len, dst, dst_len, rlen);
Bus not operable while in power down.
status_e(* _suspend)(const struct heivs_bus_t *)
Have you called bus_get ?
status_e bus_release(const struct heivs_bus_t *bus)
Release exclusive access to the bus.
Have you called bus_init ?
status_e bus_resume(const struct heivs_bus_t *bus)
Resume the bus (from low power mode)
struct heivs_bus_var_t * var
status_e(* _init)(const struct heivs_bus_t *)
see bus_get/bus_release and errors
status_e bus_write(const struct heivs_bus_t *bus, uint32_t address, const void *data, size_t len)
Write data to the bus.
status_e(* _read)(const struct heivs_bus_t *, uint32_t address, uint8_t *data, size_t len, size_t *rlen)
status_e bus_init(const struct heivs_bus_t *bus)
initialize the bus
status_e(* _resume)(const struct heivs_bus_t *)
status_e bus_read(const struct heivs_bus_t *bus, uint32_t address, void *data, size_t len, size_t *rlen)
Resume the bus (from low power mode)
status_e bus_get(const struct heivs_bus_t *bus)
Get exclusive access to the bus.
heivs_bus_state_t
State of the bus.
status_e bus_writeread(const struct heivs_bus_t *bus, uint32_t address, const void *src, size_t src_len, void *dst, size_t dst_len, size_t *rlen)
Combined write and read data.
status_e bus_suspend(const struct heivs_bus_t *bus)
Suspend the bus (low power mode)