From: Kevin Townsend Date: Fri, 8 Jun 2012 04:07:06 +0000 (+0200) Subject: Prep for v1.1.0 X-Git-Url: https://git.rohieb.name/hackover2013-badge-firmware.git/commitdiff_plain/dff476a9010ac763a0595615e3e32f5f48afbc03 Prep for v1.1.0 --- diff --git a/build/crossworks/LPC1343_CodeBase.hzp b/build/crossworks/LPC1343_CodeBase.hzp index 636619f..962314b 100644 --- a/build/crossworks/LPC1343_CodeBase.hzp +++ b/build/crossworks/LPC1343_CodeBase.hzp @@ -104,6 +104,9 @@ + + + diff --git a/build/crossworks/LPC1343_CodeBase.hzs b/build/crossworks/LPC1343_CodeBase.hzs index 61c5d6a..256ccb4 100644 --- a/build/crossworks/LPC1343_CodeBase.hzs +++ b/build/crossworks/LPC1343_CodeBase.hzs @@ -1,7 +1,9 @@ - + + + @@ -24,12 +26,9 @@ - - - - + @@ -62,14 +61,7 @@ - - - - - - - - + - + diff --git a/core/gpio/gpio.c b/core/gpio/gpio.c index e13f72e..fe80dbc 100644 --- a/core/gpio/gpio.c +++ b/core/gpio/gpio.c @@ -227,67 +227,6 @@ void gpioSetDir (uint32_t portNum, uint32_t bitPos, gpioDirection_t dir) dir == gpioDirection_Output ? (*gpiodir |= (1 << bitPos)) : (*gpiodir &= ~(1 << bitPos)); } -/**************************************************************************/ -/*! - @brief Gets the value for a specific port pin - - @param[in] portNum - The port number (0..3) - @param[in] bitPos - The bit position (0..31) - - @return The current value for the specified port pin (0..1) -*/ -/**************************************************************************/ -uint32_t gpioGetValue (uint32_t portNum, uint32_t bitPos) -{ - if (!_gpioInitialised) gpioInit(); - - uint32_t value = 0; - - switch (portNum) - { - case 0: - value = (GPIO_GPIO0DATA & (1 << bitPos)) ? 1 : 0; - break; - case 1: - value = (GPIO_GPIO1DATA & (1 << bitPos)) ? 1 : 0; - break; - case 2: - value = (GPIO_GPIO2DATA & (1 << bitPos)) ? 1 : 0; - break; - case 3: - value = (GPIO_GPIO3DATA & (1 << bitPos)) ? 1 : 0; - break; - default: - break; - } - - return value; -} - -/**************************************************************************/ -/*! - @brief Sets the value for a specific port pin (only relevant when a - pin is configured as output). - - @param[in] portNum - The port number (0..3) - @param[in] bitPos - The bit position (0..31) - @param[in] bitValue - The value to set for the specified bit (0..1). 0 will set - the pin low and 1 will set the pin high. -*/ -/**************************************************************************/ -inline void gpioSetValue (const uint32_t portNum, const uint32_t bitPos, const uint32_t bitVal) -{ - if (!_gpioInitialised) gpioInit(); - - // Take advantage of the fact the GPIO registers are bit-banded - (*(pREG32 ((GPIO_GPIO0_BASE + (portNum << 16)) + ((1 << bitPos) << 2)))) = bitVal ? 0xFFF : 0; -} - /**************************************************************************/ /*! @brief Sets the interrupt sense, event, etc. diff --git a/core/gpio/gpio.h b/core/gpio/gpio.h index 7a0e47f..ed616d2 100644 --- a/core/gpio/gpio.h +++ b/core/gpio/gpio.h @@ -99,8 +99,6 @@ gpioPullupMode_t; void gpioInit ( void ); void gpioSetDir ( uint32_t portNum, uint32_t bitPos, gpioDirection_t dir ); -uint32_t gpioGetValue ( uint32_t portNum, uint32_t bitPos ); -extern void gpioSetValue ( const uint32_t portNum, const uint32_t bitPos, const uint32_t bitVal ); void gpioSetInterrupt ( uint32_t portNum, uint32_t bitPos, gpioInterruptSense_t sense, gpioInterruptEdge_t edge, gpioInterruptEvent_t event ); void gpioIntEnable ( uint32_t portNum, uint32_t bitPos ); void gpioIntDisable ( uint32_t portNum, uint32_t bitPos ); @@ -108,4 +106,46 @@ uint32_t gpioIntStatus ( uint32_t portNum, uint32_t bitPos ); void gpioIntClear ( uint32_t portNum, uint32_t bitPos ); void gpioSetPullup ( volatile uint32_t *ioconRegister, gpioPullupMode_t mode ); +/* Inline Functions */ +INLINE uint32_t gpioGetValue ( const uint32_t portNum, const uint32_t bitPos ) INLINE_POST; +INLINE void gpioSetValue ( const uint32_t portNum, const uint32_t bitPos, const uint32_t bitVal) INLINE_POST; + +/**************************************************************************/ +/*! + @brief Gets the value for a specific port pin + + @param[in] portNum + The port number (0..3) + @param[in] bitPos + The bit position (0..31) + + @return The current value for the specified port pin (0..1) +*/ +/**************************************************************************/ +INLINE uint32_t gpioGetValue (uint32_t portNum, uint32_t bitPos) +{ + // Take advantage of the fact the GPIO registers are bit-banded + return (*(pREG32 ((GPIO_GPIO0_BASE + (portNum << 16)) + ((1 << bitPos) << 2)))) & (1 << bitPos) ? 1 : 0; +} + +/**************************************************************************/ +/*! + @brief Sets the value for a specific port pin (only relevant when a + pin is configured as output). + + @param[in] portNum + The port number (0..3) + @param[in] bitPos + The bit position (0..31) + @param[in] bitValue + The value to set for the specified bit (0..1). 0 will set + the pin low and 1 will set the pin high. +*/ +/**************************************************************************/ +INLINE void gpioSetValue (uint32_t portNum, uint32_t bitPos, uint32_t bitVal) +{ + // Take advantage of the fact the GPIO registers are bit-banded + (*(pREG32 ((GPIO_GPIO0_BASE + (portNum << 16)) + ((1 << bitPos) << 2)))) = bitVal ? 0xFFF : 0; +} + #endif \ No newline at end of file diff --git a/core/ssp/ssp.c b/core/ssp/ssp.c index b6beef2..e1f31e2 100644 --- a/core/ssp/ssp.c +++ b/core/ssp/ssp.c @@ -179,7 +179,7 @@ void sspInit (uint8_t portNum, sspClockPolarity_t polarity, sspClockPhase_t phas gpioSetValue(SSP0_CSPORT, SSP0_CSPIN, 1); gpioSetPullup(&IOCON_PIO0_2, gpioPullupMode_Inactive); // Board has external pull-up - /* If SSP0CLKDIV = DIV1 -- (PCLK / (CPSDVSR � [SCR+1])) = (72,000,000 / (2 x [8 + 1])) = 4.0 MHz */ + /* If SSP0CLKDIV = DIV1 -- (PCLK / (CPSDVSR * [SCR+1])) = (72,000,000 / (2 x [8 + 1])) = 4.0 MHz */ uint32_t configReg = ( SSP_SSP0CR0_DSS_8BIT // Data size = 8-bit | SSP_SSP0CR0_FRF_SPI // Frame format = SPI | SSP_SSP0CR0_SCR_8); // Serial clock rate = 8 diff --git a/drivers/dac/mcp4725/mcp4725.c b/drivers/dac/mcp4725/mcp4725.c index 7b9c6ac..1699eb7 100644 --- a/drivers/dac/mcp4725/mcp4725.c +++ b/drivers/dac/mcp4725/mcp4725.c @@ -19,7 +19,7 @@ // Request the current value from the DAC uint8_t status = 0; uint16_t value = 0; - mcp472ReadConfig(&status, &value); + mcp4725ReadConfig(&status, &value); @endcode @@ -135,7 +135,7 @@ void mcp4725SetVoltage( uint16_t output, bool writeEEPROM ) Pointer to hold the output value of the 12-bit DAC */ /**************************************************************************/ -void mcp472ReadConfig( uint8_t *status, uint16_t *value ) +void mcp4725ReadConfig( uint8_t *status, uint16_t *value ) { if (!_mcp4725Initialised) mcp4725Init(); diff --git a/drivers/dac/mcp4725/mcp4725.h b/drivers/dac/mcp4725/mcp4725.h index bb91b3e..42ba362 100644 --- a/drivers/dac/mcp4725/mcp4725.h +++ b/drivers/dac/mcp4725/mcp4725.h @@ -47,6 +47,6 @@ int mcp4725Init(); void mcp4725SetVoltage( uint16_t output, bool writeEEPROM ); -void mcp472ReadConfig( uint8_t *status, uint16_t *value ); +void mcp4725ReadConfig( uint8_t *status, uint16_t *value ); #endif \ No newline at end of file diff --git a/sysdefs.h b/sysdefs.h index 9b786b4..4f2ebb0 100644 --- a/sysdefs.h +++ b/sysdefs.h @@ -43,6 +43,24 @@ #include #include +#ifndef ASM +# define ASM __asm volatile +#endif + +#ifndef INLINE +# if __GNUC__ && !__GNUC_STDC_INLINE__ +# define INLINE extern inline +# else +# define INLINE inline +# endif +#endif + +// GCC does not inline any functions when not optimizing unless you specify +// the 'always_inline' attribute for the function +#ifndef INLINE_POST +# define INLINE_POST __attribute__((always_inline)) +#endif + // Stay compatible with ugly "windows" style #define BOOL bool