mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-15 04:15:44 +03:00
New timer implementation
This is first part of new softserial code. Main timer code is changed, changes to rest of code are kept to minimum. macros for BASEPRI based synchronization are added to project (atomic.h) TIMER_PERIOD fixed in pwm_rx.c
This commit is contained in:
parent
2c8b3af88d
commit
aa7f5c4a1e
17 changed files with 953 additions and 249 deletions
44
src/main/common/utils.h
Normal file
44
src/main/common/utils.h
Normal file
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* This file is part of Cleanflight.
|
||||
*
|
||||
* Cleanflight is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Cleanflight is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#define ARRAYLEN(x) (sizeof(x) / sizeof((x)[0]))
|
||||
|
||||
/*
|
||||
http://resnet.uoregon.edu/~gurney_j/jmpc/bitwise.html
|
||||
*/
|
||||
#define BITCOUNT(x) (((BX_(x)+(BX_(x)>>4)) & 0x0F0F0F0F) % 255)
|
||||
#define BX_(x) ((x) - (((x)>>1)&0x77777777) - (((x)>>2)&0x33333333) - (((x)>>3)&0x11111111))
|
||||
|
||||
#define UNUSED(x) (void)(x)
|
||||
|
||||
#if 0
|
||||
// ISO C version, but no type checking
|
||||
#define container_of(ptr, type, member) \
|
||||
((type *) ((char *)(ptr) - offsetof(type, member)))
|
||||
#else
|
||||
// non ISO variant from linux kernel; checks ptr type, but triggers 'ISO C forbids braced-groups within expressions [-Wpedantic]'
|
||||
// __extension__ is here to disable this warning
|
||||
#define container_of(ptr, type, member) __extension__ ({ \
|
||||
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
|
||||
(type *)( (char *)__mptr - offsetof(type,member) );})
|
||||
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue