common: support inclusion into assembly files
Suggested in https://github.com/libopencm3/libopencm3/pull/981
This commit is contained in:
parent
72e449f529
commit
4edba3111d
@ -20,15 +20,16 @@
|
|||||||
#ifndef LIBOPENCM3_CM3_COMMON_H
|
#ifndef LIBOPENCM3_CM3_COMMON_H
|
||||||
#define LIBOPENCM3_CM3_COMMON_H
|
#define LIBOPENCM3_CM3_COMMON_H
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
|
|
||||||
/* This must be placed around external function declaration for C++
|
|
||||||
* support. */
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
/* Declarations need wrapping for C++ */
|
||||||
# define BEGIN_DECLS extern "C" {
|
# define BEGIN_DECLS extern "C" {
|
||||||
# define END_DECLS }
|
# define END_DECLS }
|
||||||
|
#elif defined(__ASSEMBLER__)
|
||||||
|
/* skipping for assembly */
|
||||||
|
#define BEGIN_DECLS .if 0
|
||||||
|
#define END_DECLS .endif
|
||||||
#else
|
#else
|
||||||
|
/* And nothing for C */
|
||||||
# define BEGIN_DECLS
|
# define BEGIN_DECLS
|
||||||
# define END_DECLS
|
# define END_DECLS
|
||||||
#endif
|
#endif
|
||||||
@ -46,6 +47,22 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if defined (__ASSEMBLER__)
|
||||||
|
#define MMIO8(addr) (addr)
|
||||||
|
#define MMIO16(addr) (addr)
|
||||||
|
#define MMIO32(addr) (addr)
|
||||||
|
#define MMIO64(addr) (addr)
|
||||||
|
|
||||||
|
#define BBIO_SRAM(addr, bit) \
|
||||||
|
(((addr) & 0x0FFFFF) * 32 + 0x22000000 + (bit) * 4)
|
||||||
|
|
||||||
|
#define BBIO_PERIPH(addr, bit) \
|
||||||
|
(((addr) & 0x0FFFFF) * 32 + 0x42000000 + (bit) * 4)
|
||||||
|
#else
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
/* Generic memory-mapped I/O accessor functions */
|
/* Generic memory-mapped I/O accessor functions */
|
||||||
#define MMIO8(addr) (*(volatile uint8_t *)(addr))
|
#define MMIO8(addr) (*(volatile uint8_t *)(addr))
|
||||||
#define MMIO16(addr) (*(volatile uint16_t *)(addr))
|
#define MMIO16(addr) (*(volatile uint16_t *)(addr))
|
||||||
@ -58,6 +75,7 @@
|
|||||||
|
|
||||||
#define BBIO_PERIPH(addr, bit) \
|
#define BBIO_PERIPH(addr, bit) \
|
||||||
MMIO32((((uint32_t)addr) & 0x0FFFFF) * 32 + 0x42000000 + (bit) * 4)
|
MMIO32((((uint32_t)addr) & 0x0FFFFF) * 32 + 0x42000000 + (bit) * 4)
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Generic bit definition */
|
/* Generic bit definition */
|
||||||
#define BIT0 (1<<0)
|
#define BIT0 (1<<0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user