Import code from old repository from 2018
Old repository: https://github.com/binaryDiv/z80_computer
This commit is contained in:
parent
536e557eea
commit
8c7b62dc2d
19 changed files with 3076 additions and 0 deletions
44
firmware_src/BitIO.h
Normal file
44
firmware_src/BitIO.h
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
/**
|
||||
* BitIO.h
|
||||
* @author Andi Dittrich <http://andidittrich.de>
|
||||
* @version 1.0
|
||||
* @license MIT Style X11 License
|
||||
*/
|
||||
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifndef BITIO_H_
|
||||
#define BITIO_H_
|
||||
|
||||
// set bit
|
||||
static inline void BIT_SET(volatile uint8_t *target, uint8_t bit) __attribute__((always_inline));
|
||||
static inline void BIT_SET(volatile uint8_t *target, uint8_t bit){
|
||||
*target |= (1<<bit);
|
||||
};
|
||||
|
||||
// set clear
|
||||
static inline void BIT_CLEAR(volatile uint8_t *target, uint8_t bit) __attribute__((always_inline));
|
||||
static inline void BIT_CLEAR(volatile uint8_t *target, uint8_t bit){
|
||||
*target &= ~(1<<bit);
|
||||
};
|
||||
|
||||
// bit toogle
|
||||
static inline void BIT_TOGGLE(volatile uint8_t *target, uint8_t bit) __attribute__((always_inline));
|
||||
static inline void BIT_TOGGLE(volatile uint8_t *target, uint8_t bit){
|
||||
*target ^= (1<<bit);
|
||||
};
|
||||
|
||||
// set bit by boolean
|
||||
static inline void BIT_BOOL_SET(volatile uint8_t *target, uint8_t bit, bool enable) __attribute__((always_inline));
|
||||
static inline void BIT_BOOL_SET(volatile uint8_t *target, uint8_t bit, bool enable){
|
||||
if (enable){
|
||||
BIT_SET(target, bit);
|
||||
}else{
|
||||
BIT_CLEAR(target, bit);
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* BITIO_H_ */
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue