|
#define | EXAMPLE_ALREDY_INITED 1 |
|
#define | example_lock(u, w, e) HAL_LOCK(u, w, e) |
|
#define | example_unlock(u, e) HAL_UNLOCK(u, e) |
|
#define | EXAMPLE_ADDDEV(ns, p) HAL_ADDDEV(example, ns, p) |
|
#define | EXAMPLE_GET_DEV(index) HAL_GET_DEV(example, index) |
|
#define | EXAMPLE_OPS(ns) |
|
#define | EXAMPLE_INIT_DEV(ns) .gen.ops = &ns##_example_ops, |
|
#define | EXAMPLE_INIT(ns, index) static struct example *ns##_example_init(uint32_t index) |
|
#define | EXAMPLE_DEINIT(ns, p) static int32_t ns##_example_deinit(struct example *p) |
|
#define | EXAMPLE_FUNCNAME(ns, p, param) static int32_t ns##_example_funcname(struct example *p, uint32_t param) |
|
This is the Driver View form Example Driver.
This is a implementation of a driver
#include <stdio.h>
#define EXAMPLE_PRV
struct example {
uint32_t index;
};
int32_t ret;
if (ex == NULL) {
return NULL;
}
if (ret < 0) {
return NULL;
}
return ex;
}
ex->index = index;
return ex;
}
ex->gen.init = false;
return 0;
}
printf("%s: index: %lu param: %lu", __FUNCTION__, ex->index, param);
return 0;
}
static struct example ex0 = {
};
static struct example ex1 = {
};
Driver with board specific like the MPU9247 has special macros to create new Instances. (for example: MPU9250_ADDDEV())
◆ EXAMPLE_ADDDEV
#define EXAMPLE_ADDDEV |
( |
|
ns, |
|
|
|
p |
|
) |
| HAL_ADDDEV(example, ns, p) |
Add Driver Instance
- Parameters
-
ns | Driver namespace |
p | Pointer to driver instance |
◆ EXAMPLE_ALREDY_INITED
#define EXAMPLE_ALREDY_INITED 1 |
Error Code Returned if Already inited
◆ EXAMPLE_DEINIT
#define EXAMPLE_DEINIT |
( |
|
ns, |
|
|
|
p |
|
) |
| static int32_t ns##_example_deinit(struct example *p) |
Define example_deinit() Implementation
- Parameters
-
ns | Driver namespace Variablenname |
p | Instance Variablenname |
◆ EXAMPLE_FUNCNAME
#define EXAMPLE_FUNCNAME |
( |
|
ns, |
|
|
|
p, |
|
|
|
param |
|
) |
| static int32_t ns##_example_funcname(struct example *p, uint32_t param) |
Define example_funcname() Implementation
- Parameters
-
ns | Driver namespace Variablenname |
p | Instance Variablenname |
param | Param Variablenname |
◆ EXAMPLE_GET_DEV
#define EXAMPLE_GET_DEV |
( |
|
index | ) |
HAL_GET_DEV(example, index) |
Simple function for access a dev from driver
- Parameters
-
- Returns
- see HAL_GET_DEV
◆ EXAMPLE_INIT
#define EXAMPLE_INIT |
( |
|
ns, |
|
|
|
index |
|
) |
| static struct example *ns##_example_init(uint32_t index) |
Define example_init() Implementation
- Parameters
-
ns | Driver namespace Variablenname |
index | Index Variablenname |
◆ EXAMPLE_INIT_DEV
#define EXAMPLE_INIT_DEV |
( |
|
ns | ) |
.gen.ops = &ns##_example_ops, |
Init Driver Struct
- Parameters
-
◆ example_lock
#define example_lock |
( |
|
u, |
|
|
|
w, |
|
|
|
e |
|
) |
| HAL_LOCK(u, w, e) |
Lock Driver if THREAD_SAVE is not defined this instruction has no function
◆ EXAMPLE_OPS
#define EXAMPLE_OPS |
( |
|
ns | ) |
|
Value:
.example_deinit = &ns##_example_deinit,\
.example_funcname = &ns##_example_funcname, \
}
Define Operation
- Parameters
-
◆ example_unlock
Unlock Driver if THREAD_SAVE is not defined this instruction has no function
◆ example_genericInit()
int32_t example_genericInit |
( |
struct example * |
example | ) |
|
Generic Init Function
Check Driver Already inited and init mutex if active
- Parameters
-
example | Instants of Driver |
- Returns
- EXAMPLE_ALREDY_INITED on alredy init 0 on not init < 0 error
◆ HAL_DEFINE_GLOBAL_ARRAY()
HAL_DEFINE_GLOBAL_ARRAY |
( |
example |
| ) |
|