Skip to content

Commit c20a1cc

Browse files
committed
ticker api: format code to meet mbed standards.
1 parent 3b6c00b commit c20a1cc

File tree

1 file changed

+25
-13
lines changed

1 file changed

+25
-13
lines changed

hal/mbed_ticker_api.c

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
#include <stdio.h>
16+
#include <stdio.h>
1717
#include <stddef.h>
1818
#include "hal/ticker_api.h"
1919
#include "platform/mbed_critical.h"
@@ -26,7 +26,8 @@ static void update_current_timestamp(const ticker_data_t *const ticker);
2626
/*
2727
* Initialize a ticker instance.
2828
*/
29-
static void initialize(const ticker_data_t *ticker) {
29+
static void initialize(const ticker_data_t *ticker)
30+
{
3031
// return if the queue has already been initialized, in that case the
3132
// interface used by the queue is already initialized.
3233
if (ticker->queue->initialized) {
@@ -47,7 +48,8 @@ static void initialize(const ticker_data_t *ticker) {
4748
/**
4849
* Set the event handler function of a ticker instance.
4950
*/
50-
static void set_handler(const ticker_data_t *const ticker, ticker_event_handler handler) {
51+
static void set_handler(const ticker_data_t *const ticker, ticker_event_handler handler)
52+
{
5153
ticker->queue->event_handler = handler;
5254
}
5355

@@ -63,7 +65,8 @@ static void set_handler(const ticker_data_t *const ticker, ticker_event_handler
6365
* @param ref: The timestamp of reference.
6466
* @param relative_timestamp: The timestamp to convert.
6567
*/
66-
static us_timestamp_t convert_relative_timestamp(us_timestamp_t ref, timestamp_t relative_timestamp) {
68+
static us_timestamp_t convert_relative_timestamp(us_timestamp_t ref, timestamp_t relative_timestamp)
69+
{
6770
bool overflow = relative_timestamp < ((timestamp_t) ref) ? true : false;
6871

6972
us_timestamp_t result = (ref & ~((us_timestamp_t)UINT32_MAX)) | relative_timestamp;
@@ -77,7 +80,8 @@ static us_timestamp_t convert_relative_timestamp(us_timestamp_t ref, timestamp_t
7780
/**
7881
* update the current timestamp value of a ticker.
7982
*/
80-
static void update_current_timestamp(const ticker_data_t *const ticker) {
83+
static void update_current_timestamp(const ticker_data_t *const ticker)
84+
{
8185
ticker->queue->timestamp = convert_relative_timestamp(
8286
ticker->queue->timestamp,
8387
ticker->interface->read()
@@ -91,7 +95,8 @@ static void update_current_timestamp(const ticker_data_t *const ticker) {
9195
* interrupt will be set to MBED_TICKER_INTERRUPT_TIMESTAMP_MAX_DELTA us from now.
9296
* Otherwise the interrupt will be set to head->timestamp - queue->timestamp us.
9397
*/
94-
static void update_interrupt(const ticker_data_t *const ticker) {
98+
static void update_interrupt(const ticker_data_t *const ticker)
99+
{
95100
update_current_timestamp(ticker);
96101
uint32_t diff = MBED_TICKER_INTERRUPT_TIMESTAMP_MAX_DELTA;
97102

@@ -107,12 +112,14 @@ static void update_interrupt(const ticker_data_t *const ticker) {
107112
);
108113
}
109114

110-
void ticker_set_handler(const ticker_data_t *const ticker, ticker_event_handler handler) {
115+
void ticker_set_handler(const ticker_data_t *const ticker, ticker_event_handler handler)
116+
{
111117
initialize(ticker);
112118
set_handler(ticker, handler);
113119
}
114120

115-
void ticker_irq_handler(const ticker_data_t *const ticker) {
121+
void ticker_irq_handler(const ticker_data_t *const ticker)
122+
{
116123
ticker->interface->clear_interrupt();
117124

118125
/* Go through all the pending TimerEvents */
@@ -142,7 +149,8 @@ void ticker_irq_handler(const ticker_data_t *const ticker) {
142149
update_interrupt(ticker);
143150
}
144151

145-
void ticker_insert_event(const ticker_data_t *const ticker, ticker_event_t *obj, timestamp_t timestamp, uint32_t id) {
152+
void ticker_insert_event(const ticker_data_t *const ticker, ticker_event_t *obj, timestamp_t timestamp, uint32_t id)
153+
{
146154
/* disable interrupts for the duration of the function */
147155
core_util_critical_section_enter();
148156

@@ -161,7 +169,8 @@ void ticker_insert_event(const ticker_data_t *const ticker, ticker_event_t *obj,
161169
);
162170
}
163171

164-
void ticker_insert_event_us(const ticker_data_t *const ticker, ticker_event_t *obj, us_timestamp_t timestamp, uint32_t id) {
172+
void ticker_insert_event_us(const ticker_data_t *const ticker, ticker_event_t *obj, us_timestamp_t timestamp, uint32_t id)
173+
{
165174
/* disable interrupts for the duration of the function */
166175
core_util_critical_section_enter();
167176

@@ -207,7 +216,8 @@ void ticker_insert_event_us(const ticker_data_t *const ticker, ticker_event_t *o
207216
core_util_critical_section_exit();
208217
}
209218

210-
void ticker_remove_event(const ticker_data_t *const ticker, ticker_event_t *obj) {
219+
void ticker_remove_event(const ticker_data_t *const ticker, ticker_event_t *obj)
220+
{
211221
core_util_critical_section_enter();
212222

213223
// remove this object from the list
@@ -230,11 +240,13 @@ void ticker_remove_event(const ticker_data_t *const ticker, ticker_event_t *obj)
230240
core_util_critical_section_exit();
231241
}
232242

233-
timestamp_t ticker_read(const ticker_data_t *const ticker) {
243+
timestamp_t ticker_read(const ticker_data_t *const ticker)
244+
{
234245
return ticker_read_us(ticker);
235246
}
236247

237-
us_timestamp_t ticker_read_us(const ticker_data_t *const ticker) {
248+
us_timestamp_t ticker_read_us(const ticker_data_t *const ticker)
249+
{
238250
update_current_timestamp(ticker);
239251
return ticker->queue->timestamp;
240252
}

0 commit comments

Comments
 (0)