aboutsummaryrefslogtreecommitdiffstats
path: root/ports
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2008-04-13 17:03:56 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2008-04-13 17:03:56 +0000
commit97ec157b500badfd14f4387ebb8e8a6bf3ac929e (patch)
tree3536a0c3cd7cc1633e4a9ee20ce9264dea80ed61 /ports
parent9e2c8595c8c07d14a2238019a33e00bc08928c92 (diff)
downloadChibiOS-97ec157b500badfd14f4387ebb8e8a6bf3ac929e.tar.gz
ChibiOS-97ec157b500badfd14f4387ebb8e8a6bf3ac929e.tar.bz2
ChibiOS-97ec157b500badfd14f4387ebb8e8a6bf3ac929e.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@263 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'ports')
-rw-r--r--ports/ARMCM3-STM32F103/stm32_serial.c11
-rw-r--r--ports/ARMCM3-STM32F103/stm32_serial.h4
-rw-r--r--ports/ARMCM3/chcore.c1
-rw-r--r--ports/ARMCM3/nvic.c5
-rw-r--r--ports/ARMCM3/nvic.h2
5 files changed, 19 insertions, 4 deletions
diff --git a/ports/ARMCM3-STM32F103/stm32_serial.c b/ports/ARMCM3-STM32F103/stm32_serial.c
index a6150d79d..fdd7c5f77 100644
--- a/ports/ARMCM3-STM32F103/stm32_serial.c
+++ b/ports/ARMCM3-STM32F103/stm32_serial.c
@@ -20,7 +20,9 @@
#include <ch.h>
#include "board.h"
+#include "nvic.h"
#include "stm32_serial.h"
+#include "stm32lib/stm32f10x_nvic.h"
#ifdef USE_USART1
FullDuplexDriver COM1;
@@ -172,16 +174,25 @@ void InitSerial(uint32_t prio1, uint32_t prio2, uint32_t prio3) {
#ifdef USE_USART1
chFDDInit(&COM1, ib1, sizeof ib1, NULL, ob1, sizeof ob1, OutNotify1);
+ GPIOA->CRH = (GPIOA->CRH & 0xFFFFF00F) | 0x000004B0;
+ RCC->APB2ENR |= 0x00002000;
SetUSARTI(USART1, 38400, 0, CR2_STOP1_BITS | CR2_LINEN, 0);
+ NVICEnableVector(USART1_IRQChannel, prio1);
#endif
#ifdef USE_USART2
chFDDInit(&COM2, ib2, sizeof ib2, NULL, ob2, sizeof ob2, OutNotify2);
+ GPIOA->CRL = (GPIOA->CRL & 0xFFFF00FF) | 0x00004B00;
+ RCC->APB1ENR |= 0x00020000;
SetUSARTI(USART2, 38400, 0, CR2_STOP1_BITS | CR2_LINEN, 0);
+ NVICEnableVector(USART2_IRQChannel, prio2);
#endif
#ifdef USE_USART3
chFDDInit(&COM3, ib3, sizeof ib3, NULL, ob3, sizeof ob3, OutNotify3);
+ GPIOB->CRH = (GPIOB->CRH & 0xFFFF00FF) | 0x00004B00;
+ RCC->APB1ENR |= 0x00040000;
SetUSARTI(USART3, 38400, 0, CR2_STOP1_BITS | CR2_LINEN, 0);
+ NVICEnableVector(USART3_IRQChannel, prio3);
#endif
}
diff --git a/ports/ARMCM3-STM32F103/stm32_serial.h b/ports/ARMCM3-STM32F103/stm32_serial.h
index d14270a52..d14e372bd 100644
--- a/ports/ARMCM3-STM32F103/stm32_serial.h
+++ b/ports/ARMCM3-STM32F103/stm32_serial.h
@@ -20,9 +20,9 @@
#ifndef _STM32_SERIAL_H_
#define _STM32_SERIAL_H_
-#define USE_USART1
+//#define USE_USART1
#define USE_USART2
-#define USE_USART3
+//#define USE_USART3
/*
* Configuration parameter, you can change the depth of the queue buffers
diff --git a/ports/ARMCM3/chcore.c b/ports/ARMCM3/chcore.c
index 5a718abc0..25ba2e85f 100644
--- a/ports/ARMCM3/chcore.c
+++ b/ports/ARMCM3/chcore.c
@@ -56,6 +56,7 @@ void chSysSwitchI(Thread *otp, Thread *ntp) {
__attribute__((naked, weak))
void chSysHalt(void) {
+ chSysLock();
while (TRUE) {
}
}
diff --git a/ports/ARMCM3/nvic.c b/ports/ARMCM3/nvic.c
index 5d62ba10b..c36229c9c 100644
--- a/ports/ARMCM3/nvic.c
+++ b/ports/ARMCM3/nvic.c
@@ -20,5 +20,8 @@
#include <ch.h>
#include <nvic.h>
-void SetNVICVector(void) {
+void NVICEnableVector(uint32_t n, uint32_t prio) {
+
+ NVIC_IPR(n >> 2) = (NVIC_IPR(n >> 2) & ~(0xFF << (n & 3))) | (prio << (n & 3));
+ NVIC_ISER(n >> 5) = 1 << (n & 0x1F);
}
diff --git a/ports/ARMCM3/nvic.h b/ports/ARMCM3/nvic.h
index f7d513412..746a8b740 100644
--- a/ports/ARMCM3/nvic.h
+++ b/ports/ARMCM3/nvic.h
@@ -131,7 +131,7 @@ typedef struct {
#ifdef __cplusplus
extern "C" {
#endif
- void SetNVICVector(void);
+ void NVICEnableVector(uint32_t n, uint32_t prio);
#ifdef __cplusplus
}
#endif