Proyecto Final – Medición de Inclinación 0.0.1
Este proyecto utiliza la placa NUCLEO-STM32F446RE y permite detectar y visualizar en tiempo real la inclinación mediante el sensor MPU-6050.
Cargando...
Buscando...
Nada coincide
api.h
Ir a la documentación de este archivo.
1/* USER CODE BEGIN Header */
19/* USER CODE END Header */
20
21/* Define to prevent recursive inclusion -------------------------------------*/
22#ifndef __API_H
23#define __API_H
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
29/* Includes ------------------------------------------------------------------*/
30#include "stm32f4xx_hal.h"
31#include <stdint.h>
32
33#define REG_STATUS 0
34#define REG_MODULE_ID 1
35#define REG_FUNCTION_ID 2
36#define REG_ARG_TYPES 3
37#define REG_DATA_START 4
38
39#define API_GO 0x2
40#define API_BUSY 0x1
41
42#define ARGTYPE_U32 0
43#define ARGTYPE_TLV 1
44
45#define API_ALIGN(x) ( ((x)+3) & 0xFFFC )
46#define STRUCT_COUNT(x) ( sizeof(x) / sizeof(x[0]) )
47
48#define ARGTYPE_MASK 0x7F
49
50#define TLV_TYPE 0
51#define TLV_LENGTH 1
52#define TLV_VALUE 4
53#define TLV_HDRLEN 4
54
55#define ARGTYPE_PTR 0x80
56
57#define ARGLEN_PARAM 0x8000
58
59typedef enum TASK_T {
60 NONE_TASK_ID = 0,
61 ANY_TASK_ID = 1,
62} TASK_TYPE;
63
64typedef enum {
65 UINT8_T, // equivalente a uint8_t
66 INT8_T, // equivalente a int8_t
67 UINT16_T, // equivalente a uint16_t
68 INT16_T, // equivalente a int16_t
69 UINT32_T, // equivalente a uint32_t
70 INT32_T, // equivalente a int32_t
71 FLOAT32_T, // equivalente a float (32-bit IEEE-754)
72 FLOAT16_T, // equivalente a _Float16 / __fp16 (si lo soporta el compilador)
73 UINT64_T, // equivalente a uint64_t
74 __VOID // equivalente a void
75} ARG_TYPE;
76
77#define MODULE_GROUP_SHIFT 6
78#define MODULE_GROUP_MASK ( (0xFF << MODULE_GROUP_SHIFT) & 0xFF )
79#define MODULE_GROUP(m) ( (m) >> MODULE_GROUP_SHIFT )
80#define MODULE_ISGROUP(m, g) ( (m) & MODULE_GROUP_MASK == (g) )
81#define MODULE_INDEX(m) ( (m) & ~MODULE_GROUP_MASK )
82#define MODULE_GROUPS 4
83#define NONE_modules 0xff
84
85typedef HAL_StatusTypeDef (*fptr_0) (void);
86typedef HAL_StatusTypeDef (*fptr_1) (uintptr_t arg0);
87typedef HAL_StatusTypeDef (*fptr_2) (uintptr_t arg0, uintptr_t arg1);
88typedef HAL_StatusTypeDef (*fptr_3) (uintptr_t arg0, uintptr_t arg1, uintptr_t arg2);
89typedef HAL_StatusTypeDef (*fptr_4) (uintptr_t arg0, uintptr_t arg1, uintptr_t arg2, uintptr_t arg3);
90typedef HAL_StatusTypeDef (*fptr_5) (uintptr_t arg0, uintptr_t arg1, uintptr_t arg2, uintptr_t arg3, uintptr_t arg4);
91
92#define MAX_ARGS 8
93
94typedef struct FPTRS_T {
95 uint8_t module_id;
96 uint8_t function_id;
97 uint8_t task_id;
98 uint8_t nargs;
99 uint8_t arg_types[MAX_ARGS];
100 uint16_t arg_lens[MAX_ARGS];
101
102 union {
103 fptr_0 f0;
104 fptr_1 f1;
105 fptr_2 f2;
106 fptr_3 f3;
107 fptr_4 f4;
108 fptr_5 f5;
109 } fptr;
110} FPTRS;
111
112
113#define COMMAND_SIZE 1280
114
115typedef struct {
116 uint8_t buffer[COMMAND_SIZE];
117} COMMAND_DATA __attribute__((aligned(4)));
118
119extern COMMAND_DATA command;
120
121extern void exec_fn(uint8_t *data);
122
123#ifdef __cplusplus
124}
125#endif
126
127#endif /* __API_H */
Definition api.h:115
Definition api.h:94
uint8_t nargs
Definition api.h:98
uint8_t task_id
Definition api.h:97
uint8_t function_id
Definition api.h:96
uint8_t module_id
Definition api.h:95
uint16_t arg_lens[MAX_ARGS]
Definition api.h:100
uint8_t arg_types[MAX_ARGS]
Definition api.h:99