STBee Mini support.
authorNIIBE Yutaka <gniibe@fsij.org>
Fri, 22 Oct 2010 03:56:40 +0000 (12:56 +0900)
committerNIIBE Yutaka <gniibe@fsij.org>
Fri, 22 Oct 2010 03:56:40 +0000 (12:56 +0900)
AUTHORS
ChangeLog
ChibiOS_2.0.2/os/hal/platforms/STM32/hal_lld.c
boards/STBEE_MINI/board.c [new file with mode: 0644]
boards/STBEE_MINI/board.h [new file with mode: 0644]
boards/STBEE_MINI/board.mk [new file with mode: 0644]
boards/STBEE_MINI/mcuconf.h [new file with mode: 0644]
src/configure

diff --git a/AUTHORS b/AUTHORS
index d229970..b392da2 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -7,6 +7,11 @@ Kaz Kojima:
 
 NIIBE Yutaka:
     Founder of the project.
+    Added STBee Mini support:
+       boards/STBEE_MINI/board.c
+       boards/STBEE_MINI/board.h
+       boards/STBEE_MINI/board.mk
+       boards/STBEE_MINI/mcuconf.h
     Added CQ STARM support:
        boards/CQ_STARM/board.c
        boards/CQ_STARM/board.h
index e760986..0e03322 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2010-10-22  NIIBE Yutaka  <gniibe@fsij.org>
+
+       * src/configure: Added STBee Mini support.
+       * boards/STBEE_MINI/mcuconf.h: New.
+       * boards/STBEE_MINI/board.mk: New.
+       * boards/STBEE_MINI/board.h: New.
+       * boards/STBEE_MINI/board.c: New.
+
+       * ChibiOS_2.0.2/os/hal/platforms/STM32/hal_lld.c
+       (pal_default_config): STBee Mini uses STM32F103CBT6 which expose
+       no GPIO E port.
+
 2010-10-21  NIIBE Yutaka  <gniibe@fsij.org>
 
        * boards/common/hw_config.c (Get_SerialNum): Removed.
index 8c11816..07d04a5 100644 (file)
@@ -55,7 +55,7 @@ const PALConfig pal_default_config =
   {VAL_GPIOBODR, VAL_GPIOBCRL, VAL_GPIOBCRH},
   {VAL_GPIOCODR, VAL_GPIOCCRL, VAL_GPIOCCRH},
   {VAL_GPIODODR, VAL_GPIODCRL, VAL_GPIODCRH},
-#if !defined(STM32F10X_LD)
+#if !defined(STM32F10X_LD) && !defined(BOARD_STBEE_MINI)
   {VAL_GPIOEODR, VAL_GPIOECRL, VAL_GPIOECRH},
 #endif
 #if defined(STM32F10X_HD)
diff --git a/boards/STBEE_MINI/board.c b/boards/STBEE_MINI/board.c
new file mode 100644 (file)
index 0000000..17ce9e4
--- /dev/null
@@ -0,0 +1,41 @@
+#include "config.h"
+#include "ch.h"
+#include "hal.h"
+
+#include "../common/hwinit.c"
+
+void
+hwinit0 (void)
+{
+  hwinit0_common ();
+}
+
+void
+hwinit1 (void)
+{
+  hwinit1_common ();
+  /*
+   * Disable JTAG and SWD, done after hwinit1_common as HAL resets AFIO
+   */
+  AFIO->MAPR |= AFIO_MAPR_SWJ_CFG_DISABLE;
+  /* We use LED2 as optional "error" indicator */
+  palSetPad (IOPORT1, GPIOA_LED2);
+}
+
+void
+USB_Cable_Config (FunctionalState NewState)
+{
+  if (NewState != DISABLE)
+    palSetPad (IOPORT1, GPIOA_USB_ENABLE);
+  else
+    palClearPad (IOPORT1, GPIOA_USB_ENABLE);
+}
+
+void
+set_led (int value)
+{
+  if (value)
+    palClearPad (IOPORT1, GPIOA_LED1);
+  else
+    palSetPad (IOPORT1, GPIOA_LED1);
+}
diff --git a/boards/STBEE_MINI/board.h b/boards/STBEE_MINI/board.h
new file mode 100644 (file)
index 0000000..0607ddc
--- /dev/null
@@ -0,0 +1,127 @@
+/*
+    ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio.
+
+    This file is part of ChibiOS/RT.
+
+    ChibiOS/RT is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 3 of the License, or
+    (at your option) any later version.
+
+    ChibiOS/RT is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+                                      ---
+
+    A special exception to the GPL can be applied should you wish to distribute
+    a combined work that includes ChibiOS/RT, without being obliged to provide
+    the source code for any proprietary components. See the file exception.txt
+    for full details of how and when the exception can be applied.
+*/
+
+#ifndef _BOARD_H_
+#define _BOARD_H_
+
+/*
+ * Setup for the STBee Mini board.
+ */
+
+/*
+ * Board identifier.
+ */
+#define BOARD_STBEE_MINI
+#define BOARD_NAME "STBee Mini"
+
+/*
+ * Board frequencies.
+ */
+#define STM32_LSECLK            32768
+#define STM32_HSECLK            12000000
+
+/*
+ * MCU type, this macro is used by both the ST library and the ChibiOS/RT
+ * native STM32 HAL.
+ */
+#define STM32F10X_MD
+
+/*
+ * IO pins assignments.
+ */
+#define GPIOA_LED1              13
+#define GPIOA_USB_ENABLE        14
+#define GPIOA_LED2              15
+
+#define GPIOC_BUTTON            13
+
+/*
+ * I/O ports initial setup, this configuration is established soon after reset
+ * in the initialization code.
+ *
+ * The digits have the following meaning:
+ *   0 - Analog input.
+ *   1 - Push Pull output 10MHz.
+ *   2 - Push Pull output 2MHz.
+ *   3 - Push Pull output 50MHz.
+ *   4 - Digital input.
+ *   5 - Open Drain output 10MHz.
+ *   6 - Open Drain output 2MHz.
+ *   7 - Open Drain output 50MHz.
+ *   8 - Digital input with PullUp or PullDown resistor depending on ODR.
+ *   9 - Alternate Push Pull output 10MHz.
+ *   A - Alternate Push Pull output 2MHz.
+ *   B - Alternate Push Pull output 50MHz.
+ *   C - Reserved.
+ *   D - Alternate Open Drain output 10MHz.
+ *   E - Alternate Open Drain output 2MHz.
+ *   F - Alternate Open Drain output 50MHz.
+ * Please refer to the STM32 Reference Manual for details.
+ */
+
+/*
+ * Port A setup.
+ * PA11 - input with pull-up (USBDM)
+ * PA12 - input with pull-up (USBDP)
+ * Everything input with pull-up except:
+ * PA13 - Open Drain output (LED1 0:ON 1:OFF)
+ * PA14 - Push pull output  (USB ENABLE 0:DISABLE 1:ENABLE)
+ * PA15 - Open Drain output (LED2 0:ON 1:OFF)
+ */
+#define VAL_GPIOACRL            0x88888888      /*  PA7...PA0 */
+#define VAL_GPIOACRH            0x73788888      /* PA15...PA8 */
+#define VAL_GPIOAODR            0xFFFFFFFF
+
+/*
+ * Port B setup.
+ * Everything input with pull-up except:
+ */
+#define VAL_GPIOBCRL            0x88888888      /*  PB7...PB0 */
+#define VAL_GPIOBCRH            0x88888888      /* PB15...PB8 */
+#define VAL_GPIOBODR            0xFFFFFFFF
+
+/*
+ * Port C setup.
+ * Everything input with pull-up except:
+ * PC13 - Normal input.
+ * PC14 - Normal input.
+ * PC15 - Normal input.
+ */
+#define VAL_GPIOCCRL            0x88888888      /*  PC7...PC0 */
+#define VAL_GPIOCCRH            0x44488888      /* PC15...PC8 */
+#define VAL_GPIOCODR            0xFFFFFFFF
+
+/*
+ * Port D setup.
+ * Everything input with pull-up except:
+ * PD0  - Normal input (XTAL).
+ * PD1  - Normal input (XTAL).
+ */
+#define VAL_GPIODCRL            0x88888844      /*  PD7...PD0 */
+#define VAL_GPIODCRH            0x88888888      /* PD15...PD8 */
+#define VAL_GPIODODR            0xFFFFFFFF
+
+#endif /* _BOARD_H_ */
diff --git a/boards/STBEE_MINI/board.mk b/boards/STBEE_MINI/board.mk
new file mode 100644 (file)
index 0000000..7f05e87
--- /dev/null
@@ -0,0 +1,6 @@
+# List of all the board related files.
+BOARDSRC = ../boards/STBEE_MINI/board.c \
+       ../boards/common/hw_config.c
+
+# Required include directories
+BOARDINC = ../boards/STBEE_MINI
diff --git a/boards/STBEE_MINI/mcuconf.h b/boards/STBEE_MINI/mcuconf.h
new file mode 100644 (file)
index 0000000..ea0f434
--- /dev/null
@@ -0,0 +1,107 @@
+/*
+    ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio.
+
+    This file is part of ChibiOS/RT.
+
+    ChibiOS/RT is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 3 of the License, or
+    (at your option) any later version.
+
+    ChibiOS/RT is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+                                      ---
+
+    A special exception to the GPL can be applied should you wish to distribute
+    a combined work that includes ChibiOS/RT, without being obliged to provide
+    the source code for any proprietary components. See the file exception.txt
+    for full details of how and when the exception can be applied.
+*/
+
+/*
+ * STM32 drivers configuration.
+ * The following settings override the default settings present in
+ * the various device driver implementation headers.
+ * Note that the settings for each driver only have effect if the driver
+ * is enabled in halconf.h.
+ *
+ * IRQ priorities:
+ * 15...0       Lowest...Highest.
+ *
+ * DMA priorities:
+ * 0...3        Lowest...Highest.
+ */
+
+/*
+ * HAL driver system settings.
+ */
+#define STM32_SW                    STM32_SW_PLL
+#define STM32_PLLSRC                STM32_PLLSRC_HSE
+#define STM32_PLLXTPRE              STM32_PLLXTPRE_DIV1
+#define STM32_PLLMUL_VALUE          6
+#define STM32_HPRE                  STM32_HPRE_DIV1
+#define STM32_PPRE1                 STM32_PPRE1_DIV2
+#define STM32_PPRE2                 STM32_PPRE2_DIV2
+#define STM32_ADCPRE                STM32_ADCPRE_DIV4
+#define STM32_MCO                   STM32_MCO_NOCLOCK
+
+/*
+ * ADC driver system settings.
+ */
+#define USE_STM32_ADC1              TRUE
+#define STM32_ADC1_DMA_PRIORITY     3
+#define STM32_ADC1_IRQ_PRIORITY     5
+#define STM32_ADC1_DMA_ERROR_HOOK() chSysHalt()
+
+/*
+ * CAN driver system settings.
+ */
+#define USE_STM32_CAN1              TRUE
+#define STM32_CAN1_IRQ_PRIORITY     11
+
+/*
+ * PWM driver system settings.
+ */
+#define USE_STM32_PWM1              TRUE
+#define USE_STM32_PWM2              FALSE
+#define USE_STM32_PWM3              FALSE
+#define USE_STM32_PWM4              FALSE
+#define STM32_PWM1_IRQ_PRIORITY     7
+#define STM32_PWM2_IRQ_PRIORITY     7
+#define STM32_PWM3_IRQ_PRIORITY     7
+#define STM32_PWM4_IRQ_PRIORITY     7
+
+/*
+ * SERIAL driver system settings.
+ */
+#define USE_STM32_USART1            FALSE
+#define USE_STM32_USART2            TRUE
+#define USE_STM32_USART3            FALSE
+#if defined(STM32F10X_HD) || defined(STM32F10X_CL)
+#define USE_STM32_UART4             FALSE
+#define USE_STM32_UART5             FALSE
+#endif
+#define STM32_USART1_PRIORITY       12
+#define STM32_USART2_PRIORITY       12
+#define STM32_USART3_PRIORITY       12
+#if defined(STM32F10X_HD) || defined(STM32F10X_CL)
+#define STM32_UART4_PRIORITY        12
+#define STM32_UART5_PRIORITY        12
+#endif
+
+/*
+ * SPI driver system settings.
+ */
+#define USE_STM32_SPI1              TRUE
+#define USE_STM32_SPI2              FALSE
+#define STM32_SPI1_DMA_PRIORITY     2
+#define STM32_SPI2_DMA_PRIORITY     2
+#define STM32_SPI1_IRQ_PRIORITY     10
+#define STM32_SPI2_IRQ_PRIORITY     10
+#define STM32_SPI1_DMA_ERROR_HOOK() chSysHalt()
index 9988d52..d33d9a6 100755 (executable)
@@ -80,6 +80,7 @@ Configuration:
                           OLIMEX_STM32_H103
                           STM32_PRIMER2
                           CQ_STARM
+                          STBEE_MINI
   --enable-debug       debug with virtual COM port     [no]
   --with-dfu           build image for DFU             [<target specific>]
   --with-fsij          Use FSIJ serial number          [no: random number]
@@ -97,7 +98,7 @@ fi
 
 # --with-dfu option
 case $target in
-CQ_STARM)
+CQ_STARM|STBEE_MINI)
   if test "$with_dfu" = "default"; then
     with_dfu=yes;
   fi  ;;
@@ -109,11 +110,13 @@ esac
 
 # --with-fsij option
 if test "$with_fsij" = "no"; then
+  echo "Using random serial number for card AID"
   FSIJ_DEFINE="#undef WITH_FSIJ_SERIAL_NUMBER"
   SERIAL_NUMBER_FOUR_BYTES=`od -t u1 -N 4 /dev/random | sed -n -e '/^0000000/s/^0000000  *//' -e 's/  */,/gp'`
 else
+  echo "Using FSIJ assigned serial number for card AID"
   if test "x$MAIL" = "x"; then
-    echo "Please set MAIL shell variable to select FSIJ serial number." >&2
+    echo "ERROR: Please set MAIL shell variable to select FSIJ serial number" >&2
     exit 1
   fi
   FSIJ_DEFINE="#define WITH_FSIJ_SERIAL_NUMBER 1"