Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d518b24

Browse files
committedAug 23, 2017
Extend compatibility
Add several macro for compatibily (register access) Added: analogInPinToBit portOutputRegister portInputRegister portSetRegister portClearRegister portConfigRegister portModeRegister _BV cbi sbi Signed-off-by: Frederic.Pillon <[email protected]>
1 parent 77192e8 commit d518b24

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed
 

‎cores/arduino/pins_arduino.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,22 @@ uint32_t pinNametoDigitalPin(PinName p);
6565
#define digitalPinToPort(p) (get_GPIO_Port(STM_PORT(digitalPinToPinName(p))))
6666
#define digitalPinToBitMask(p) (STM_GPIO_PIN(digitalPinToPinName(p)))
6767

68+
#define analogInPinToBit(p) (STM_PIN(digitalPinToPinName(p)))
69+
#define portOutputRegister(P) (&(P->ODR))
70+
#define portInputRegister(P) (&(P->IDR))
71+
72+
#define portSetRegister(P) (&(P->BSRR))
73+
#define portClearRegister(P) (&(P->BRR))
74+
75+
// Config registers split in 2 registers:
76+
// CRL: pin 0..7
77+
// CRH: pin 8..15
78+
// Return only CRL
79+
#define portConfigRegister(P) (&(P->CRL))
80+
// Mode included in the config register
81+
#define portModeRegister(P) (portConfigRegister(P))
82+
83+
6884
#define digitalPinIsValid(p) (digitalPinToPinName(p) != NC)
6985

7086
// As some pin could be duplicated in digitalPin[]

‎cores/arduino/wiring_constants.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,19 @@ enum BitOrder {
112112
#define bitClear(value, bit) ((value) &= ~(1UL << (bit)))
113113
#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit))
114114

115-
typedef unsigned int word;
116-
117115
#define bit(b) (1UL << (b))
116+
//macro added for compatibility
117+
#ifndef _BV
118+
#define _BV(bit) (1 << (bit))
119+
#endif
120+
#ifndef cbi
121+
#define cbi(reg, bitmask) *reg &= ~bitmask
122+
#endif
123+
#ifndef sbi
124+
#define sbi(reg, bitmask) *reg |= bitmask
125+
#endif
118126

127+
typedef unsigned int word;
119128

120129
typedef bool boolean ;
121130

0 commit comments

Comments
 (0)
Please sign in to comment.