Statistics
| Branch: | Tag: | Revision:

amiro-os / periphery-lld / aos_periphAL.h @ ded1ded7

History | View | Annotate | Download (4.403 KB)

1 dd56d656 Thomas Schöpping
/*
2
AMiRo-OS is an operating system designed for the Autonomous Mini Robot (AMiRo) platform.
3 96621a83 Thomas Schöpping
Copyright (C) 2016..2020  Thomas Schöpping et al.
4 dd56d656 Thomas Schöpping

5
This program is free software: you can redistribute it and/or modify
6
it under the terms of the GNU General Public License as published by
7
the Free Software Foundation, either version 3 of the License, or
8
(at your option) any later version.
9

10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
GNU General Public License for more details.
14

15
You should have received a copy of the GNU General Public License
16
along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
*/
18
19
#ifndef AMIROOS_PERIPHAL_H
20
#define AMIROOS_PERIPHAL_H
21
22
/*============================================================================*/
23
/* DEPENDENCIES                                                               */
24
/*============================================================================*/
25
26
#include <aosconf.h>
27 ded1ded7 Thomas Schöpping
#include <alldconf.h>
28 dd56d656 Thomas Schöpping
#include <hal.h>
29
30
/*============================================================================*/
31
/* DEBUG                                                                      */
32
/*============================================================================*/
33
34 ded1ded7 Thomas Schöpping
#if (AMIROLLD_CFG_DBG == true) && (AMIROOS_CFG_DBG != true)
35 dd56d656 Thomas Schöpping
36 ded1ded7 Thomas Schöpping
#define apalDbgAssertMsg(condition, fmt, ...)
37 dd56d656 Thomas Schöpping
38
#define apalDbgPrintf(fmt, ...)                 0
39
40 ded1ded7 Thomas Schöpping
#endif /* (AMIROLLD_CFG_DBG == true) && (AMIROOS_CFG_DBG != true) */
41 dd56d656 Thomas Schöpping
42
/*============================================================================*/
43
/* TIMING                                                                     */
44
/*============================================================================*/
45
46
#if (AMIROOS_CFG_DBG != true)
47
48
#define apalSleep(us)   chThdSleep(chTimeUS2I((apalTime_t)us))
49
50
#endif /* (AMIROOS_CFG_DBG == true) */
51
52
/*============================================================================*/
53
/* GPIO                                                                       */
54
/*============================================================================*/
55
56
#if (HAL_USE_PAL == TRUE) || defined(__DOXYGEN__)
57
58
/**
59
 * @brief GPIO driver type.
60
 */
61
typedef struct {
62
  ioline_t line;
63
} PACKED_VAR apalGpio_t;
64
65
/**
66
 * @brief   Converts an apalGpioEdge_t to an ChibiOS PAL edge.
67
 */
68
#define APAL2CH_EDGE(edge)                                            \
69
  ((edge == APAL_GPIO_EDGE_RISING) ? PAL_EVENT_MODE_RISING_EDGE :     \
70
    (edge == APAL_GPIO_EDGE_FALLING) ? PAL_EVENT_MODE_FALLING_EDGE :  \
71
     (edge == APAL_GPIO_EDGE_BOTH) ? PAL_EVENT_MODE_BOTH_EDGES :      \
72
      PAL_EVENT_MODE_DISABLED)
73
74
#endif /* (HAL_USE_PAL == TRUE) */
75
76
/*============================================================================*/
77
/* PWM                                                                        */
78
/*============================================================================*/
79
80
#if (HAL_USE_PWM == TRUE) || defined (__DOXYGEN__)
81
82
/**
83
 * @brief PWM driver type.
84
 */
85
typedef PWMDriver apalPWMDriver_t;
86
87
#endif /* (HAL_USE_PWM == TRUE) */
88
89
/*============================================================================*/
90
/* QEI                                                                        */
91
/*============================================================================*/
92
93
#if (HAL_USE_QEI == TRUE) || defined (__DOXYGEN__)
94
95
/**
96
 * @brief QEI driver type.
97
 */
98
typedef QEIDriver apalQEIDriver_t;
99
100
#endif /* (HAL_USE_QEI == TRUE) */
101
102
/*============================================================================*/
103
/* I2C                                                                        */
104
/*============================================================================*/
105
106
#if (HAL_USE_I2C == TRUE) || defined(__DOXYGEN__)
107
108
/**
109
 * @brief I2C driver type.
110
 */
111
typedef I2CDriver apalI2CDriver_t;
112
113
#endif /* (HAL_USE_I2C == TRUE) */
114
115
/*============================================================================*/
116
/* SPI                                                                        */
117
/*============================================================================*/
118
119
#if (HAL_USE_SPI == TRUE) || defined(__DOXYGEN__)
120
121
/**
122
 * @brief SPI driver type.
123
 */
124
typedef SPIDriver apalSPIDriver_t;
125
126
/**
127
 * @brief SPI confguration type.
128
 */
129
typedef SPIConfig apalSPIConfig_t;
130
131
#endif /* (HAL_USE_SPI == TRUE) */
132
133
#endif /* AMIROOS_PERIPHAL_H */