Skip to content

Missing compatibility #90

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions cores/arduino/pins_arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ extern "C" {

#define NOT_AN_INTERRUPT NC // -1
#define DEND PEND
#define NUM_DIGITAL_PINS DEND
#define NUM_DIGITAL_PINS ((uint32_t)DEND)
#define NUM_ANALOG_INPUTS (AEND-A0)

// Convert a digital pin number Dxx to a PinName PX_n
Expand Down Expand Up @@ -62,9 +62,34 @@ uint32_t pinNametoDigitalPin(PinName p);
pin_in_pinmap(digitalPinToPinName(p), PinMap_SPI_SSEL))


#define digitalPinToPort(p) (get_GPIO_Port(digitalPinToPinName(p)))
#define digitalPinToPort(p) (get_GPIO_Port(STM_PORT(digitalPinToPinName(p))))
#define digitalPinToBitMask(p) (STM_GPIO_PIN(digitalPinToPinName(p)))

#define analogInPinToBit(p) (STM_PIN(digitalPinToPinName(p)))
#define portOutputRegister(P) (&(P->ODR))
#define portInputRegister(P) (&(P->IDR))

#define portSetRegister(P) (&(P->BSRR))
#if defined(STM32F2xx) || defined(STM32F4xx) || defined(STM32F7xx)
// For those series reset are in the high part so << 16U needed
#define portClearRegister(P) (&(P->BSRR))
#else
#define portClearRegister(P) (&(P->BRR))
#endif


#if defined(STM32F1xx)
// Config registers split in 2 registers:
// CRL: pin 0..7
// CRH: pin 8..15
// Return only CRL
#define portModeRegister(P) (&(P->CRL))
#else
#define portModeRegister(P) (&(P->MODER))
#endif
#define portConfigRegister(P) (portModeRegister(P))


#define digitalPinIsValid(p) (digitalPinToPinName(p) != NC)

// As some pin could be duplicated in digitalPin[]
Expand Down
13 changes: 11 additions & 2 deletions cores/arduino/wiring_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,19 @@ enum BitOrder {
#define bitClear(value, bit) ((value) &= ~(1UL << (bit)))
#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit))

typedef unsigned int word;

#define bit(b) (1UL << (b))
//macro added for compatibility
#ifndef _BV
#define _BV(bit) (1 << (bit))
#endif
#ifndef cbi
#define cbi(reg, bitmask) *reg &= ~bitmask
#endif
#ifndef sbi
#define sbi(reg, bitmask) *reg |= bitmask
#endif

typedef unsigned int word;

typedef bool boolean ;

Expand Down