Statistics
| Branch: | Tag: | Revision:

amiro-os / periphery-lld / aos_periphAL.h @ 82b6a25c

History | View | Annotate | Download (4.311 KB)

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

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
#include <hal.h>
28

    
29
/*============================================================================*/
30
/* DEBUG                                                                      */
31
/*============================================================================*/
32

    
33
#if (AMIROOS_CFG_DBG != true)
34

    
35
#define apalDbgAssert(condition)
36

    
37
#define apalDbgPrintf(fmt, ...)                 0
38

    
39
#endif /* (AMIROOS_CFG_DBG == true) */
40

    
41
/*============================================================================*/
42
/* TIMING                                                                     */
43
/*============================================================================*/
44

    
45
#if (AMIROOS_CFG_DBG != true)
46

    
47
#define apalSleep(us)   chThdSleep(chTimeUS2I((apalTime_t)us))
48

    
49
#endif /* (AMIROOS_CFG_DBG == true) */
50

    
51
/*============================================================================*/
52
/* GPIO                                                                       */
53
/*============================================================================*/
54

    
55
#if (HAL_USE_PAL == TRUE) || defined(__DOXYGEN__)
56

    
57
/**
58
 * @brief GPIO driver type.
59
 */
60
typedef struct {
61
  ioline_t line;
62
} PACKED_VAR apalGpio_t;
63

    
64
/**
65
 * @brief   Converts an apalGpioEdge_t to an ChibiOS PAL edge.
66
 */
67
#define APAL2CH_EDGE(edge)                                            \
68
  ((edge == APAL_GPIO_EDGE_RISING) ? PAL_EVENT_MODE_RISING_EDGE :     \
69
    (edge == APAL_GPIO_EDGE_FALLING) ? PAL_EVENT_MODE_FALLING_EDGE :  \
70
     (edge == APAL_GPIO_EDGE_BOTH) ? PAL_EVENT_MODE_BOTH_EDGES :      \
71
      PAL_EVENT_MODE_DISABLED)
72

    
73
#endif /* (HAL_USE_PAL == TRUE) */
74

    
75
/*============================================================================*/
76
/* PWM                                                                        */
77
/*============================================================================*/
78

    
79
#if (HAL_USE_PWM == TRUE) || defined (__DOXYGEN__)
80

    
81
/**
82
 * @brief PWM driver type.
83
 */
84
typedef PWMDriver apalPWMDriver_t;
85

    
86
#endif /* (HAL_USE_PWM == TRUE) */
87

    
88
/*============================================================================*/
89
/* QEI                                                                        */
90
/*============================================================================*/
91

    
92
#if (HAL_USE_QEI == TRUE) || defined (__DOXYGEN__)
93

    
94
/**
95
 * @brief QEI driver type.
96
 */
97
typedef QEIDriver apalQEIDriver_t;
98

    
99
#endif /* (HAL_USE_QEI == TRUE) */
100

    
101
/*============================================================================*/
102
/* I2C                                                                        */
103
/*============================================================================*/
104

    
105
#if (HAL_USE_I2C == TRUE) || defined(__DOXYGEN__)
106

    
107
/**
108
 * @brief I2C driver type.
109
 */
110
typedef I2CDriver apalI2CDriver_t;
111

    
112
#endif /* (HAL_USE_I2C == TRUE) */
113

    
114
/*============================================================================*/
115
/* SPI                                                                        */
116
/*============================================================================*/
117

    
118
#if (HAL_USE_SPI == TRUE) || defined(__DOXYGEN__)
119

    
120
/**
121
 * @brief SPI driver type.
122
 */
123
typedef SPIDriver apalSPIDriver_t;
124

    
125
/**
126
 * @brief SPI confguration type.
127
 */
128
typedef SPIConfig apalSPIConfig_t;
129

    
130
#endif /* (HAL_USE_SPI == TRUE) */
131

    
132
#endif /* AMIROOS_PERIPHAL_H */