forked from u-blox/ubxlib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathu_port_private.h
123 lines (103 loc) · 3.91 KB
/
u_port_private.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*
* Copyright 2022 u-blox
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _U_PORT_PRIVATE_H_
#define _U_PORT_PRIVATE_H_
/** @file
* @brief Stuff private to the STM32F4 porting layer.
*/
#ifdef __cplusplus
extern "C" {
#endif
/* ----------------------------------------------------------------
* COMPILE-TIME MACROS
* -------------------------------------------------------------- */
/** Get the port number of a pin, which is the upper nibble.
*/
#define U_PORT_STM32F4_GPIO_PORT(x) ((uint16_t ) (((uint32_t) x) >> 4))
/** Get the pin number of a pin, which is the lower nibble.
*/
#define U_PORT_STM32F4_GPIO_PIN(x) ((uint16_t ) (x & 0x0f))
#ifndef U_PORT_PRIVATE_TIMER_NAME_MAX_LEN_BYTES
/** The maximum length of the name of a timer: the name is used for
* diagnostic purposes only so it is not allowed to be very long
* to save on RAM.
*/
# define U_PORT_PRIVATE_TIMER_NAME_MAX_LEN_BYTES 8
#endif
/** Convert a millisecond value to an RTOS tick.
*/
#define MS_TO_TICKS(delayMs) (( configTICK_RATE_HZ * delayMs + 500 ) / 1000)
/* ----------------------------------------------------------------
* TYPES
* -------------------------------------------------------------- */
/* ----------------------------------------------------------------
* FUNCTIONS
* -------------------------------------------------------------- */
/** Initialise the private stuff.
*
* @return zero on success else negative error code.
*/
int32_t uPortPrivateInit();
/** Deinitialise the private stuff.
*/
void uPortPrivateDeinit();
/** Get the current OS tick converted to a time in milliseconds.
*/
int64_t uPortPrivateGetTickTimeMs();
/** Return the address of the port register for a given GPIO pin.
*
* @param pin the pin number.
* @return the GPIO port address.
* */
GPIO_TypeDef *pUPortPrivateGpioGetReg(int32_t pin);
/** Enable the clock to the register of the given GPIO pin.
*
* @param pin the pin number.
*/
void uPortPrivateGpioEnableClock(int32_t pin);
/** Add a timer entry to the list.
*
* @param pHandle a place to put the timer handle.
* @param pName a name for the timer, used for debug
* purposes only; should be a null-terminated
* string, may be NULL. The value will be
* copied.
* @param pCallback the timer callback routine.
* @param pCallbackParam a parameter that will be provided to the
* timer callback routine as its second parameter
* when it is called; may be NULL.
* @param intervalMs the time interval in milliseconds.
* @param periodic if true the timer will be restarted after it
* has expired, else the timer will be one-shot.
* @return zero on success else negative error code.
*/
int32_t uPortPrivateTimerCreate(uPortTimerHandle_t *pHandle,
const char *pName,
pTimerCallback_t *pCallback,
void *pCallbackParam,
uint32_t intervalMs,
bool periodic);
/** Remove a timer entry from the list.
*
* @param handle the handle of the timer to be removed.
* @return zero on success else negative error code.
*/
int32_t uPortPrivateTimerDelete(const uPortTimerHandle_t handle);
#ifdef __cplusplus
}
#endif
#endif // _U_PORT_PRIVATE_H_
// End of file