aboutsummaryrefslogtreecommitdiffstats
path: root/libmaple
diff options
context:
space:
mode:
Diffstat (limited to 'libmaple')
-rw-r--r--libmaple/adc.c2
-rw-r--r--libmaple/dac.c4
-rw-r--r--libmaple/dac.h4
-rw-r--r--libmaple/exti.c2
-rw-r--r--libmaple/flash.h3
-rw-r--r--libmaple/fsmc.c4
-rw-r--r--libmaple/fsmc.h4
-rw-r--r--libmaple/gpio.c2
-rw-r--r--libmaple/nvic.c2
-rw-r--r--libmaple/nvic.h3
-rw-r--r--libmaple/rcc.h3
-rw-r--r--libmaple/ring_buffer.h3
-rw-r--r--libmaple/spi.h1
-rw-r--r--libmaple/systick.c2
-rw-r--r--libmaple/timers.c2
-rw-r--r--libmaple/usart.c2
-rw-r--r--libmaple/usart.h1
-rw-r--r--libmaple/usb/usb_hardware.c157
-rw-r--r--libmaple/util.c2
19 files changed, 109 insertions, 94 deletions
diff --git a/libmaple/adc.c b/libmaple/adc.c
index 9b21b49..b70c8bd 100644
--- a/libmaple/adc.c
+++ b/libmaple/adc.c
@@ -23,8 +23,6 @@
*****************************************************************************/
/**
- * @file adc.c
- *
* @brief Analog to digital converter routines
*/
diff --git a/libmaple/dac.c b/libmaple/dac.c
index 4c00edb..7f6101d 100644
--- a/libmaple/dac.c
+++ b/libmaple/dac.c
@@ -27,6 +27,10 @@
#include "gpio.h"
#include "dac.h"
+/**
+ * @brief DAC peripheral routines.
+ */
+
/* Only one, so global to this file */
DAC_Map *dac = (DAC_Map*)(DAC_BASE);
diff --git a/libmaple/dac.h b/libmaple/dac.h
index 17b67b7..9c84f2e 100644
--- a/libmaple/dac.h
+++ b/libmaple/dac.h
@@ -26,6 +26,10 @@
* See ../notes/dac.txt for more info
*/
+/**
+ * @file dac.h
+ */
+
#ifndef _DAC_H_
#define _DAC_H_
diff --git a/libmaple/exti.c b/libmaple/exti.c
index acd7c94..496f0a1 100644
--- a/libmaple/exti.c
+++ b/libmaple/exti.c
@@ -23,8 +23,6 @@
*****************************************************************************/
/**
- * @file exti.c
- *
* @brief External interrupt control routines
*/
diff --git a/libmaple/flash.h b/libmaple/flash.h
index 54bda0e..7b74c83 100644
--- a/libmaple/flash.h
+++ b/libmaple/flash.h
@@ -24,7 +24,8 @@
/**
- * @brief basic stm32 flash setup routines
+ * @file flash.h
+ * @brief basic stm32 flash setup routines
*/
#ifndef _FLASH_H_
diff --git a/libmaple/fsmc.c b/libmaple/fsmc.c
index 301a90d..49526f4 100644
--- a/libmaple/fsmc.c
+++ b/libmaple/fsmc.c
@@ -22,6 +22,10 @@
* THE SOFTWARE.
*****************************************************************************/
+/**
+ * @brief
+ */
+
#include "libmaple.h"
#include "rcc.h"
#include "gpio.h"
diff --git a/libmaple/fsmc.h b/libmaple/fsmc.h
index 471cad1..e83b529 100644
--- a/libmaple/fsmc.h
+++ b/libmaple/fsmc.h
@@ -26,6 +26,10 @@
* See ../notes/fsmc.txt for more info
*/
+/**
+ * @file fsmc.h
+ */
+
#ifndef _FSMC_H_
#define _FSMC_H_
diff --git a/libmaple/gpio.c b/libmaple/gpio.c
index f7aee2b..3940837 100644
--- a/libmaple/gpio.c
+++ b/libmaple/gpio.c
@@ -23,8 +23,6 @@
*****************************************************************************/
/**
- * @file gpio.c
- *
* @brief GPIO initialization routine
*/
diff --git a/libmaple/nvic.c b/libmaple/nvic.c
index 5b32d16..fc77054 100644
--- a/libmaple/nvic.c
+++ b/libmaple/nvic.c
@@ -23,8 +23,6 @@
*****************************************************************************/
/**
- * @file nvic.c
- *
* @brief Nested interrupt controller routines
*/
diff --git a/libmaple/nvic.h b/libmaple/nvic.h
index 3cdac5a..d99e57d 100644
--- a/libmaple/nvic.h
+++ b/libmaple/nvic.h
@@ -23,7 +23,8 @@
*****************************************************************************/
/**
- * @brief Nested interrupt controller defines and prototypes
+ * @file nvic.h
+ * @brief Nested interrupt controller defines and prototypes
*/
#ifndef _NVIC_H_
diff --git a/libmaple/rcc.h b/libmaple/rcc.h
index f245fe9..a12f4b4 100644
--- a/libmaple/rcc.h
+++ b/libmaple/rcc.h
@@ -23,7 +23,8 @@
*****************************************************************************/
/**
- * @brief reset and clock control definitions and prototypes
+ * @file rcc.h
+ * @brief reset and clock control definitions and prototypes
*/
#ifndef _RCC_H_
diff --git a/libmaple/ring_buffer.h b/libmaple/ring_buffer.h
index 6a54747..aa4f83f 100644
--- a/libmaple/ring_buffer.h
+++ b/libmaple/ring_buffer.h
@@ -1,5 +1,6 @@
/**
- * @brief simple circular buffer
+ * @file ring_buffer.h
+ * @brief simple circular buffer
*/
#ifndef _RING_BUFFER_H_
diff --git a/libmaple/spi.h b/libmaple/spi.h
index d1973c5..db8aa9c 100644
--- a/libmaple/spi.h
+++ b/libmaple/spi.h
@@ -23,6 +23,7 @@
*****************************************************************************/
/**
+ * @file spi.h
* @brief libmaple serial peripheral interface (SPI) prototypes and
* declarations
*/
diff --git a/libmaple/systick.c b/libmaple/systick.c
index 12a3e22..7935cc0 100644
--- a/libmaple/systick.c
+++ b/libmaple/systick.c
@@ -23,8 +23,6 @@
*****************************************************************************/
/**
- * @file systick.c
- *
* @brief System timer interrupt handler and initialization routines
*/
diff --git a/libmaple/timers.c b/libmaple/timers.c
index 04bfa9f..5b97e20 100644
--- a/libmaple/timers.c
+++ b/libmaple/timers.c
@@ -23,8 +23,6 @@
*****************************************************************************/
/**
- * @file timers.c
- *
* @brief General timer routines
*/
diff --git a/libmaple/usart.c b/libmaple/usart.c
index 34095f8..e63e8f6 100644
--- a/libmaple/usart.c
+++ b/libmaple/usart.c
@@ -23,8 +23,6 @@
*****************************************************************************/
/**
- * @file usart.c
- *
* @brief USART control routines
*/
diff --git a/libmaple/usart.h b/libmaple/usart.h
index 593fb8f..49978e9 100644
--- a/libmaple/usart.h
+++ b/libmaple/usart.h
@@ -23,6 +23,7 @@
*****************************************************************************/
/**
+ * @file usart.h
* @brief USART definitions and prototypes
*/
diff --git a/libmaple/usb/usb_hardware.c b/libmaple/usb/usb_hardware.c
index 2f37df6..d0cd693 100644
--- a/libmaple/usb/usb_hardware.c
+++ b/libmaple/usb/usb_hardware.c
@@ -1,4 +1,4 @@
-/* *****************************************************************************
+/******************************************************************************
* The MIT License
*
* Copyright (c) 2010 LeafLabs LLC.
@@ -20,10 +20,10 @@
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
- * ****************************************************************************/
+*****************************************************************************/
/**
- * @file hardware.c
+ * @file usb_hardware.c
*
* @brief init routines to setup clocks and interrupts for usb.
*
@@ -32,97 +32,106 @@
#include "usb_hardware.h"
void setPin(u32 bank, u8 pin) {
- u32 pinMask = 0x1 << (pin);
- SET_REG(GPIO_BSRR(bank),pinMask);
+ u32 pinMask = 0x1 << (pin);
+ SET_REG(GPIO_BSRR(bank),pinMask);
}
void resetPin(u32 bank, u8 pin) {
- u32 pinMask = 0x1 << (16+pin);
- SET_REG(GPIO_BSRR(bank),pinMask);
+ u32 pinMask = 0x1 << (16+pin);
+ SET_REG(GPIO_BSRR(bank),pinMask);
}
void systemReset(void) {
- SET_REG(RCC_CR, GET_REG(RCC_CR) | 0x00000001);
- SET_REG(RCC_CFGR, GET_REG(RCC_CFGR) & 0xF8FF0000);
- SET_REG(RCC_CR, GET_REG(RCC_CR) & 0xFEF6FFFF);
- SET_REG(RCC_CR, GET_REG(RCC_CR) & 0xFFFBFFFF);
- SET_REG(RCC_CFGR, GET_REG(RCC_CFGR) & 0xFF80FFFF);
+ SET_REG(RCC_CR, GET_REG(RCC_CR) | 0x00000001);
+ SET_REG(RCC_CFGR, GET_REG(RCC_CFGR) & 0xF8FF0000);
+ SET_REG(RCC_CR, GET_REG(RCC_CR) & 0xFEF6FFFF);
+ SET_REG(RCC_CR, GET_REG(RCC_CR) & 0xFFFBFFFF);
+ SET_REG(RCC_CFGR, GET_REG(RCC_CFGR) & 0xFF80FFFF);
- SET_REG(RCC_CIR, 0x00000000); /* disable all RCC interrupts */
+ SET_REG(RCC_CIR, 0x00000000); // disable all RCC interrupts
}
void setupCLK (void) {
- /* enable HSE */
- SET_REG(RCC_CR,GET_REG(RCC_CR) | 0x00010001);
- while ((GET_REG(RCC_CR) & 0x00020000) == 0); /* for it to come on */
-
- /* Configure PLL */
- SET_REG(RCC_CFGR,GET_REG(RCC_CFGR) | 0x001D0400); /* pll=72Mhz,APB1=36Mhz,AHB=72Mhz */
- SET_REG(RCC_CR,GET_REG(RCC_CR) | 0x01000000); /* enable the pll */
- while ((GET_REG(RCC_CR) & 0x03000000) == 0); /* wait for it to come on */
-
- /* Set SYSCLK as PLL */
- SET_REG(RCC_CFGR,GET_REG(RCC_CFGR) | 0x00000002);
- while ((GET_REG(RCC_CFGR) & 0x00000008) == 0); /* wait for it to come on */
+ /* enable HSE */
+ SET_REG(RCC_CR,GET_REG(RCC_CR) | 0x00010001);
+ /* for it to come on */
+ while ((GET_REG(RCC_CR) & 0x00020000) == 0);
+
+ /* Configure PLL */
+ /* pll=72Mhz,APB1=36Mhz,AHB=72Mhz */
+ SET_REG(RCC_CFGR,GET_REG(RCC_CFGR) | 0x001D0400);
+ /* enable the pll */
+ SET_REG(RCC_CR,GET_REG(RCC_CR) | 0x01000000);
+ /* wait for it to come on */
+ while ((GET_REG(RCC_CR) & 0x03000000) == 0);
+
+ /* Set SYSCLK as PLL */
+ SET_REG(RCC_CFGR,GET_REG(RCC_CFGR) | 0x00000002);
+ /* wait for it to come on */
+ while ((GET_REG(RCC_CFGR) & 0x00000008) == 0);
}
void nvicInit(NVIC_InitTypeDef* NVIC_InitStruct) {
- u32 tmppriority = 0x00;
- u32 tmpreg = 0x00;
- u32 tmpmask = 0x00;
- u32 tmppre = 0;
- u32 tmpsub = 0x0F;
-
- SCB_TypeDef* rSCB = (SCB_TypeDef *) SCB_BASE;
- NVIC_TypeDef* rNVIC = (NVIC_TypeDef *) NVIC_BASE;
-
-
- /* Compute the Corresponding IRQ Priority --------------------------------*/
- tmppriority = (0x700 - (rSCB->AIRCR & (u32)0x700))>> 0x08;
- tmppre = (0x4 - tmppriority);
- tmpsub = tmpsub >> tmppriority;
-
- tmppriority = (u32)NVIC_InitStruct->NVIC_IRQChannelPreemptionPriority << tmppre;
- tmppriority |= NVIC_InitStruct->NVIC_IRQChannelSubPriority & tmpsub;
-
- tmppriority = tmppriority << 0x04;
- tmppriority = ((u32)tmppriority) << ((NVIC_InitStruct->NVIC_IRQChannel & (u8)0x03) * 0x08);
-
- tmpreg = rNVIC->IPR[(NVIC_InitStruct->NVIC_IRQChannel >> 0x02)];
- tmpmask = (u32)0xFF << ((NVIC_InitStruct->NVIC_IRQChannel & (u8)0x03) * 0x08);
- tmpreg &= ~tmpmask;
- tmppriority &= tmpmask;
- tmpreg |= tmppriority;
-
- rNVIC->IPR[(NVIC_InitStruct->NVIC_IRQChannel >> 0x02)] = tmpreg;
-
- /* Enable the Selected IRQ Channels --------------------------------------*/
- rNVIC->ISER[(NVIC_InitStruct->NVIC_IRQChannel >> 0x05)] =
- (u32)0x01 << (NVIC_InitStruct->NVIC_IRQChannel & (u8)0x1F);
+ u32 tmppriority = 0x00;
+ u32 tmpreg = 0x00;
+ u32 tmpmask = 0x00;
+ u32 tmppre = 0;
+ u32 tmpsub = 0x0F;
+
+ SCB_TypeDef* rSCB = (SCB_TypeDef *) SCB_BASE;
+ NVIC_TypeDef* rNVIC = (NVIC_TypeDef *) NVIC_BASE;
+
+
+ /* Compute the Corresponding IRQ Priority -------------------------------*/
+ tmppriority = (0x700 - (rSCB->AIRCR & (u32)0x700))>> 0x08;
+ tmppre = (0x4 - tmppriority);
+ tmpsub = tmpsub >> tmppriority;
+
+ tmppriority = (u32)NVIC_InitStruct->NVIC_IRQChannelPreemptionPriority <<
+ tmppre;
+ tmppriority |= NVIC_InitStruct->NVIC_IRQChannelSubPriority & tmpsub;
+
+ tmppriority = tmppriority << 0x04;
+ tmppriority = ((u32)tmppriority) <<
+ ((NVIC_InitStruct->NVIC_IRQChannel & (u8)0x03) * 0x08);
+
+ tmpreg = rNVIC->IPR[(NVIC_InitStruct->NVIC_IRQChannel >> 0x02)];
+ tmpmask = (u32)0xFF <<
+ ((NVIC_InitStruct->NVIC_IRQChannel & (u8)0x03) * 0x08);
+ tmpreg &= ~tmpmask;
+ tmppriority &= tmpmask;
+ tmpreg |= tmppriority;
+
+ rNVIC->IPR[(NVIC_InitStruct->NVIC_IRQChannel >> 0x02)] = tmpreg;
+
+ /* Enable the Selected IRQ Channels -------------------------------------*/
+ rNVIC->ISER[(NVIC_InitStruct->NVIC_IRQChannel >> 0x05)] =
+ (u32)0x01 << (NVIC_InitStruct->NVIC_IRQChannel & (u8)0x1F);
}
void nvicDisableInterrupts() {
- NVIC_TypeDef* rNVIC = (NVIC_TypeDef *) NVIC_BASE;
- rNVIC->ICER[0] = 0xFFFFFFFF;
- rNVIC->ICER[1] = 0xFFFFFFFF;
- rNVIC->ICPR[0] = 0xFFFFFFFF;
- rNVIC->ICPR[1] = 0xFFFFFFFF;
-
- SET_REG(STK_CTRL,0x04); /* disable the systick, which operates separately from nvic */
+ NVIC_TypeDef* rNVIC = (NVIC_TypeDef *) NVIC_BASE;
+ rNVIC->ICER[0] = 0xFFFFFFFF;
+ rNVIC->ICER[1] = 0xFFFFFFFF;
+ rNVIC->ICPR[0] = 0xFFFFFFFF;
+ rNVIC->ICPR[1] = 0xFFFFFFFF;
+
+ /* Disable the systick timer, which operates separately from NVIC */
+ SET_REG(STK_CTRL,0x04);
}
void systemHardReset(void) {
- SCB_TypeDef* rSCB = (SCB_TypeDef *) SCB_BASE;
- typedef void (*funcPtr)(void);
-
- /* Reset */
- rSCB->AIRCR = (u32)AIRCR_RESET_REQ;
-
- /* should never get here */
- while (1) {
- asm volatile("nop");
- }
+ SCB_TypeDef* rSCB = (SCB_TypeDef *) SCB_BASE;
+ typedef void (*funcPtr)(void);
+
+ /* Reset */
+ rSCB->AIRCR = (u32)AIRCR_RESET_REQ;
+
+ /* Should never get here */
+ while (1) {
+ asm volatile("nop");
+ }
}
diff --git a/libmaple/util.c b/libmaple/util.c
index be29e7e..135f005 100644
--- a/libmaple/util.c
+++ b/libmaple/util.c
@@ -23,8 +23,6 @@
*****************************************************************************/
/**
- * @file util.h
- *
* @brief Utility procedures for debugging, mostly an error LED fade
* and messages dumped over a uart for failed asserts.
*/