Browse Source

Initial support for Netduino

This also fixes up the IRQ for the PYBOARD4 USERSW
although I was unable to test that functionality.
pull/259/head
Dave Hylands 11 years ago
parent
commit
1570a96cad
  1. 5
      stm/lcd.c
  2. 21
      stm/main.c
  3. 52
      stm/mpconfigport.h
  4. 39
      stm/stm32fxxx_it.c
  5. 4
      stm/stmperiph/stm324x7i_eval.h
  6. 2
      stm/stmusb/usb_bsp.c
  7. 2
      stm/usrsw.c

5
stm/lcd.c

@ -4,6 +4,9 @@
#include "nlr.h"
#include "misc.h"
#include "mpconfig.h"
#if MICROPY_HW_HAS_LCD
#include "qstr.h"
#include "parse.h"
#include "obj.h"
@ -378,3 +381,5 @@ void lcd_print_strn(const char *str, unsigned int len) {
sys_tick_delay_ms(50);
}
}
#endif // MICROPY_HW_HAS_LCD

21
stm/main.c

@ -602,6 +602,27 @@ int main(void) {
GPIO_Init(GPIOD, &GPIO_InitStructure);
}
#endif
#if defined(NETDUINO_PLUS_2)
{
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_25MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
#if MICROPY_HW_HAS_SDCARD
// Turn on the power enable for the sdcard (PB1)
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;
GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIO_WriteBit(GPIOB, GPIO_Pin_1, Bit_SET);
#endif
// Turn on the power for the 5V on the expansion header (PB2)
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIO_WriteBit(GPIOB, GPIO_Pin_2, Bit_SET);
}
#endif
// basic sub-system init
sys_tick_init();

52
stm/mpconfigport.h

@ -26,6 +26,7 @@ machine_float_t machine_sqrt(machine_float_t x);
//#define PYBOARD3
#define PYBOARD4
//#define STM32F4DISC
//#define NETDUINO_PLUS_2
#if defined (PYBOARD3)
#define MICROPY_HW_BOARD_NAME "PYBv3"
@ -90,7 +91,7 @@ machine_float_t machine_sqrt(machine_float_t x);
#define USRSW_EXTI_PIN (EXTI_PinSource3)
#define USRSW_EXTI_PORT (EXTI_PortSourceGPIOB)
#define USRSW_EXTI_LINE (EXTI_Line3)
#define USRSW_EXTI_IRQN (EXTI15_10_IRQn)
#define USRSW_EXTI_IRQN (EXTI3_IRQn)
#define USRSW_EXTI_EDGE (EXTI_Trigger_Rising)
/* LED */
@ -153,10 +154,59 @@ machine_float_t machine_sqrt(machine_float_t x);
#define PYB_LED_ON(port, pin) (port->BSRRL = pin)
#define PYB_LED_OFF(port, pin) (port->BSRRH = pin)
#elif defined (NETDUINO_PLUS_2)
#define MICROPY_HW_BOARD_NAME "NetduinoPlus2"
#define MICROPY_HW_HAS_SWITCH (1)
// On the netuino, the sdcard appears to be wired up as a 1-bit
// SPI, so the driver needs to be converted to support that before
// we can turn this on.
#define MICROPY_HW_HAS_SDCARD (0)
#define MICROPY_HW_HAS_MMA7660 (0)
#define MICROPY_HW_HAS_LIS3DSH (0)
#define MICROPY_HW_HAS_LCD (0)
#define MICROPY_HW_HAS_WLAN (0)
#define MICROPY_HW_ENABLE_RNG (1)
#define MICROPY_HW_ENABLE_RTC (0)
#define MICROPY_HW_ENABLE_TIMER (1)
#define MICROPY_HW_ENABLE_SERVO (1)
#define MICROPY_HW_ENABLE_AUDIO (0)
#define USRSW_PORT (GPIOB)
#define USRSW_PIN (GPIO_Pin_11)
#define USRSW_PUPD (GPIO_PuPd_NOPULL)
#define USRSW_EXTI_PIN (EXTI_PinSource11)
#define USRSW_EXTI_PORT (EXTI_PortSourceGPIOB)
#define USRSW_EXTI_LINE (EXTI_Line11)
#define USRSW_EXTI_IRQN (EXTI15_10_IRQn)
#define USRSW_EXTI_EDGE (EXTI_Trigger_Rising)
/* LED */
#define PYB_LED1_PORT (GPIOA) // Blue LED
#define PYB_LED1_PIN (GPIO_Pin_10)
#define PYB_LED2_PORT (GPIOC) // White LED (aka Power)
#define PYB_LED2_PIN (GPIO_Pin_13)
#define PYB_LED3_PORT (GPIOA) // Same as Led(1)
#define PYB_LED3_PIN (GPIO_Pin_10)
#define PYB_LED4_PORT (GPIOC) // Same as Led(2)
#define PYB_LED4_PIN (GPIO_Pin_13)
#define PYB_OTYPE (GPIO_OType_PP)
#define PYB_LED_ON(port, pin) (port->BSRRL = pin)
#define PYB_LED_OFF(port, pin) (port->BSRRH = pin)
#define HSE_VALUE (25000000)
#endif
#define STM32F40_41xxx
#define USE_STDPERIPH_DRIVER
#if !defined(HSE_VALUE)
#define HSE_VALUE (8000000)
#endif
#define USE_DEVICE_MODE
//#define USE_HOST_MODE

39
stm/stm32fxxx_it.c

@ -290,14 +290,21 @@ void TIM6_DAC_IRQHandler(void) {
#include "qstr.h"
#include "obj.h"
#include "led.h"
void Default_Handler(void); // Found in startup_stm32f40xx.s
// EXTI
// for USRSW on A13
// for USRSW on A13 for PYBOARD3, and B11 for NETDUINO_PLUS_2
// for cc3000 on A14
void EXTI15_10_IRQHandler(void) {
// work out if it's A13 that had the interrupt
if (EXTI_GetITStatus(EXTI_Line13) != RESET) {
// this is used just to wake the device
EXTI_ClearITPendingBit(EXTI_Line13);
// work out if it's the user switch that had the interrupt
// Note that if the user switch is on a diffetent IRQ, then this code
// should be optimized out.
if (USRSW_EXTI_IRQN == EXTI15_10_IRQn) {
if (EXTI_GetITStatus(USRSW_EXTI_LINE) != RESET) {
// this is used just to wake the device
EXTI_ClearITPendingBit(USRSW_EXTI_LINE);
}
}
// work out if it's A14 that had the interrupt
if (EXTI_GetITStatus(EXTI_Line14) != RESET) {
@ -319,10 +326,24 @@ void EXTI15_10_IRQHandler(void) {
}
}
#if defined(STM32F4DISC)
// STM32F4DISC is setup for A0
void EXTI0_IRQHandler(void) {
// clear pending interrupt bit
EXTI_ClearITPendingBit(EXTI_Line0);
if (USRSW_EXTI_IRQN == EXTI0_IRQn) {
// this is used just to wake the device
EXTI_ClearITPendingBit(USRSW_EXTI_LINE);
} else {
Default_Handler();
}
}
#endif
// PYBOARD4 has button on PB3
void EXTI3_IRQHandler(void) {
if (USRSW_EXTI_IRQN == EXTI3_IRQn) {
// this is used just to wake the device
EXTI_ClearITPendingBit(USRSW_EXTI_LINE);
} else {
Default_Handler();
}
}
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

4
stm/stmperiph/stm324x7i_eval.h

@ -54,6 +54,10 @@
#define SD_DETECT_PIN GPIO_Pin_15 /* PB.15 */
#define SD_DETECT_GPIO_PORT GPIOB /* GPIOB */
#define SD_DETECT_GPIO_CLK RCC_AHB1Periph_GPIOB
#elif defined(NETDUINO_PLUS_2)
#define SD_DETECT_PIN GPIO_Pin_5 /* PB.5 */
#define SD_DETECT_GPIO_PORT GPIOB /* GPIOB */
#define SD_DETECT_GPIO_CLK RCC_AHB1Periph_GPIOB
#endif
#define SDIO_FIFO_ADDRESS ((uint32_t)0x40012C80)

2
stm/stmusb/usb_bsp.c

@ -117,6 +117,7 @@ void USB_OTG_BSP_Init(USB_OTG_CORE_HANDLE *pdev) {
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ;
GPIO_Init(GPIOA, &GPIO_InitStructure);
#if !defined(NETDUINO_PLUS_2)
// Configure ID pin on PA10
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
@ -125,6 +126,7 @@ void USB_OTG_BSP_Init(USB_OTG_CORE_HANDLE *pdev) {
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP ;
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_PinAFConfig(GPIOA, GPIO_PinSource10, GPIO_AF_OTG_FS);
#endif
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
RCC_AHB2PeriphClockCmd(RCC_AHB2Periph_OTG_FS, ENABLE);

2
stm/usrsw.c

@ -52,7 +52,7 @@ int switch_get(void) {
// pulled low, so switch is pressed
return 1;
}
#elif defined (STM32F4DISC)
#elif defined (STM32F4DISC) || defined(NETDUINO_PLUS_2)
/* switch pulled down */
if (USRSW_PORT->IDR & USRSW_PIN) {
// pulled high, so switch is pressed

Loading…
Cancel
Save