Schwabe/silence register warnings clang (#3940)

* Ignore deprecated register warning for the the STM include files

Ignore the warning with the use of #pragma which is not elegant but otherwise we would have to change the vendor files

* Remove usage of register in C/C++ files.

Modern compilers ignore it anyway and C++11 actually deprecates it. Removing also removes a number of clang warnings about this
This commit is contained in:
Arne Schwabe
2016-10-21 00:09:54 +02:00
committed by Bertrand Songis
parent ba824537d4
commit ad8cd2546e
21 changed files with 140 additions and 116 deletions
+5 -5
View File
@@ -917,27 +917,27 @@ inline int divRoundClosest(const int n, const int d)
#define calc100to256_16Bits(x) calc100to256(x) #define calc100to256_16Bits(x) calc100to256(x)
#define calc100toRESX_16Bits(x) calc100toRESX(x) #define calc100toRESX_16Bits(x) calc100toRESX(x)
inline int calc100to256(register int x) inline int calc100to256(int x)
{ {
return divRoundClosest(x*256, 100); return divRoundClosest(x*256, 100);
} }
inline int calc100toRESX(register int x) inline int calc100toRESX(int x)
{ {
return divRoundClosest(x*RESX, 100); return divRoundClosest(x*RESX, 100);
} }
inline int calc1000toRESX(register int x) inline int calc1000toRESX(int x)
{ {
return divRoundClosest(x*RESX, 1000); return divRoundClosest(x*RESX, 1000);
} }
inline int calcRESXto1000(register int x) inline int calcRESXto1000(int x)
{ {
return divRoundClosest(x*1000, RESX); return divRoundClosest(x*1000, RESX);
} }
inline int calcRESXto100(register int x) inline int calcRESXto100(int x)
{ {
return divRoundClosest(x*100, RESX); return divRoundClosest(x*100, RESX);
} }
+12
View File
@@ -27,6 +27,13 @@
extern "C" { extern "C" {
#endif #endif
#if __clang__
// clang is very picky about the use of "register"
// Tell clang to ignore the warnings for the following files
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-register"
#endif
#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h" #include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h"
#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_rcc.h" #include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_rcc.h"
#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_gpio.h" #include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_gpio.h"
@@ -44,6 +51,11 @@ extern "C" {
#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_tim.h" #include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_tim.h"
#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_dma2d.h" #include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_dma2d.h"
#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/misc.h" #include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/misc.h"
#if __clang__
// Restore warnings about registers
#pragma clang diagnostic pop
#endif
#if !defined(SIMU) #if !defined(SIMU)
#include "usbd_cdc_core.h" #include "usbd_cdc_core.h"
+3 -3
View File
@@ -93,7 +93,7 @@ uint8_t keyDown()
void checkRotaryEncoder() void checkRotaryEncoder()
{ {
register uint32_t newpos = ROTARY_ENCODER_POSITION(); uint32_t newpos = ROTARY_ENCODER_POSITION();
if (newpos != rotencPosition) { if (newpos != rotencPosition) {
if ((rotencPosition & 0x01) ^ ((newpos & 0x02) >> 1)) { if ((rotencPosition & 0x01) ^ ((newpos & 0x02) >> 1)) {
--rotencValue[0]; --rotencValue[0];
@@ -108,7 +108,7 @@ void checkRotaryEncoder()
/* TODO common to ARM */ /* TODO common to ARM */
void readKeysAndTrims() void readKeysAndTrims()
{ {
register uint32_t i; uint32_t i;
uint8_t index = 0; uint8_t index = 0;
uint32_t in = readKeys(); uint32_t in = readKeys();
@@ -161,7 +161,7 @@ uint8_t keyState(uint8_t index)
uint32_t switchState(uint8_t index) uint32_t switchState(uint8_t index)
{ {
register uint32_t xxx = 0; uint32_t xxx = 0;
switch (index) { switch (index) {
ADD_3POS_CASE(A, 0); ADD_3POS_CASE(A, 0);
+5 -5
View File
@@ -43,8 +43,8 @@ const char ana_direction[NUMBER_ANALOG] = {1, 1, 0, 1 ,0 ,1 ,0, 0, 0};
// TRGEN = 0 (software trigger only) // TRGEN = 0 (software trigger only)
void adcInit() void adcInit()
{ {
register Adc *padc ; Adc *padc ;
register uint32_t timer ; uint32_t timer ;
timer = ( Master_frequency / (3600000*2) ) << 8 ; timer = ( Master_frequency / (3600000*2) ) << 8 ;
// Enable peripheral clock ADC = bit 29 // Enable peripheral clock ADC = bit 29
@@ -65,9 +65,9 @@ void adcInit()
// Documented bug, must do them 1 by 1 // Documented bug, must do them 1 by 1
void adcSingleRead() void adcSingleRead()
{ {
register Adc *padc; Adc *padc;
register uint32_t y; uint32_t y;
register uint32_t x; uint32_t x;
for (uint8_t i=0; i<4; i++) for (uint8_t i=0; i<4; i++)
padc = ADC; padc = ADC;
+6 -6
View File
@@ -31,8 +31,8 @@ const int8_t volumeScale[VOLUME_LEVEL_MAX+1] =
void setSampleRate(uint32_t frequency) void setSampleRate(uint32_t frequency)
{ {
register Tc *ptc ; Tc *ptc ;
register uint32_t timer ; uint32_t timer ;
timer = Master_frequency / (8 * frequency) ; // MCK/8 and 100 000 Hz timer = Master_frequency / (8 * frequency) ; // MCK/8 and 100 000 Hz
if (timer > 65535) if (timer > 65535)
@@ -50,8 +50,8 @@ void setSampleRate(uint32_t frequency)
// Start TIMER1 at 100000Hz, used for DACC trigger // Start TIMER1 at 100000Hz, used for DACC trigger
void dacTimerStart() void dacTimerStart()
{ {
register Tc *ptc ; Tc *ptc ;
register uint32_t timer ; uint32_t timer ;
// Enable peripheral clock TC0 = bit 23 thru TC5 = bit 28 // Enable peripheral clock TC0 = bit 23 thru TC5 = bit 28
PMC->PMC_PCER0 |= 0x01000000L ; // Enable peripheral clock to TC1 PMC->PMC_PCER0 |= 0x01000000L ; // Enable peripheral clock to TC1
@@ -78,7 +78,7 @@ void dacInit()
PMC->PMC_PCER0 |= 0x40000000L ; // Enable peripheral clock to DAC PMC->PMC_PCER0 |= 0x40000000L ; // Enable peripheral clock to DAC
register Dacc *dacptr = DACC; Dacc *dacptr = DACC;
#if defined(REVA) #if defined(REVA)
dacptr->DACC_MR = 0x0B010215L ; // 0000 1011 0000 0001 0000 0010 0001 0101 dacptr->DACC_MR = 0x0B010215L ; // 0000 1011 0000 0001 0000 0010 0001 0101
@@ -137,7 +137,7 @@ extern "C" void DAC_IRQHandler()
// Sound routines // Sound routines
void audioInit() void audioInit()
{ {
register Pio *pioptr ; Pio *pioptr ;
dacInit() ; dacInit() ;
+15 -15
View File
@@ -50,7 +50,7 @@ extern "C" void sam_boot( void ) ;
inline void config_free_pins() inline void config_free_pins()
{ {
#if defined(REVA) #if defined(REVA)
register Pio * pioptr = PIOA ; Pio * pioptr = PIOA ;
pioptr->PIO_PER = 0x03800000L ; // Enable bits A25,24,23 pioptr->PIO_PER = 0x03800000L ; // Enable bits A25,24,23
pioptr->PIO_ODR = 0x03800000L ; // Set as input pioptr->PIO_ODR = 0x03800000L ; // Set as input
pioptr->PIO_PUER = 0x03800000L ; // Enable pullups pioptr->PIO_PUER = 0x03800000L ; // Enable pullups
@@ -73,7 +73,7 @@ inline void config_free_pins()
inline void setup_switches() inline void setup_switches()
{ {
#if defined(REVA) #if defined(REVA)
register Pio *pioptr = PIOA ; Pio *pioptr = PIOA ;
pioptr->PIO_PER = 0xF8008184 ; // Enable bits pioptr->PIO_PER = 0xF8008184 ; // Enable bits
pioptr->PIO_ODR = 0xF8008184 ; // Set bits input pioptr->PIO_ODR = 0xF8008184 ; // Set bits input
pioptr->PIO_PUER = 0xF8008184 ; // Set bits with pullups pioptr->PIO_PUER = 0xF8008184 ; // Set bits with pullups
@@ -97,7 +97,7 @@ inline void setup_switches()
#if !defined(SIMU) #if !defined(SIMU)
inline void UART3_Configure(uint32_t baudrate, uint32_t masterClock) inline void UART3_Configure(uint32_t baudrate, uint32_t masterClock)
{ {
register Uart *pUart = BT_USART; Uart *pUart = BT_USART;
/* Configure PIO */ /* Configure PIO */
configure_pins( (PIO_PB2 | PIO_PB3), PIN_PERIPHERAL | PIN_INPUT | PIN_PER_A | PIN_PORTB | PIN_NO_PULLUP ) ; configure_pins( (PIO_PB2 | PIO_PB3), PIN_PERIPHERAL | PIN_INPUT | PIN_PER_A | PIN_PORTB | PIN_NO_PULLUP ) ;
@@ -139,7 +139,7 @@ void UART3_Stop()
// This was 6 MHz, we may need to slow it to TIMER_CLOCK2 (MCK/8=4.5 MHz) // This was 6 MHz, we may need to slow it to TIMER_CLOCK2 (MCK/8=4.5 MHz)
inline void start_timer0() inline void start_timer0()
{ {
register Tc *ptc ; Tc *ptc ;
// Enable peripheral clock TC0 = bit 23 thru TC5 = bit 28 // Enable peripheral clock TC0 = bit 23 thru TC5 = bit 28
PMC->PMC_PCER0 |= 0x00800000L ; // Enable peripheral clock to TC0 PMC->PMC_PCER0 |= 0x00800000L ; // Enable peripheral clock to TC0
@@ -158,8 +158,8 @@ inline void start_timer0()
// Starts TIMER2 at 200Hz, commentd out drive of TIOA2 (A26, EXT2) // Starts TIMER2 at 200Hz, commentd out drive of TIOA2 (A26, EXT2)
inline void start_timer2() inline void start_timer2()
{ {
register Tc *ptc ; Tc *ptc ;
register uint32_t timer ; uint32_t timer ;
// Enable peripheral clock TC0 = bit 23 thru TC5 = bit 28 // Enable peripheral clock TC0 = bit 23 thru TC5 = bit 28
PMC->PMC_PCER0 |= 0x02000000L ; // Enable peripheral clock to TC2 PMC->PMC_PCER0 |= 0x02000000L ; // Enable peripheral clock to TC2
@@ -195,7 +195,7 @@ void interrupt5ms()
extern "C" void TC2_IRQHandler() extern "C" void TC2_IRQHandler()
{ {
register uint32_t dummy; uint32_t dummy;
/* Clear status bit to acknowledge interrupt */ /* Clear status bit to acknowledge interrupt */
dummy = TC0->TC_CHANNEL[2].TC_SR; dummy = TC0->TC_CHANNEL[2].TC_SR;
@@ -220,8 +220,8 @@ extern "C" void TC2_IRQHandler()
// For testing, just drive it out with PWM // For testing, just drive it out with PWM
void init_pwm() void init_pwm()
{ {
register Pwm *pwmptr ; Pwm *pwmptr ;
register uint32_t timer ; uint32_t timer ;
PMC->PMC_PCER0 |= ( 1 << ID_PWM ) ; // Enable peripheral clock to PWM PMC->PMC_PCER0 |= ( 1 << ID_PWM ) ; // Enable peripheral clock to PWM
@@ -229,7 +229,7 @@ void init_pwm()
/* Configure PIO */ /* Configure PIO */
#if defined(REVA) #if defined(REVA)
register Pio *pioptr = PIOB ; Pio *pioptr = PIOB ;
pioptr->PIO_PER = 0x00000020L ; // Enable bit B5 pioptr->PIO_PER = 0x00000020L ; // Enable bit B5
pioptr->PIO_ODR = 0x00000020L ; // set as input pioptr->PIO_ODR = 0x00000020L ; // set as input
#else #else
@@ -299,7 +299,7 @@ void init_pwm()
void configure_pins( uint32_t pins, uint16_t config ) void configure_pins( uint32_t pins, uint16_t config )
{ {
register Pio *pioptr ; Pio *pioptr ;
pioptr = PIOA + ( ( config & PIN_PORT_MASK ) >> 6) ; pioptr = PIOA + ( ( config & PIN_PORT_MASK ) >> 6) ;
if ( config & PIN_PULLUP ) if ( config & PIN_PULLUP )
@@ -374,8 +374,8 @@ void opentxBootloader();
#if !defined(AR9X) #if !defined(AR9X)
void i2cInit() void i2cInit()
{ {
register Pio *pioptr; Pio *pioptr;
register uint32_t timing; uint32_t timing;
PMC->PMC_PCER0 |= 0x00080000L ; // Enable peripheral clock to TWI0 PMC->PMC_PCER0 |= 0x00080000L ; // Enable peripheral clock to TWI0
@@ -410,7 +410,7 @@ void boardInit()
} }
} }
register Pio *pioptr ; Pio *pioptr ;
ResetReason = RSTC->RSTC_SR; ResetReason = RSTC->RSTC_SR;
@@ -547,7 +547,7 @@ uint8_t getTemperature()
void setSticksGain(uint8_t gains) void setSticksGain(uint8_t gains)
{ {
register Adc *padc ; Adc *padc ;
uint32_t gain ; uint32_t gain ;
uint32_t offset ; uint32_t offset ;
+4 -4
View File
@@ -111,8 +111,8 @@ static uint32_t BOARD_ConfigurePmc(void)
#undef CLOCK_TIMEOUT #undef CLOCK_TIMEOUT
#define CLOCK_TIMEOUT 0xFFFFFFFF #define CLOCK_TIMEOUT 0xFFFFFFFF
register uint32_t timeout = 0 ; uint32_t timeout = 0 ;
register Pmc *pmcptr ; Pmc *pmcptr ;
pmcptr = PMC ; pmcptr = PMC ;
@@ -179,8 +179,8 @@ static uint32_t BOARD_ConfigurePmc(void)
void revert_osc() void revert_osc()
{ {
register uint32_t timeout = 0; uint32_t timeout = 0;
register Pmc *pmcptr; Pmc *pmcptr;
pmcptr = PMC; pmcptr = PMC;
+3 -3
View File
@@ -71,9 +71,9 @@ extern uint32_t Master_frequency ;
void ResetHandler (void) void ResetHandler (void)
{ {
{ {
register uint32_t *pSrc; uint32_t *pSrc;
register uint32_t *pDest; uint32_t *pDest;
register uint32_t m_freq ; uint32_t m_freq ;
/* /*
* Call the SystemInit code from CMSIS interface if available. * Call the SystemInit code from CMSIS interface if available.
+8 -8
View File
@@ -28,10 +28,10 @@ uint8_t eepromIsTransferComplete()
return Spi_complete; return Spi_complete;
} }
uint32_t eepromTransmitData(register uint8_t *command, register uint8_t *tx, register uint8_t *rx, register uint32_t comlen, register uint32_t count) uint32_t eepromTransmitData(uint8_t *command, uint8_t *tx, uint8_t *rx, uint32_t comlen, uint32_t count)
{ {
register Spi * spiptr = SPI; Spi * spiptr = SPI;
register uint32_t condition; uint32_t condition;
static uint8_t discard_rx_command[4]; static uint8_t discard_rx_command[4];
if (comlen > 4) { if (comlen > 4) {
@@ -76,8 +76,8 @@ uint32_t eepromTransmitData(register uint8_t *command, register uint8_t *tx, reg
uint8_t eepromTransmitByte(uint8_t out, bool skipFirst) uint8_t eepromTransmitByte(uint8_t out, bool skipFirst)
{ {
register Spi * spiptr = SPI; Spi * spiptr = SPI;
register uint32_t delay; uint32_t delay;
spiptr->SPI_CR = 1; // Enable spiptr->SPI_CR = 1; // Enable
(void) spiptr->SPI_RDR; // Dump any rx data (void) spiptr->SPI_RDR; // Dump any rx data
@@ -172,8 +172,8 @@ void eepromBlockErase(uint32_t address)
// Set clock to 3 MHz, AT25 device is rated to 70MHz, 18MHz would be better // Set clock to 3 MHz, AT25 device is rated to 70MHz, 18MHz would be better
void eepromInit() void eepromInit()
{ {
register Spi * spiptr = SPI; Spi * spiptr = SPI;
register uint32_t timer; uint32_t timer;
PMC->PMC_PCER0 |= 0x00200000L; // Enable peripheral clock to SPI PMC->PMC_PCER0 |= 0x00200000L; // Enable peripheral clock to SPI
/* Configure PIO */ /* Configure PIO */
@@ -190,7 +190,7 @@ void eepromInit()
extern "C" void SPI_IRQHandler() extern "C" void SPI_IRQHandler()
{ {
register Spi * spiptr = SPI; Spi * spiptr = SPI;
SPI->SPI_IDR = 0x07FF; // All interrupts off SPI->SPI_IDR = 0x07FF; // All interrupts off
spiptr->SPI_CR = 2; // Disable spiptr->SPI_CR = 2; // Disable
(void) spiptr->SPI_RDR; // Dump any rx data (void) spiptr->SPI_RDR; // Dump any rx data
+1 -1
View File
@@ -30,7 +30,7 @@ void hapticOff()
// pwmPercent 0-100 // pwmPercent 0-100
void hapticOn( uint32_t pwmPercent ) void hapticOn( uint32_t pwmPercent )
{ {
register Pwm *pwmptr ; Pwm *pwmptr ;
pwmptr = PWM ; pwmptr = PWM ;
+1 -1
View File
@@ -51,7 +51,7 @@ bool i2cInit()
//Enable Peripheral Clock //Enable Peripheral Clock
PMC->PMC_PCER0 |= 0x00080000L; PMC->PMC_PCER0 |= 0x00080000L;
//Enable TWI PIOs //Enable TWI PIOs
register Pio *pioptr; Pio *pioptr;
pioptr = PIOA; pioptr = PIOA;
pioptr->PIO_ABCDSR[0] &= ~0x00000018; // Peripheral A pioptr->PIO_ABCDSR[0] &= ~0x00000018; // Peripheral A
pioptr->PIO_ABCDSR[1] &= ~0x00000018; // Peripheral A pioptr->PIO_ABCDSR[1] &= ~0x00000018; // Peripheral A
+6 -6
View File
@@ -32,8 +32,8 @@
// LCD pins 5 DOWN, 4 RIGHT, 3 LEFT, 1 UP // LCD pins 5 DOWN, 4 RIGHT, 3 LEFT, 1 UP
uint32_t readKeys() uint32_t readKeys()
{ {
register uint32_t x; uint32_t x;
register uint32_t result = 0; uint32_t result = 0;
x = lcdLock ? lcdInputs : PIOC->PIO_PDSR; // 6 LEFT, 5 RIGHT, 4 DOWN, 3 UP () x = lcdLock ? lcdInputs : PIOC->PIO_PDSR; // 6 LEFT, 5 RIGHT, 4 DOWN, 3 UP ()
x = ~x; x = ~x;
@@ -73,7 +73,7 @@ uint32_t readKeys()
uint32_t readTrims() uint32_t readTrims()
{ {
register uint32_t result = 0; uint32_t result = 0;
if (~TRIMS_GPIO_REG_LHL & TRIMS_GPIO_PIN_LHL) if (~TRIMS_GPIO_REG_LHL & TRIMS_GPIO_PIN_LHL)
result |= 0x01; result |= 0x01;
@@ -107,7 +107,7 @@ uint8_t keyDown()
void readKeysAndTrims() void readKeysAndTrims()
{ {
register uint32_t i; uint32_t i;
#if ROTARY_ENCODERS > 0 #if ROTARY_ENCODERS > 0
keys[BTN_REa].input(REA_DOWN()); keys[BTN_REa].input(REA_DOWN());
@@ -135,8 +135,8 @@ uint8_t keyState(uint8_t index)
uint32_t switchState(uint8_t index) uint32_t switchState(uint8_t index)
{ {
register uint32_t a = PIOA->PIO_PDSR; uint32_t a = PIOA->PIO_PDSR;
register uint32_t c = PIOC->PIO_PDSR; uint32_t c = PIOC->PIO_PDSR;
uint32_t xxx = 0; uint32_t xxx = 0;
+10 -10
View File
@@ -71,7 +71,7 @@ const uint8_t Lcd_lookup[] =
void lcdSendCtl(uint8_t val) void lcdSendCtl(uint8_t val)
{ {
register Pio *pioptr; Pio *pioptr;
#if defined(REVA) #if defined(REVA)
pioptr = PIOC; pioptr = PIOC;
@@ -112,7 +112,7 @@ void lcdSendCtl(uint8_t val)
void lcdInit() void lcdInit()
{ {
register Pio *pioptr; Pio *pioptr;
// /home/thus/txt/datasheets/lcd/KS0713.pdf // /home/thus/txt/datasheets/lcd/KS0713.pdf
// ~/txt/flieger/ST7565RV17.pdf from http://www.glyn.de/content.asp?wdid=132&sid= // ~/txt/flieger/ST7565RV17.pdf from http://www.glyn.de/content.asp?wdid=132&sid=
@@ -191,7 +191,7 @@ void lcdInit()
void lcdSetRefVolt(uint8_t val) void lcdSetRefVolt(uint8_t val)
{ {
register Pio *pioptr; Pio *pioptr;
pioptr = PIOC; pioptr = PIOC;
// read the inputs, and lock the LCD lines // read the inputs, and lock the LCD lines
@@ -221,14 +221,14 @@ void lcdSetRefVolt(uint8_t val)
void lcdRefresh() void lcdRefresh()
{ {
register Pio *pioptr; Pio *pioptr;
register uint8_t *p = displayBuf; uint8_t *p = displayBuf;
register uint32_t y; uint32_t y;
register uint32_t x; uint32_t x;
register uint32_t z; uint32_t z;
register uint32_t ebit; uint32_t ebit;
#if defined(REVA) #if defined(REVA)
register uint8_t *lookup; uint8_t *lookup;
lookup = (uint8_t *) Lcd_lookup; lookup = (uint8_t *) Lcd_lookup;
#endif #endif
+13 -13
View File
@@ -22,7 +22,7 @@
void setExternalModulePolarity() void setExternalModulePolarity()
{ {
register Pwm * pwmptr = PWM; Pwm * pwmptr = PWM;
pwmptr->PWM_CH_NUM[3].PWM_CDTYUPD = GET_PPM_DELAY(EXTERNAL_MODULE) * 2; // Duty in half uS pwmptr->PWM_CH_NUM[3].PWM_CDTYUPD = GET_PPM_DELAY(EXTERNAL_MODULE) * 2; // Duty in half uS
if (GET_PPM_POLARITY(EXTERNAL_MODULE)) if (GET_PPM_POLARITY(EXTERNAL_MODULE))
pwmptr->PWM_CH_NUM[3].PWM_CMR &= ~0x00000200; // CPOL pwmptr->PWM_CH_NUM[3].PWM_CMR &= ~0x00000200; // CPOL
@@ -32,7 +32,7 @@ void setExternalModulePolarity()
void setExtraModulePolarity() void setExtraModulePolarity()
{ {
register Pwm * pwmptr = PWM; Pwm * pwmptr = PWM;
pwmptr->PWM_CH_NUM[1].PWM_CDTYUPD = GET_PPM_DELAY(EXTRA_MODULE) * 2; // Duty in half uS pwmptr->PWM_CH_NUM[1].PWM_CDTYUPD = GET_PPM_DELAY(EXTRA_MODULE) * 2; // Duty in half uS
if (GET_PPM_POLARITY(EXTRA_MODULE)) if (GET_PPM_POLARITY(EXTRA_MODULE))
pwmptr->PWM_CH_NUM[1].PWM_CMR &= ~0x00000200; // CPOL pwmptr->PWM_CH_NUM[1].PWM_CMR &= ~0x00000200; // CPOL
@@ -42,7 +42,7 @@ void setExtraModulePolarity()
void module_output_active() void module_output_active()
{ {
register Pio *pioptr = PIOA; Pio *pioptr = PIOA;
pioptr->PIO_ABCDSR[0] &= ~PIO_PA17; // Peripheral C pioptr->PIO_ABCDSR[0] &= ~PIO_PA17; // Peripheral C
pioptr->PIO_ABCDSR[1] |= PIO_PA17; // Peripheral C pioptr->PIO_ABCDSR[1] |= PIO_PA17; // Peripheral C
pioptr->PIO_PDR = PIO_PA17; // Disable bit A17 Assign to peripheral pioptr->PIO_PDR = PIO_PA17; // Disable bit A17 Assign to peripheral
@@ -61,7 +61,7 @@ void module_output_active()
void init_main_ppm(uint32_t period, uint32_t out_enable) void init_main_ppm(uint32_t period, uint32_t out_enable)
{ {
register Pwm * pwmptr; Pwm * pwmptr;
setupPulsesPPMModule(EXTERNAL_MODULE); setupPulsesPPMModule(EXTERNAL_MODULE);
@@ -86,7 +86,7 @@ void init_main_ppm(uint32_t period, uint32_t out_enable)
void disable_main_ppm() void disable_main_ppm()
{ {
register Pio * pioptr = PIOA; Pio * pioptr = PIOA;
pioptr->PIO_PER = PIO_PA17; // Assign A17 to PIO pioptr->PIO_PER = PIO_PA17; // Assign A17 to PIO
PWM->PWM_IDR1 = PWM_IDR1_CHID3; PWM->PWM_IDR1 = PWM_IDR1_CHID3;
} }
@@ -95,7 +95,7 @@ void init_second_ppm(uint32_t period)
{ {
#if !defined(REVA) #if !defined(REVA)
// PWM1 for PPM2 // PWM1 for PPM2
register Pwm * pwmptr = PWM; Pwm * pwmptr = PWM;
configure_pins(PIO_PC15, PIN_PERIPHERAL | PIN_INPUT | PIN_PER_B | PIN_PORTC | PIN_NO_PULLUP ); configure_pins(PIO_PC15, PIN_PERIPHERAL | PIN_INPUT | PIN_PER_B | PIN_PORTC | PIN_NO_PULLUP );
pwmptr->PWM_CH_NUM[1].PWM_CMR = 0x0000000B; // CLKB pwmptr->PWM_CH_NUM[1].PWM_CMR = 0x0000000B; // CLKB
if (!GET_PPM_POLARITY(EXTRA_MODULE)) { if (!GET_PPM_POLARITY(EXTRA_MODULE)) {
@@ -113,7 +113,7 @@ void init_second_ppm(uint32_t period)
void disable_second_ppm() void disable_second_ppm()
{ {
#if !defined(REVA) #if !defined(REVA)
register Pio * pioptr = PIOC; Pio * pioptr = PIOC;
pioptr->PIO_PER = PIO_PC15; // Assign C17 to PIO pioptr->PIO_PER = PIO_PC15; // Assign C17 to PIO
PWM->PWM_IDR1 = PWM_IDR1_CHID1; PWM->PWM_IDR1 = PWM_IDR1_CHID1;
#endif #endif
@@ -163,7 +163,7 @@ void disable_ppm(uint32_t port)
// TD is on PA17, peripheral A // TD is on PA17, peripheral A
void init_ssc() void init_ssc()
{ {
register Ssc * sscptr; Ssc * sscptr;
PMC->PMC_PCER0 |= 0x00400000L; // Enable peripheral clock to SSC PMC->PMC_PCER0 |= 0x00400000L; // Enable peripheral clock to SSC
@@ -185,8 +185,8 @@ void init_ssc()
void disable_ssc() void disable_ssc()
{ {
register Pio *pioptr; Pio *pioptr;
register Ssc *sscptr; Ssc *sscptr;
// Revert back to pwm output // Revert back to pwm output
pioptr = PIOA; pioptr = PIOA;
@@ -243,7 +243,7 @@ void disable_dsm2(uint32_t port)
#if !defined(SIMU) #if !defined(SIMU)
extern "C" void PWM_IRQHandler(void) extern "C" void PWM_IRQHandler(void)
{ {
register Pwm * pwmptr = PWM; Pwm * pwmptr = PWM;
uint32_t reason = pwmptr->PWM_ISR1; uint32_t reason = pwmptr->PWM_ISR1;
uint32_t period; uint32_t period;
@@ -266,7 +266,7 @@ extern "C" void PWM_IRQHandler(void)
} }
else { else {
// Kick off serial output here // Kick off serial output here
register Ssc * sscptr = SSC; Ssc * sscptr = SSC;
sscptr->SSC_TPR = CONVERT_PTR_UINT(modulePulsesData[EXTERNAL_MODULE].pxx.pulses); sscptr->SSC_TPR = CONVERT_PTR_UINT(modulePulsesData[EXTERNAL_MODULE].pxx.pulses);
sscptr->SSC_TCR = (uint8_t *)modulePulsesData[EXTERNAL_MODULE].pxx.ptr - (uint8_t *)modulePulsesData[EXTERNAL_MODULE].pxx.pulses; sscptr->SSC_TCR = (uint8_t *)modulePulsesData[EXTERNAL_MODULE].pxx.ptr - (uint8_t *)modulePulsesData[EXTERNAL_MODULE].pxx.pulses;
sscptr->SSC_PTCR = SSC_PTCR_TXTEN; // Start transfers sscptr->SSC_PTCR = SSC_PTCR_TXTEN; // Start transfers
@@ -290,7 +290,7 @@ extern "C" void PWM_IRQHandler(void)
} }
else { else {
// Kick off serial output here // Kick off serial output here
register Ssc * sscptr = SSC; Ssc * sscptr = SSC;
sscptr->SSC_TPR = CONVERT_PTR_UINT(modulePulsesData[EXTERNAL_MODULE].dsm2.pulses); sscptr->SSC_TPR = CONVERT_PTR_UINT(modulePulsesData[EXTERNAL_MODULE].dsm2.pulses);
sscptr->SSC_TCR = (uint8_t *)modulePulsesData[EXTERNAL_MODULE].dsm2.ptr - (uint8_t *)modulePulsesData[EXTERNAL_MODULE].dsm2.pulses; sscptr->SSC_TCR = (uint8_t *)modulePulsesData[EXTERNAL_MODULE].dsm2.ptr - (uint8_t *)modulePulsesData[EXTERNAL_MODULE].dsm2.pulses;
sscptr->SSC_PTCR = SSC_PTCR_TXTEN; // Start transfers sscptr->SSC_PTCR = SSC_PTCR_TXTEN; // Start transfers
+1 -1
View File
@@ -37,7 +37,7 @@ void rotencEnd()
volatile uint32_t Rotary_position ; volatile uint32_t Rotary_position ;
extern "C" void PIOC_IRQHandler() extern "C" void PIOC_IRQHandler()
{ {
register uint32_t dummy; uint32_t dummy;
dummy = PIOC->PIO_ISR ; // Read and clear status register dummy = PIOC->PIO_ISR ; // Read and clear status register
(void) dummy ; // Discard value - prevents compiler warning (void) dummy ; // Discard value - prevents compiler warning
+1 -1
View File
@@ -62,7 +62,7 @@ uint8_t serial2TracesEnabled()
*/ */
void SECOND_UART_Configure(uint32_t baudrate, uint32_t masterClock) void SECOND_UART_Configure(uint32_t baudrate, uint32_t masterClock)
{ {
register Uart *pUart = SECOND_SERIAL_UART; Uart *pUart = SECOND_SERIAL_UART;
/* Configure PIO */ /* Configure PIO */
configure_pins( (PIO_PA9 | PIO_PA10), PIN_PERIPHERAL | PIN_INPUT | PIN_PER_A | PIN_PORTA | PIN_NO_PULLUP ) ; configure_pins( (PIO_PA9 | PIO_PA10), PIN_PERIPHERAL | PIN_INPUT | PIN_PER_A | PIN_PORTA | PIN_NO_PULLUP ) ;
+8 -8
View File
@@ -36,7 +36,7 @@ uint16_t DsmRxTimeout;
// Uses PA5 and PA6 (RXD and TXD) // Uses PA5 and PA6 (RXD and TXD)
void UART2_Configure(uint32_t baudrate, uint32_t masterClock, int mode) void UART2_Configure(uint32_t baudrate, uint32_t masterClock, int mode)
{ {
register Usart *pUsart = SECOND_USART; Usart *pUsart = SECOND_USART;
// Configure PIO // Configure PIO
configure_pins( (PIO_PA5 | PIO_PA6), PIN_PERIPHERAL | PIN_INPUT | PIN_PER_A | PIN_PORTA | PIN_NO_PULLUP ) ; configure_pins( (PIO_PA5 | PIO_PA6), PIN_PERIPHERAL | PIN_INPUT | PIN_PER_A | PIN_PORTA | PIN_NO_PULLUP ) ;
@@ -66,7 +66,7 @@ void UART2_Configure(uint32_t baudrate, uint32_t masterClock, int mode)
void UART2_timeout_enable() void UART2_timeout_enable()
{ {
register Usart *pUsart = SECOND_USART; Usart *pUsart = SECOND_USART;
pUsart->US_CR = US_CR_STTTO ; pUsart->US_CR = US_CR_STTTO ;
pUsart->US_RTOR = 115 ; // Bits @ 115200 ~= 1mS pUsart->US_RTOR = 115 ; // Bits @ 115200 ~= 1mS
pUsart->US_IER = US_IER_TIMEOUT ; pUsart->US_IER = US_IER_TIMEOUT ;
@@ -76,7 +76,7 @@ void UART2_timeout_enable()
void UART2_timeout_disable() void UART2_timeout_disable()
{ {
register Usart *pUsart = SECOND_USART; Usart *pUsart = SECOND_USART;
pUsart->US_RTOR = 0 ; pUsart->US_RTOR = 0 ;
pUsart->US_IDR = US_IDR_TIMEOUT ; pUsart->US_IDR = US_IDR_TIMEOUT ;
NVIC_DisableIRQ(USART0_IRQn); NVIC_DisableIRQ(USART0_IRQn);
@@ -84,14 +84,14 @@ void UART2_timeout_disable()
extern "C" void USART0_IRQHandler() extern "C" void USART0_IRQHandler()
{ {
register Usart *pUsart = SECOND_USART; Usart *pUsart = SECOND_USART;
pUsart->US_CR = US_CR_STTTO ; // Clears timeout bit pUsart->US_CR = US_CR_STTTO ; // Clears timeout bit
DsmRxTimeout = 1; DsmRxTimeout = 1;
} }
void startPdcUsartReceive() void startPdcUsartReceive()
{ {
register Usart *pUsart = SECOND_USART; Usart *pUsart = SECOND_USART;
TelemetryInBuffer.outPtr = TelemetryInBuffer.fifo ; TelemetryInBuffer.outPtr = TelemetryInBuffer.fifo ;
#ifndef SIMU #ifndef SIMU
pUsart->US_RPR = (uint32_t)TelemetryInBuffer.fifo ; pUsart->US_RPR = (uint32_t)TelemetryInBuffer.fifo ;
@@ -105,7 +105,7 @@ void startPdcUsartReceive()
void rxPdcUsart( void (*pChProcess)(uint8_t x) ) void rxPdcUsart( void (*pChProcess)(uint8_t x) )
{ {
#if !defined(SIMU) #if !defined(SIMU)
register Usart *pUsart = SECOND_USART; Usart *pUsart = SECOND_USART;
uint8_t *ptr ; uint8_t *ptr ;
uint8_t *endPtr ; uint8_t *endPtr ;
@@ -137,7 +137,7 @@ void rxPdcUsart( void (*pChProcess)(uint8_t x) )
uint32_t txPdcUsart(uint8_t *buffer, uint32_t size) uint32_t txPdcUsart(uint8_t *buffer, uint32_t size)
{ {
register Usart *pUsart = SECOND_USART; Usart *pUsart = SECOND_USART;
if ( pUsart->US_TNCR == 0 ) if ( pUsart->US_TNCR == 0 )
{ {
@@ -153,7 +153,7 @@ uint32_t txPdcUsart(uint8_t *buffer, uint32_t size)
uint32_t telemetryTransmitPending() uint32_t telemetryTransmitPending()
{ {
register Usart *pUsart = SECOND_USART; Usart *pUsart = SECOND_USART;
uint32_t x ; uint32_t x ;
__disable_irq() ; __disable_irq() ;
+3 -3
View File
@@ -23,7 +23,7 @@
// Start TIMER3 for input capture // Start TIMER3 for input capture
inline void start_timer3() inline void start_timer3()
{ {
register Tc *ptc ; Tc *ptc ;
// Enable peripheral clock TC0 = bit 23 thru TC5 = bit 28 // Enable peripheral clock TC0 = bit 23 thru TC5 = bit 28
PMC->PMC_PCER0 |= 0x04000000L ; // Enable peripheral clock to TC3 PMC->PMC_PCER0 |= 0x04000000L ; // Enable peripheral clock to TC3
@@ -45,8 +45,8 @@ inline void start_timer3()
// Start Timer4 to provide 0.5uS clock for input capture // Start Timer4 to provide 0.5uS clock for input capture
void start_timer4() void start_timer4()
{ {
register Tc *ptc ; Tc *ptc ;
register uint32_t timer ; uint32_t timer ;
timer = Master_frequency / (2*2000000) ; // MCK/2 and 2MHz timer = Master_frequency / (2*2000000) ; // MCK/2 and 2MHz
+1 -1
View File
@@ -25,7 +25,7 @@ const AudioBuffer * nextBuffer = 0;
void setSampleRate(uint32_t frequency) void setSampleRate(uint32_t frequency)
{ {
register uint32_t timer = (PERI1_FREQUENCY * TIMER_MULT_APB1) / frequency - 1 ; // MCK/8 and 100 000 Hz uint32_t timer = (PERI1_FREQUENCY * TIMER_MULT_APB1) / frequency - 1 ; // MCK/8 and 100 000 Hz
AUDIO_TIMER->CR1 &= ~TIM_CR1_CEN ; AUDIO_TIMER->CR1 &= ~TIM_CR1_CEN ;
AUDIO_TIMER->CNT = 0 ; AUDIO_TIMER->CNT = 0 ;
+12
View File
@@ -27,6 +27,13 @@
extern "C" { extern "C" {
#endif #endif
#if __clang__
// clang is very picky about the use of "register"
// tell it to ignore for the STM32 includes instead of modyfing the orginal files
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-register"
#endif
#if defined(PCBX9E) #if defined(PCBX9E)
#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h" #include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h"
#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_rcc.h" #include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_rcc.h"
@@ -59,6 +66,11 @@ extern "C" {
#include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/misc.h" #include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/misc.h"
#endif #endif
#if __clang__
// Restore warnings about registers
#pragma clang diagnostic pop
#endif
#if !defined(SIMU) #if !defined(SIMU)
#include "usbd_cdc_core.h" #include "usbd_cdc_core.h"
#include "usbd_msc_core.h" #include "usbd_msc_core.h"
+2 -2
View File
@@ -88,7 +88,7 @@ uint8_t keyDown()
#if defined(ROTARY_ENCODER_NAVIGATION) #if defined(ROTARY_ENCODER_NAVIGATION)
void checkRotaryEncoder() void checkRotaryEncoder()
{ {
register uint32_t newpos = ROTARY_ENCODER_POSITION(); uint32_t newpos = ROTARY_ENCODER_POSITION();
if (newpos != rotencPosition) { if (newpos != rotencPosition) {
if ((rotencPosition & 0x01) ^ ((newpos & 0x02) >> 1)) { if ((rotencPosition & 0x01) ^ ((newpos & 0x02) >> 1)) {
--rotencValue[0]; --rotencValue[0];
@@ -168,7 +168,7 @@ uint8_t keyState(uint8_t index)
uint32_t switchState(uint8_t index) uint32_t switchState(uint8_t index)
{ {
register uint32_t xxx = 0; uint32_t xxx = 0;
switch (index) { switch (index) {
ADD_3POS_CASE(A, 0); ADD_3POS_CASE(A, 0);