修复mico-sdk错误

This commit is contained in:
nhkefus
2025-03-11 15:54:45 +08:00
parent 3422912129
commit 2ccb892a1c
2152 changed files with 664341 additions and 702636 deletions

View File

@@ -1,39 +1,39 @@
/*###ICF### Section handled by ICF editor, don't touch! ****/
/*-Editor annotation file-*/
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
/*-Specials-*/
define symbol __ICFEDIT_intvec_start__ = 0x08000000;
/*-Memory Regions-*/
define symbol __ICFEDIT_region_ROM_start__ = 0x08000000;
define symbol __ICFEDIT_region_ROM_end__ = 0x08007FFF;
define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
define symbol __ICFEDIT_region_RAM_end__ = 0x20020000;
/*-Sizes-*/
define symbol __ICFEDIT_size_cstack__ = 0x1000;
define symbol __ICFEDIT_size_heap__ = 0x100;
/**** End of ICF editor section. ###ICF###*/
define memory mem with size = 4G;
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
define symbol RAM_intvec_start = 0x20000000;
initialize by copy { readonly, readwrite };
do not initialize { section .noinit };
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
"RAM_intvec_start":
place at address mem:RAM_intvec_start { section .intvec_RAM };
"ROM_region":
place in ROM_region { readonly };
"RAM_region":
place in RAM_region { readwrite,
/*###ICF### Section handled by ICF editor, don't touch! ****/
/*-Editor annotation file-*/
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
/*-Specials-*/
define symbol __ICFEDIT_intvec_start__ = 0x08000000;
/*-Memory Regions-*/
define symbol __ICFEDIT_region_ROM_start__ = 0x08000000;
define symbol __ICFEDIT_region_ROM_end__ = 0x08007FFF;
define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
define symbol __ICFEDIT_region_RAM_end__ = 0x20020000;
/*-Sizes-*/
define symbol __ICFEDIT_size_cstack__ = 0x1000;
define symbol __ICFEDIT_size_heap__ = 0x100;
/**** End of ICF editor section. ###ICF###*/
define memory mem with size = 4G;
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
define symbol RAM_intvec_start = 0x20000000;
initialize by copy { readonly, readwrite };
do not initialize { section .noinit };
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
"RAM_intvec_start":
place at address mem:RAM_intvec_start { section .intvec_RAM };
"ROM_region":
place in ROM_region { readonly };
"RAM_region":
place in RAM_region { readwrite,
block CSTACK, block HEAP };

View File

@@ -1,20 +1,20 @@
; *************************************************************
; *** Scatter-Loading Description File generated by uVision ***
; *************************************************************
LR_IROM1 0x08000000 0x00004000 {
ER_IROM1 0x08000000 0x00004000
{
*.o (RESET, +First)
*(InRoot$$Sections)
startup_stm32f2xx_bootloader_RVMDK.o
}
ER_IROM2 0x20000000 0x00008000 {
.ANY (+RO)
}
RW_IRAM1 0x20008000 0x00012000
{
.ANY (+RW +ZI)
}
}
; *************************************************************
; *** Scatter-Loading Description File generated by uVision ***
; *************************************************************
LR_IROM1 0x08000000 0x00004000 {
ER_IROM1 0x08000000 0x00004000
{
*.o (RESET, +First)
*(InRoot$$Sections)
startup_stm32f2xx_bootloader_RVMDK.o
}
ER_IROM2 0x20000000 0x00008000 {
.ANY (+RO)
}
RW_IRAM1 0x20008000 0x00012000
{
.ANY (+RW +ZI)
}
}

View File

@@ -1,33 +1,33 @@
/**
******************************************************************************
*
* The MIT License
* Copyright (c) 2016 MXCHIP Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is furnished
* to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 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.
******************************************************************************
*/
MEMORY
{
BL_FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 32K
PAR_1 (rwx) : ORIGIN = 0x08008000, LENGTH = 16K
PAR_2 (rwx) : ORIGIN = 0x0800C000, LENGTH = 16K
APP_FLASH (rx) : ORIGIN = 0x08010000, LENGTH = 320K
SRAM (rwx) : ORIGIN = 0x20000000, LENGTH = 128K
/**
******************************************************************************
*
* The MIT License
* Copyright (c) 2016 MXCHIP Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is furnished
* to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 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.
******************************************************************************
*/
MEMORY
{
BL_FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 32K
PAR_1 (rwx) : ORIGIN = 0x08008000, LENGTH = 16K
PAR_2 (rwx) : ORIGIN = 0x0800C000, LENGTH = 16K
APP_FLASH (rx) : ORIGIN = 0x08010000, LENGTH = 320K
SRAM (rwx) : ORIGIN = 0x20000000, LENGTH = 128K
}

View File

@@ -1,30 +1,30 @@
/*###ICF### Section handled by ICF editor, don't touch! ****/
/*-Editor annotation file-*/
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
/*-Specials-*/
define symbol __ICFEDIT_intvec_start__ = 0x08010000;
/*-Memory Regions-*/
define symbol __ICFEDIT_region_ROM_start__ = 0x08010000;
define symbol __ICFEDIT_region_ROM_end__ = 0x080FFFFF;
define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
define symbol __ICFEDIT_region_RAM_end__ = 0x2001FFFF;
/*-Sizes-*/
define symbol __ICFEDIT_size_cstack__ = 0x200;
define symbol __ICFEDIT_size_heap__ = 0x14A00;
/**** End of ICF editor section. ###ICF###*/
define memory mem with size = 4G;
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
initialize by copy { readwrite };
do not initialize { section .noinit };
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
place in ROM_region { readonly };
place in RAM_region { readwrite,
/*###ICF### Section handled by ICF editor, don't touch! ****/
/*-Editor annotation file-*/
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
/*-Specials-*/
define symbol __ICFEDIT_intvec_start__ = 0x08010000;
/*-Memory Regions-*/
define symbol __ICFEDIT_region_ROM_start__ = 0x08010000;
define symbol __ICFEDIT_region_ROM_end__ = 0x080FFFFF;
define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
define symbol __ICFEDIT_region_RAM_end__ = 0x2001FFFF;
/*-Sizes-*/
define symbol __ICFEDIT_size_cstack__ = 0x200;
define symbol __ICFEDIT_size_heap__ = 0x14A00;
/**** End of ICF editor section. ###ICF###*/
define memory mem with size = 4G;
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
initialize by copy { readwrite };
do not initialize { section .noinit };
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
place in ROM_region { readonly };
place in RAM_region { readwrite,
block CSTACK, block HEAP };

View File

@@ -1,487 +1,487 @@
/**
******************************************************************************
* @file platform.c
* @author William Xu
* @version V1.0.0
* @date 05-May-2014
* @brief This file provides all MICO Peripherals mapping table and platform
* specific functions.
******************************************************************************
*
* The MIT License
* Copyright (c) 2014 MXCHIP Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is furnished
* to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 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.
******************************************************************************
*/
#include "stdio.h"
#include "string.h"
#include "platform.h"
#include "platform_config.h"
#include "platform_peripheral.h"
#include "platform_logging.h"
#include "mico_platform.h"
#include "wlan_platform_common.h"
#include "button.h"
/******************************************************
* Macros
******************************************************/
/******************************************************
* Constants
******************************************************/
/******************************************************
* Enumerations
******************************************************/
/******************************************************
* Type Definitions
******************************************************/
/******************************************************
* Structures
******************************************************/
/******************************************************
* Function Declarations
******************************************************/
extern WEAK void PlatformEasyLinkButtonClickedCallback(void);
extern WEAK void PlatformStandbyButtonClickedCallback(void);
extern WEAK void PlatformEasyLinkButtonLongPressedCallback(void);
extern WEAK void bootloader_start(void);
/******************************************************
* Variables Definitions
******************************************************/
const platform_gpio_t platform_gpio_pins[] =
{
/* Common GPIOs for internal use */
[MICO_SYS_LED] = { GPIOB, 0 },
[MICO_RF_LED] = { GPIOB, 1 }, //MICO_GPIO_16
[BOOT_SEL] = { GPIOB, 1 }, //MICO_GPIO_16
[MFG_SEL] = { GPIOB, 9 }, //MICO_GPIO_30
[EasyLink_BUTTON] = { GPIOA, 1 }, //MICO_GPIO_11
/* GPIOs for external use */
[MICO_GPIO_1] = { GPIOB, 6 },
[MICO_GPIO_2] = { GPIOB, 7 },
[MICO_GPIO_4] = { GPIOC, 7 },
[MICO_GPIO_5] = { GPIOA, 4 },
[MICO_GPIO_6] = { GPIOA, 4 },
[MICO_GPIO_7] = { GPIOB, 3 },
[MICO_GPIO_8] = { GPIOB , 4 },
[MICO_GPIO_9] = { GPIOB, 5 },
[MICO_GPIO_10] = { GPIOB, 8 },
[MICO_GPIO_12] = { GPIOC, 2 },
[MICO_GPIO_13] = { GPIOB, 14 },
[MICO_GPIO_14] = { GPIOC, 6 },
[MICO_GPIO_18] = { GPIOA, 15 },
[MICO_GPIO_19] = { GPIOB, 11 },
[MICO_GPIO_20] = { GPIOA, 12 },
[MICO_GPIO_21] = { GPIOA, 11 },
[MICO_GPIO_22] = { GPIOA, 9 },
[MICO_GPIO_23] = { GPIOA, 10 },
[MICO_GPIO_29] = { GPIOA, 0 },
};
/*
* Possible compile time inputs:
* - Set which ADC peripheral to use for each ADC. All on one ADC allows sequential conversion on all inputs. All on separate ADCs allows concurrent conversion.
*/
/* TODO : These need fixing */
const platform_adc_t platform_adc_peripherals[] =
{
[MICO_ADC_1] = {ADC1, ADC_Channel_1, RCC_APB2Periph_ADC1, 1, &platform_gpio_pins[MICO_GPIO_2]},
[MICO_ADC_2] = {ADC1, ADC_Channel_2, RCC_APB2Periph_ADC1, 1, &platform_gpio_pins[MICO_GPIO_4]},
[MICO_ADC_3] = {ADC1, ADC_Channel_3, RCC_APB2Periph_ADC1, 1, &platform_gpio_pins[MICO_GPIO_5]},
};
/* PWM mappings */
const platform_pwm_t platform_pwm_peripherals[] =
{
[MICO_PWM_1] = {TIM4, 3, RCC_APB1Periph_TIM4, GPIO_AF_TIM4, &platform_gpio_pins[MICO_GPIO_10]}, /* or TIM10/Ch1 */
[MICO_PWM_2] = {TIM12, 1, RCC_APB1Periph_TIM12, GPIO_AF_TIM12, &platform_gpio_pins[MICO_GPIO_13]}, /* or TIM1/Ch2N */
[MICO_PWM_3] = {TIM2, 4, RCC_APB1Periph_TIM2, GPIO_AF_TIM2, &platform_gpio_pins[MICO_GPIO_19]},
/* TODO: fill in the other options here ... */
};
const platform_spi_t platform_spi_peripherals[] =
{
[MICO_SPI_1] =
{
.port = SPI1,
.gpio_af = GPIO_AF_SPI1,
.peripheral_clock_reg = RCC_APB2Periph_SPI1,
.peripheral_clock_func = RCC_APB2PeriphClockCmd,
.pin_mosi = &platform_gpio_pins[MICO_GPIO_9],
.pin_miso = &platform_gpio_pins[MICO_GPIO_8],
.pin_clock = &platform_gpio_pins[MICO_GPIO_7],
.tx_dma =
{
.controller = DMA2,
.stream = DMA2_Stream5,
.channel = DMA_Channel_3,
.irq_vector = DMA2_Stream5_IRQn,
.complete_flags = DMA_HISR_TCIF5,
.error_flags = ( DMA_HISR_TEIF5 | DMA_HISR_FEIF5 | DMA_HISR_DMEIF5 ),
},
.rx_dma =
{
.controller = DMA2,
.stream = DMA2_Stream0,
.channel = DMA_Channel_3,
.irq_vector = DMA2_Stream0_IRQn,
.complete_flags = DMA_LISR_TCIF0,
.error_flags = ( DMA_LISR_TEIF0 | DMA_LISR_FEIF0 | DMA_LISR_DMEIF0 ),
},
}
};
platform_spi_driver_t platform_spi_drivers[MICO_SPI_MAX];
const platform_uart_t platform_uart_peripherals[] =
{
[MICO_UART_1] =
{
.port = USART1,
.pin_tx = &platform_gpio_pins[MICO_GPIO_22],
.pin_rx = &platform_gpio_pins[MICO_GPIO_23],
.pin_cts = &platform_gpio_pins[MICO_GPIO_21],
.pin_rts = &platform_gpio_pins[MICO_GPIO_20],
.tx_dma_config =
{
.controller = DMA2,
.stream = DMA2_Stream7,
.channel = DMA_Channel_4,
.irq_vector = DMA2_Stream7_IRQn,
.complete_flags = DMA_HISR_TCIF7,
.error_flags = ( DMA_HISR_TEIF7 | DMA_HISR_FEIF7 ),
},
.rx_dma_config =
{
.controller = DMA2,
.stream = DMA2_Stream2,
.channel = DMA_Channel_4,
.irq_vector = DMA2_Stream2_IRQn,
.complete_flags = DMA_LISR_TCIF2,
.error_flags = ( DMA_LISR_TEIF2 | DMA_LISR_FEIF2 | DMA_LISR_DMEIF2 ),
},
},
[MICO_UART_2] =
{
.port = USART6,
.pin_tx = &platform_gpio_pins[MICO_GPIO_14],
.pin_rx = &platform_gpio_pins[MICO_GPIO_4],
.pin_cts = NULL,
.pin_rts = NULL,
.tx_dma_config =
{
.controller = DMA2,
.stream = DMA2_Stream6,
.channel = DMA_Channel_5,
.irq_vector = DMA2_Stream6_IRQn,
.complete_flags = DMA_HISR_TCIF6,
.error_flags = ( DMA_HISR_TEIF6 | DMA_HISR_FEIF6 ),
},
.rx_dma_config =
{
.controller = DMA2,
.stream = DMA2_Stream1,
.channel = DMA_Channel_5,
.irq_vector = DMA2_Stream1_IRQn,
.complete_flags = DMA_LISR_TCIF1,
.error_flags = ( DMA_LISR_TEIF1 | DMA_LISR_FEIF1 | DMA_LISR_DMEIF1 ),
},
},
};
platform_uart_driver_t platform_uart_drivers[MICO_UART_MAX];
const platform_i2c_t platform_i2c_peripherals[] =
{
[MICO_I2C_1] =
{
.port = I2C1,
.pin_scl = &platform_gpio_pins[MICO_GPIO_1],
.pin_sda = &platform_gpio_pins[MICO_GPIO_2],
.peripheral_clock_reg = RCC_APB1Periph_I2C1,
.tx_dma = DMA1,
.tx_dma_peripheral_clock = RCC_AHB1Periph_DMA1,
.tx_dma_stream = DMA1_Stream7,
.rx_dma_stream = DMA1_Stream0,
.tx_dma_stream_id = 7,
.rx_dma_stream_id = 0,
.tx_dma_channel = DMA_Channel_1,
.rx_dma_channel = DMA_Channel_1,
.gpio_af = GPIO_AF_I2C1
},
};
platform_i2c_driver_t platform_i2c_drivers[MICO_I2C_MAX];
platform_flash_driver_t platform_flash_drivers[MICO_FLASH_MAX];
/* Wi-Fi control pins. Used by platform/MCU/wlan_platform_common.c
* SDIO: EMW1062_PIN_BOOTSTRAP[1:0] = b'00
* gSPI: EMW1062_PIN_BOOTSTRAP[1:0] = b'01
*/
const platform_gpio_t wifi_control_pins[] =
{
[WIFI_PIN_POWER ] = { GPIOC, 1 },
[WIFI_PIN_RESET ] = { GPIOC, 5 },
[WIFI_PIN_32K_CLK ] = { GPIOA, 8 },
[WIFI_PIN_BOOTSTRAP_0] = { GPIOB, 12 },
[WIFI_PIN_BOOTSTRAP_1] = { GPIOB, 13 },
};
/* Wi-Fi SDIO bus pins. Used by platform/MCU/STM32F2xx/EMW1062_driver/wlan_SDIO.c */
const platform_gpio_t wifi_sdio_pins[] =
{
[WIFI_PIN_SDIO_OOB_IRQ] = { GPIOB, 12 },
[WIFI_PIN_SDIO_CLK ] = { GPIOC, 12 },
[WIFI_PIN_SDIO_CMD ] = { GPIOD, 2 },
[WIFI_PIN_SDIO_D0 ] = { GPIOC, 8 },
[WIFI_PIN_SDIO_D1 ] = { GPIOC, 9 },
[WIFI_PIN_SDIO_D2 ] = { GPIOC, 10 },
[WIFI_PIN_SDIO_D3 ] = { GPIOC, 11 },
};
/* Flash memory devices */
const platform_flash_t platform_flash_peripherals[] =
{
[MICO_FLASH_EMBEDDED] =
{
.flash_type = FLASH_TYPE_EMBEDDED,
.flash_start_addr = 0x08000000,
.flash_length = 0x100000,
},
};
platform_flash_driver_t platform_flash_drivers[MICO_FLASH_MAX];
/* Logic partition on flash devices */
const mico_logic_partition_t mico_partitions[] =
{
[MICO_PARTITION_BOOTLOADER] =
{
.partition_owner = MICO_FLASH_EMBEDDED,
.partition_description = "Bootloader",
.partition_start_addr = 0x08000000,
.partition_length = 0x8000, //32k bytes
.partition_options = PAR_OPT_READ_EN | PAR_OPT_WRITE_DIS,
},
[MICO_PARTITION_APPLICATION] =
{
.partition_owner = MICO_FLASH_EMBEDDED,
.partition_description = "Application",
.partition_start_addr = 0x08010000,
.partition_length = 0x50000, //320k bytes
.partition_options = PAR_OPT_READ_EN | PAR_OPT_WRITE_DIS,
},
[MICO_PARTITION_RF_FIRMWARE] =
{
.partition_owner = MICO_FLASH_EMBEDDED,
.partition_description = "RF Firmware",
.partition_start_addr = 0x080C0000,
.partition_length = 0x40000, //256k bytes
.partition_options = PAR_OPT_READ_EN | PAR_OPT_WRITE_DIS,
},
[MICO_PARTITION_OTA_TEMP] =
{
.partition_owner = MICO_FLASH_EMBEDDED,
.partition_description = "OTA Storage",
.partition_start_addr = 0x08060000,
.partition_length = 0x60000, //384k bytes
.partition_options = PAR_OPT_READ_EN | PAR_OPT_WRITE_EN,
},
[MICO_PARTITION_PARAMETER_1] =
{
.partition_owner = MICO_FLASH_EMBEDDED,
.partition_description = "PARAMETER1",
.partition_start_addr = 0x08008000,
.partition_length = 0x4000, // 16k bytes
.partition_options = PAR_OPT_READ_EN | PAR_OPT_WRITE_EN,
},
[MICO_PARTITION_PARAMETER_2] =
{
.partition_owner = MICO_FLASH_EMBEDDED,
.partition_description = "PARAMETER1",
.partition_start_addr = 0x0800C000,
.partition_length = 0x4000, //16k bytes
.partition_options = PAR_OPT_READ_EN | PAR_OPT_WRITE_EN,
},
[MICO_PARTITION_ATE] =
{
.partition_owner = MICO_FLASH_NONE,
}
};
/******************************************************
* Interrupt Handler Definitions
******************************************************/
MICO_RTOS_DEFINE_ISR( USART1_IRQHandler )
{
platform_uart_irq( &platform_uart_drivers[MICO_UART_1] );
}
MICO_RTOS_DEFINE_ISR( USART6_IRQHandler )
{
platform_uart_irq( &platform_uart_drivers[MICO_UART_2] );
}
MICO_RTOS_DEFINE_ISR( DMA2_Stream7_IRQHandler )
{
platform_uart_tx_dma_irq( &platform_uart_drivers[MICO_UART_1] );
}
MICO_RTOS_DEFINE_ISR( DMA2_Stream6_IRQHandler )
{
platform_uart_tx_dma_irq( &platform_uart_drivers[MICO_UART_2] );
}
MICO_RTOS_DEFINE_ISR( DMA2_Stream2_IRQHandler )
{
platform_uart_rx_dma_irq( &platform_uart_drivers[MICO_UART_1] );
}
MICO_RTOS_DEFINE_ISR( DMA2_Stream1_IRQHandler )
{
platform_uart_rx_dma_irq( &platform_uart_drivers[MICO_UART_2] );
}
/******************************************************
* Function Definitions
******************************************************/
static void _button_STANDBY_irq_handler( void* arg )
{
(void)(arg);
PlatformStandbyButtonClickedCallback();
}
bool watchdog_check_last_reset( void )
{
if ( RCC->CSR & RCC_CSR_WDGRSTF )
{
/* Clear the flag and return */
RCC->CSR |= RCC_CSR_RMVF;
return true;
}
return false;
}
void platform_init_peripheral_irq_priorities( void )
{
/* Interrupt priority setup. Called by MiCO/platform/MCU/STM32F2xx/platform_init.c */
NVIC_SetPriority( RTC_WKUP_IRQn , 1 ); /* RTC Wake-up event */
NVIC_SetPriority( SDIO_IRQn , 2 ); /* WLAN SDIO */
NVIC_SetPriority( DMA2_Stream3_IRQn, 3 ); /* WLAN SDIO DMA */
NVIC_SetPriority( DMA1_Stream3_IRQn, 3 ); /* WLAN SPI DMA */
NVIC_SetPriority( USART1_IRQn , 6 ); /* MICO_UART_1 */
NVIC_SetPriority( USART6_IRQn , 6 ); /* MICO_UART_2 */
NVIC_SetPriority( DMA2_Stream7_IRQn, 7 ); /* MICO_UART_1 TX DMA */
NVIC_SetPriority( DMA2_Stream2_IRQn, 7 ); /* MICO_UART_1 RX DMA */
NVIC_SetPriority( DMA2_Stream6_IRQn, 7 ); /* MICO_UART_2 TX DMA */
NVIC_SetPriority( DMA2_Stream1_IRQn, 7 ); /* MICO_UART_2 RX DMA */
NVIC_SetPriority( EXTI0_IRQn , 14 ); /* GPIO */
NVIC_SetPriority( EXTI1_IRQn , 14 ); /* GPIO */
NVIC_SetPriority( EXTI2_IRQn , 14 ); /* GPIO */
NVIC_SetPriority( EXTI3_IRQn , 14 ); /* GPIO */
NVIC_SetPriority( EXTI4_IRQn , 14 ); /* GPIO */
NVIC_SetPriority( EXTI9_5_IRQn , 14 ); /* GPIO */
NVIC_SetPriority( EXTI15_10_IRQn , 14 ); /* GPIO */
}
void init_platform( void )
{
button_init_t init;
MicoGpioInitialize( (mico_gpio_t)MICO_SYS_LED, OUTPUT_PUSH_PULL );
MicoGpioOutputLow( (mico_gpio_t)MICO_SYS_LED );
MicoGpioInitialize( (mico_gpio_t)MICO_RF_LED, OUTPUT_OPEN_DRAIN_NO_PULL );
MicoGpioOutputHigh( (mico_gpio_t)MICO_RF_LED );
// Initialise EasyLink buttons
init.gpio = EasyLink_BUTTON;
init.pressed_func = PlatformEasyLinkButtonClickedCallback;
init.long_pressed_func = PlatformEasyLinkButtonLongPressedCallback;
init.long_pressed_timeout = 5000;
button_init( IOBUTTON_EASYLINK, init );
// Initialise Standby/wakeup switcher
MicoGpioInitialize( Standby_SEL, INPUT_PULL_UP );
MicoGpioEnableIRQ( Standby_SEL , IRQ_TRIGGER_FALLING_EDGE, _button_STANDBY_irq_handler, NULL);
}
void init_platform_bootloader( void )
{
MicoGpioInitialize( (mico_gpio_t)MICO_SYS_LED, OUTPUT_PUSH_PULL );
MicoGpioOutputLow( (mico_gpio_t)MICO_SYS_LED );
MicoGpioInitialize( (mico_gpio_t)MICO_RF_LED, OUTPUT_OPEN_DRAIN_NO_PULL );
MicoGpioOutputHigh( (mico_gpio_t)MICO_RF_LED );
MicoGpioInitialize((mico_gpio_t)BOOT_SEL, INPUT_PULL_UP);
MicoGpioInitialize((mico_gpio_t)MFG_SEL, INPUT_HIGH_IMPEDANCE);
}
void MicoSysLed(bool onoff)
{
if (onoff) {
MicoGpioOutputHigh( (mico_gpio_t)MICO_SYS_LED );
} else {
MicoGpioOutputLow( (mico_gpio_t)MICO_SYS_LED );
}
}
void MicoRfLed(bool onoff)
{
if (onoff)
{
MicoGpioOutputLow( (mico_gpio_t)MICO_RF_LED );
}
else
{
MicoGpioOutputHigh( (mico_gpio_t)MICO_RF_LED );
}
}
bool MicoShouldEnterMFGMode(void)
{
if(MicoGpioInputGet((mico_gpio_t)BOOT_SEL)==false && MicoGpioInputGet((mico_gpio_t)MFG_SEL)==false)
return true;
else
return false;
}
bool MicoShouldEnterBootloader(void)
{
if(MicoGpioInputGet((mico_gpio_t)BOOT_SEL)==false && MicoGpioInputGet((mico_gpio_t)MFG_SEL)==true)
return true;
else
return false;
}
/**
******************************************************************************
* @file platform.c
* @author William Xu
* @version V1.0.0
* @date 05-May-2014
* @brief This file provides all MICO Peripherals mapping table and platform
* specific functions.
******************************************************************************
*
* The MIT License
* Copyright (c) 2014 MXCHIP Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is furnished
* to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 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.
******************************************************************************
*/
#include "stdio.h"
#include "string.h"
#include "platform.h"
#include "platform_config.h"
#include "platform_peripheral.h"
#include "platform_logging.h"
#include "mico_platform.h"
#include "wlan_platform_common.h"
#include "button.h"
/******************************************************
* Macros
******************************************************/
/******************************************************
* Constants
******************************************************/
/******************************************************
* Enumerations
******************************************************/
/******************************************************
* Type Definitions
******************************************************/
/******************************************************
* Structures
******************************************************/
/******************************************************
* Function Declarations
******************************************************/
extern WEAK void PlatformEasyLinkButtonClickedCallback(void);
extern WEAK void PlatformStandbyButtonClickedCallback(void);
extern WEAK void PlatformEasyLinkButtonLongPressedCallback(void);
extern WEAK void bootloader_start(void);
/******************************************************
* Variables Definitions
******************************************************/
const platform_gpio_t platform_gpio_pins[] =
{
/* Common GPIOs for internal use */
[MICO_SYS_LED] = { GPIOB, 0 },
[MICO_RF_LED] = { GPIOB, 1 }, //MICO_GPIO_16
[BOOT_SEL] = { GPIOB, 1 }, //MICO_GPIO_16
[MFG_SEL] = { GPIOB, 9 }, //MICO_GPIO_30
[EasyLink_BUTTON] = { GPIOA, 1 }, //MICO_GPIO_11
/* GPIOs for external use */
[MICO_GPIO_1] = { GPIOB, 6 },
[MICO_GPIO_2] = { GPIOB, 7 },
[MICO_GPIO_4] = { GPIOC, 7 },
[MICO_GPIO_5] = { GPIOA, 4 },
[MICO_GPIO_6] = { GPIOA, 4 },
[MICO_GPIO_7] = { GPIOB, 3 },
[MICO_GPIO_8] = { GPIOB , 4 },
[MICO_GPIO_9] = { GPIOB, 5 },
[MICO_GPIO_10] = { GPIOB, 8 },
[MICO_GPIO_12] = { GPIOC, 2 },
[MICO_GPIO_13] = { GPIOB, 14 },
[MICO_GPIO_14] = { GPIOC, 6 },
[MICO_GPIO_18] = { GPIOA, 15 },
[MICO_GPIO_19] = { GPIOB, 11 },
[MICO_GPIO_20] = { GPIOA, 12 },
[MICO_GPIO_21] = { GPIOA, 11 },
[MICO_GPIO_22] = { GPIOA, 9 },
[MICO_GPIO_23] = { GPIOA, 10 },
[MICO_GPIO_29] = { GPIOA, 0 },
};
/*
* Possible compile time inputs:
* - Set which ADC peripheral to use for each ADC. All on one ADC allows sequential conversion on all inputs. All on separate ADCs allows concurrent conversion.
*/
/* TODO : These need fixing */
const platform_adc_t platform_adc_peripherals[] =
{
[MICO_ADC_1] = {ADC1, ADC_Channel_1, RCC_APB2Periph_ADC1, 1, &platform_gpio_pins[MICO_GPIO_2]},
[MICO_ADC_2] = {ADC1, ADC_Channel_2, RCC_APB2Periph_ADC1, 1, &platform_gpio_pins[MICO_GPIO_4]},
[MICO_ADC_3] = {ADC1, ADC_Channel_3, RCC_APB2Periph_ADC1, 1, &platform_gpio_pins[MICO_GPIO_5]},
};
/* PWM mappings */
const platform_pwm_t platform_pwm_peripherals[] =
{
[MICO_PWM_1] = {TIM4, 3, RCC_APB1Periph_TIM4, GPIO_AF_TIM4, &platform_gpio_pins[MICO_GPIO_10]}, /* or TIM10/Ch1 */
[MICO_PWM_2] = {TIM12, 1, RCC_APB1Periph_TIM12, GPIO_AF_TIM12, &platform_gpio_pins[MICO_GPIO_13]}, /* or TIM1/Ch2N */
[MICO_PWM_3] = {TIM2, 4, RCC_APB1Periph_TIM2, GPIO_AF_TIM2, &platform_gpio_pins[MICO_GPIO_19]},
/* TODO: fill in the other options here ... */
};
const platform_spi_t platform_spi_peripherals[] =
{
[MICO_SPI_1] =
{
.port = SPI1,
.gpio_af = GPIO_AF_SPI1,
.peripheral_clock_reg = RCC_APB2Periph_SPI1,
.peripheral_clock_func = RCC_APB2PeriphClockCmd,
.pin_mosi = &platform_gpio_pins[MICO_GPIO_9],
.pin_miso = &platform_gpio_pins[MICO_GPIO_8],
.pin_clock = &platform_gpio_pins[MICO_GPIO_7],
.tx_dma =
{
.controller = DMA2,
.stream = DMA2_Stream5,
.channel = DMA_Channel_3,
.irq_vector = DMA2_Stream5_IRQn,
.complete_flags = DMA_HISR_TCIF5,
.error_flags = ( DMA_HISR_TEIF5 | DMA_HISR_FEIF5 | DMA_HISR_DMEIF5 ),
},
.rx_dma =
{
.controller = DMA2,
.stream = DMA2_Stream0,
.channel = DMA_Channel_3,
.irq_vector = DMA2_Stream0_IRQn,
.complete_flags = DMA_LISR_TCIF0,
.error_flags = ( DMA_LISR_TEIF0 | DMA_LISR_FEIF0 | DMA_LISR_DMEIF0 ),
},
}
};
platform_spi_driver_t platform_spi_drivers[MICO_SPI_MAX];
const platform_uart_t platform_uart_peripherals[] =
{
[MICO_UART_1] =
{
.port = USART1,
.pin_tx = &platform_gpio_pins[MICO_GPIO_22],
.pin_rx = &platform_gpio_pins[MICO_GPIO_23],
.pin_cts = &platform_gpio_pins[MICO_GPIO_21],
.pin_rts = &platform_gpio_pins[MICO_GPIO_20],
.tx_dma_config =
{
.controller = DMA2,
.stream = DMA2_Stream7,
.channel = DMA_Channel_4,
.irq_vector = DMA2_Stream7_IRQn,
.complete_flags = DMA_HISR_TCIF7,
.error_flags = ( DMA_HISR_TEIF7 | DMA_HISR_FEIF7 ),
},
.rx_dma_config =
{
.controller = DMA2,
.stream = DMA2_Stream2,
.channel = DMA_Channel_4,
.irq_vector = DMA2_Stream2_IRQn,
.complete_flags = DMA_LISR_TCIF2,
.error_flags = ( DMA_LISR_TEIF2 | DMA_LISR_FEIF2 | DMA_LISR_DMEIF2 ),
},
},
[MICO_UART_2] =
{
.port = USART6,
.pin_tx = &platform_gpio_pins[MICO_GPIO_14],
.pin_rx = &platform_gpio_pins[MICO_GPIO_4],
.pin_cts = NULL,
.pin_rts = NULL,
.tx_dma_config =
{
.controller = DMA2,
.stream = DMA2_Stream6,
.channel = DMA_Channel_5,
.irq_vector = DMA2_Stream6_IRQn,
.complete_flags = DMA_HISR_TCIF6,
.error_flags = ( DMA_HISR_TEIF6 | DMA_HISR_FEIF6 ),
},
.rx_dma_config =
{
.controller = DMA2,
.stream = DMA2_Stream1,
.channel = DMA_Channel_5,
.irq_vector = DMA2_Stream1_IRQn,
.complete_flags = DMA_LISR_TCIF1,
.error_flags = ( DMA_LISR_TEIF1 | DMA_LISR_FEIF1 | DMA_LISR_DMEIF1 ),
},
},
};
platform_uart_driver_t platform_uart_drivers[MICO_UART_MAX];
const platform_i2c_t platform_i2c_peripherals[] =
{
[MICO_I2C_1] =
{
.port = I2C1,
.pin_scl = &platform_gpio_pins[MICO_GPIO_1],
.pin_sda = &platform_gpio_pins[MICO_GPIO_2],
.peripheral_clock_reg = RCC_APB1Periph_I2C1,
.tx_dma = DMA1,
.tx_dma_peripheral_clock = RCC_AHB1Periph_DMA1,
.tx_dma_stream = DMA1_Stream7,
.rx_dma_stream = DMA1_Stream0,
.tx_dma_stream_id = 7,
.rx_dma_stream_id = 0,
.tx_dma_channel = DMA_Channel_1,
.rx_dma_channel = DMA_Channel_1,
.gpio_af = GPIO_AF_I2C1
},
};
platform_i2c_driver_t platform_i2c_drivers[MICO_I2C_MAX];
platform_flash_driver_t platform_flash_drivers[MICO_FLASH_MAX];
/* Wi-Fi control pins. Used by platform/MCU/wlan_platform_common.c
* SDIO: EMW1062_PIN_BOOTSTRAP[1:0] = b'00
* gSPI: EMW1062_PIN_BOOTSTRAP[1:0] = b'01
*/
const platform_gpio_t wifi_control_pins[] =
{
[WIFI_PIN_POWER ] = { GPIOC, 1 },
[WIFI_PIN_RESET ] = { GPIOC, 5 },
[WIFI_PIN_32K_CLK ] = { GPIOA, 8 },
[WIFI_PIN_BOOTSTRAP_0] = { GPIOB, 12 },
[WIFI_PIN_BOOTSTRAP_1] = { GPIOB, 13 },
};
/* Wi-Fi SDIO bus pins. Used by platform/MCU/STM32F2xx/EMW1062_driver/wlan_SDIO.c */
const platform_gpio_t wifi_sdio_pins[] =
{
[WIFI_PIN_SDIO_OOB_IRQ] = { GPIOB, 12 },
[WIFI_PIN_SDIO_CLK ] = { GPIOC, 12 },
[WIFI_PIN_SDIO_CMD ] = { GPIOD, 2 },
[WIFI_PIN_SDIO_D0 ] = { GPIOC, 8 },
[WIFI_PIN_SDIO_D1 ] = { GPIOC, 9 },
[WIFI_PIN_SDIO_D2 ] = { GPIOC, 10 },
[WIFI_PIN_SDIO_D3 ] = { GPIOC, 11 },
};
/* Flash memory devices */
const platform_flash_t platform_flash_peripherals[] =
{
[MICO_FLASH_EMBEDDED] =
{
.flash_type = FLASH_TYPE_EMBEDDED,
.flash_start_addr = 0x08000000,
.flash_length = 0x100000,
},
};
platform_flash_driver_t platform_flash_drivers[MICO_FLASH_MAX];
/* Logic partition on flash devices */
const mico_logic_partition_t mico_partitions[] =
{
[MICO_PARTITION_BOOTLOADER] =
{
.partition_owner = MICO_FLASH_EMBEDDED,
.partition_description = "Bootloader",
.partition_start_addr = 0x08000000,
.partition_length = 0x8000, //32k bytes
.partition_options = PAR_OPT_READ_EN | PAR_OPT_WRITE_DIS,
},
[MICO_PARTITION_APPLICATION] =
{
.partition_owner = MICO_FLASH_EMBEDDED,
.partition_description = "Application",
.partition_start_addr = 0x08010000,
.partition_length = 0x50000, //320k bytes
.partition_options = PAR_OPT_READ_EN | PAR_OPT_WRITE_DIS,
},
[MICO_PARTITION_RF_FIRMWARE] =
{
.partition_owner = MICO_FLASH_EMBEDDED,
.partition_description = "RF Firmware",
.partition_start_addr = 0x080C0000,
.partition_length = 0x40000, //256k bytes
.partition_options = PAR_OPT_READ_EN | PAR_OPT_WRITE_DIS,
},
[MICO_PARTITION_OTA_TEMP] =
{
.partition_owner = MICO_FLASH_EMBEDDED,
.partition_description = "OTA Storage",
.partition_start_addr = 0x08060000,
.partition_length = 0x60000, //384k bytes
.partition_options = PAR_OPT_READ_EN | PAR_OPT_WRITE_EN,
},
[MICO_PARTITION_PARAMETER_1] =
{
.partition_owner = MICO_FLASH_EMBEDDED,
.partition_description = "PARAMETER1",
.partition_start_addr = 0x08008000,
.partition_length = 0x4000, // 16k bytes
.partition_options = PAR_OPT_READ_EN | PAR_OPT_WRITE_EN,
},
[MICO_PARTITION_PARAMETER_2] =
{
.partition_owner = MICO_FLASH_EMBEDDED,
.partition_description = "PARAMETER1",
.partition_start_addr = 0x0800C000,
.partition_length = 0x4000, //16k bytes
.partition_options = PAR_OPT_READ_EN | PAR_OPT_WRITE_EN,
},
[MICO_PARTITION_ATE] =
{
.partition_owner = MICO_FLASH_NONE,
}
};
/******************************************************
* Interrupt Handler Definitions
******************************************************/
MICO_RTOS_DEFINE_ISR( USART1_IRQHandler )
{
platform_uart_irq( &platform_uart_drivers[MICO_UART_1] );
}
MICO_RTOS_DEFINE_ISR( USART6_IRQHandler )
{
platform_uart_irq( &platform_uart_drivers[MICO_UART_2] );
}
MICO_RTOS_DEFINE_ISR( DMA2_Stream7_IRQHandler )
{
platform_uart_tx_dma_irq( &platform_uart_drivers[MICO_UART_1] );
}
MICO_RTOS_DEFINE_ISR( DMA2_Stream6_IRQHandler )
{
platform_uart_tx_dma_irq( &platform_uart_drivers[MICO_UART_2] );
}
MICO_RTOS_DEFINE_ISR( DMA2_Stream2_IRQHandler )
{
platform_uart_rx_dma_irq( &platform_uart_drivers[MICO_UART_1] );
}
MICO_RTOS_DEFINE_ISR( DMA2_Stream1_IRQHandler )
{
platform_uart_rx_dma_irq( &platform_uart_drivers[MICO_UART_2] );
}
/******************************************************
* Function Definitions
******************************************************/
static void _button_STANDBY_irq_handler( void* arg )
{
(void)(arg);
PlatformStandbyButtonClickedCallback();
}
bool watchdog_check_last_reset( void )
{
if ( RCC->CSR & RCC_CSR_WDGRSTF )
{
/* Clear the flag and return */
RCC->CSR |= RCC_CSR_RMVF;
return true;
}
return false;
}
void platform_init_peripheral_irq_priorities( void )
{
/* Interrupt priority setup. Called by MiCO/platform/MCU/STM32F2xx/platform_init.c */
NVIC_SetPriority( RTC_WKUP_IRQn , 1 ); /* RTC Wake-up event */
NVIC_SetPriority( SDIO_IRQn , 2 ); /* WLAN SDIO */
NVIC_SetPriority( DMA2_Stream3_IRQn, 3 ); /* WLAN SDIO DMA */
NVIC_SetPriority( DMA1_Stream3_IRQn, 3 ); /* WLAN SPI DMA */
NVIC_SetPriority( USART1_IRQn , 6 ); /* MICO_UART_1 */
NVIC_SetPriority( USART6_IRQn , 6 ); /* MICO_UART_2 */
NVIC_SetPriority( DMA2_Stream7_IRQn, 7 ); /* MICO_UART_1 TX DMA */
NVIC_SetPriority( DMA2_Stream2_IRQn, 7 ); /* MICO_UART_1 RX DMA */
NVIC_SetPriority( DMA2_Stream6_IRQn, 7 ); /* MICO_UART_2 TX DMA */
NVIC_SetPriority( DMA2_Stream1_IRQn, 7 ); /* MICO_UART_2 RX DMA */
NVIC_SetPriority( EXTI0_IRQn , 14 ); /* GPIO */
NVIC_SetPriority( EXTI1_IRQn , 14 ); /* GPIO */
NVIC_SetPriority( EXTI2_IRQn , 14 ); /* GPIO */
NVIC_SetPriority( EXTI3_IRQn , 14 ); /* GPIO */
NVIC_SetPriority( EXTI4_IRQn , 14 ); /* GPIO */
NVIC_SetPriority( EXTI9_5_IRQn , 14 ); /* GPIO */
NVIC_SetPriority( EXTI15_10_IRQn , 14 ); /* GPIO */
}
void init_platform( void )
{
button_init_t init;
MicoGpioInitialize( (mico_gpio_t)MICO_SYS_LED, OUTPUT_PUSH_PULL );
MicoGpioOutputLow( (mico_gpio_t)MICO_SYS_LED );
MicoGpioInitialize( (mico_gpio_t)MICO_RF_LED, OUTPUT_OPEN_DRAIN_NO_PULL );
MicoGpioOutputHigh( (mico_gpio_t)MICO_RF_LED );
// Initialise EasyLink buttons
init.gpio = EasyLink_BUTTON;
init.pressed_func = PlatformEasyLinkButtonClickedCallback;
init.long_pressed_func = PlatformEasyLinkButtonLongPressedCallback;
init.long_pressed_timeout = 5000;
button_init( IOBUTTON_EASYLINK, init );
// Initialise Standby/wakeup switcher
MicoGpioInitialize( Standby_SEL, INPUT_PULL_UP );
MicoGpioEnableIRQ( Standby_SEL , IRQ_TRIGGER_FALLING_EDGE, _button_STANDBY_irq_handler, NULL);
}
void init_platform_bootloader( void )
{
MicoGpioInitialize( (mico_gpio_t)MICO_SYS_LED, OUTPUT_PUSH_PULL );
MicoGpioOutputLow( (mico_gpio_t)MICO_SYS_LED );
MicoGpioInitialize( (mico_gpio_t)MICO_RF_LED, OUTPUT_OPEN_DRAIN_NO_PULL );
MicoGpioOutputHigh( (mico_gpio_t)MICO_RF_LED );
MicoGpioInitialize((mico_gpio_t)BOOT_SEL, INPUT_PULL_UP);
MicoGpioInitialize((mico_gpio_t)MFG_SEL, INPUT_HIGH_IMPEDANCE);
}
void MicoSysLed(bool onoff)
{
if (onoff) {
MicoGpioOutputHigh( (mico_gpio_t)MICO_SYS_LED );
} else {
MicoGpioOutputLow( (mico_gpio_t)MICO_SYS_LED );
}
}
void MicoRfLed(bool onoff)
{
if (onoff)
{
MicoGpioOutputLow( (mico_gpio_t)MICO_RF_LED );
}
else
{
MicoGpioOutputHigh( (mico_gpio_t)MICO_RF_LED );
}
}
bool MicoShouldEnterMFGMode(void)
{
if(MicoGpioInputGet((mico_gpio_t)BOOT_SEL)==false && MicoGpioInputGet((mico_gpio_t)MFG_SEL)==false)
return true;
else
return false;
}
bool MicoShouldEnterBootloader(void)
{
if(MicoGpioInputGet((mico_gpio_t)BOOT_SEL)==false && MicoGpioInputGet((mico_gpio_t)MFG_SEL)==true)
return true;
else
return false;
}

View File

@@ -1,313 +1,319 @@
/**
******************************************************************************
* @file platform.h
* @author William Xu
* @version V1.0.0
* @date 05-May-2014
* @brief This file provides all MICO Peripherals defined for current platform.
******************************************************************************
*
* The MIT License
* Copyright (c) 2014 MXCHIP Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is furnished
* to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 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.
******************************************************************************
*/
#pragma once
#ifdef __cplusplus
extern "C"
{
#endif
/******************************************************
* Macros
******************************************************/
/******************************************************
* Constants
******************************************************/
/******************************************************
* Enumerations
******************************************************/
/*
EMW3162 on EMB-380-S platform pin definitions ...
+-------------------------------------------------------------------------+
| Enum ID |Pin | STM32| Peripheral | Board | Peripheral |
| | # | Port | Available | Connection | Alias |
|---------------+----+------+-------------+--------------+----------------|
| MICO_GPIO_1 | 1 | B 6 | GPIO | | |
| | | | TIM4_CH1 | | |
| | | | CAN2_TX | | |
| | | | USART1_TX | | |
| | | | I2C1_SCL | | MICO_I2C1_SCL |
| | | | CAN2_TX | | |
|---------------+----+------+-------------+--------------+----------------|
| MICO_GPIO_2 | 2 | B 7 | GPIO | | |
| | | | I2C1_SCL | | MICO_I2C1_SDA |
| | | | USART1_RX | | |
| | | | TIM4_CH2 | | |
|---------------+----+------+-------------+--------------+----------------|
| | 3 | A 13| SWDIO | | |
|---------------+----+------+-------------+--------------+----------------|
| MICO_GPIO_4 | 4 | C 7 | USART2_RX | | MICO_UART_2_RX |
| | | | GPIO | | |
| | | | TIM8_CH2 | | |
| | | | TIM3_CH2 | | |
| | | | I2S3_MCK | | |
|---------------+----+------+-------------+--------------+----------------|
| MICO_GPIO_5 | 5 | A 3 | ADC123_IN3 | | MICO_ADC_1 |
| | | | GPIO | | |
| | | | TIM2_CH4 | | |
| | | | TIM5_CH4 | | |
| | | | TIM9_CH2 | | |
| | | | UART2_RX | | |
|---------------+----+------+-------------+--------------+----------------|
| MICO_GPIO_6 | 6 | A 4 | SPI1_NSS | | MICO_SPI_1_NSS |
| | | | GPIO | | |
| | | | SPI3_NSS | | |
| | | | I2S3_WS | | |
|---------------+----+------+-------------+--------------+----------------|
| MICO_GPIO_7 | 7 | B 3 | JTDO | | |
| | | | GPIO | | |
| | | | I2S3_SCK | | |
| | | | TIM2_CH2 | | |
| | | | SPI1_SCK | | MICO_SPI_1_SCK |
| | | | SPI3_SCK | | |
|---------------+----+------+-------------+--------------+----------------|
| MICO_GPIO_8 | 8 | B 4 | NJRST | | |
| | | | GPIO | | |
| | | | SPI3_MISO | | |
| | | | SPI1_MISO | | MICO_SPI_1_MISO|
| | | | TIM3_CH1 | | |
|---------------+----+------+-------------+--------------+----------------|
| MICO_GPIO_9 | 9 | B 5 | I2C1_SMBA | | |
| | | | GPIO | | |
| | | | CAN2_RX | | |
| | | | SPI1_MOSI | | |
| | | | SPI3_MOSI | | MICO_SPI_1_MOSI|
| | | | TIM3_CH2 | | |
|---------------+----+------+-------------+--------------+----------------|
| MICO_GPIO_10 | 10 | B 8 | GPIO | | |
| | | | TIM4_CH3 | | MICO_PWM_1 |
| | | | TIM10_CH1 | | |
| | | | I2C1_SCL | | |
| | | | CAN1_RX | | |
|---------------+----+------+-------------+--------------+----------------|
| MICO_GPIO_11 | 11 | A 1 | GPIO |EasyLink_BUTTON | |
| | | | TIM5_CH2 | | |
| | | | TIM2_CH2 | | |
| | | | ADC123_IN1 | | |
|---------------+----+------+-------------+--------------+----------------|
| MICO_GPIO_12 | 12 | C 2 | GPIO | | |
| | | | ADC123_ IN12| | MICO_ADC_2 |
|---------------+----+------+-------------+--------------+----------------|
| MICO_GPIO_13 | 13 | B 14 | GPIO | | |
| | | | TIM1_CH2N | | |
| | | | TIM12_CH1 | | MICO_PWM_2 |
|---------------+----+------+-------------+--------------+----------------|
| MICO_GPIO_14 | 14 | C 6 | GPIO | | |
| | | | TIM3_CH1 | | |
| | | | TIM8_CH1 | | |
| | | | USART6_TX | | MICO_UART_2_TX |
|---------------+----+------+-------------+--------------+----------------|
| | 15 | GND | | | |
|---------------+----+------+-------------+--------------+----------------|
| MICO_GPIO_16 | 16 | B 1 | GPIO | RF_LED | |
| | | | TIM3_CH4 | | |
| | | | TIM8_CH3N | | |
| | | | TIM1_CH4N | | |
|---------------+----+------+-------------+--------------+----------------|
| | 17 |nReset| | | |
|---------------+----+------+-------------+--------------+----------------|
| MICO_GPIO_18 | 18 | A 15 | GPIO | | |
| | | | JTDI | | |
+---------------+----+--------------------+--------------+----------------+
| MICO_GPIO_19 | 19 | B 11 | GPIO | | |
| | | | TIM2_CH4 | | MICO_PWM_3 |
+---------------+----+--------------------+--------------+----------------+
| MICO_GPIO_20 | 20 | A 12 | GPIO | | |
| | | | USART1_RTS | | |
| | | | CAN1_TX | | |
| | | | TIM1_ETR | | |
| | | | OTG_FS_DP | | |
+---------------+----+--------------------+--------------+----------------+
| MICO_GPIO_21 | 21 | A 11 | GPIO | | |
| | | | USART1_CTS | | |
| | | | CAN1_RX | | |
| | | | TIM1_CH4 | | |
| | | | OTG_FS_DM | | |
+---------------+----+--------------------+--------------+----------------+
| MICO_GPIO_22 | 22 | A 9 | GPIO | | |
| | | | USART1_TX |STDIO_UART_TX | |
| | | | TIM1_CH2 | | |
+---------------+----+--------------------+--------------+----------------+
| MICO_GPIO_23 | 23 | A 10 | GPIO | | |
| | | | USART1_RX |STDIO_UART_RX | |
| | | | TIM1_CH3 | | |
| | | | OTG_FS_ID | | |
+---------------+----+--------------------+--------------+----------------+
| | 24 | VCC | | | |
+---------------+----+--------------------+--------------+----------------+
| | 25 | GND | | | |
+---------------+----+--------------------+--------------+----------------+
| | 26 | NC | | | |
+---------------+----+--------------------+--------------+----------------+
| | 27 | BOOT0| | | |
+---------------+----+--------------------+--------------+----------------+
| | 28 | A 14 | JTCK-SWCLK | | |
+---------------+----+--------------------+--------------+----------------+
| MICO_GPIO_29 | 29 | A 0 | GPIO |StandBy/WakeUp| |
| | | | TIM2_CH1_ETR| | |
| | | | TIM5_CH1 | | |
| | | | TIM8_ETR | | |
+---------------+----+--------------------+--------------+----------------+
| MICO_GPIO_30 | 30 | B 9 | GPIO | Status_Sel | |
| | | | TIM4_CH4 | | |
| | | | TIM11_CH1 | | |
| | | | I2C1_SDA | | |
| | | | CAN1_TX | | |
+---------------+----+--------------------+--------------+----------------+
| MICO_SYS_LED | | B 0 | GPIO | | |
+---------------+----+--------------------+--------------+----------------+
*
*/
#define MICO_UNUSED 0xFF
typedef enum
{
MICO_SYS_LED,
MICO_RF_LED,
BOOT_SEL,
MFG_SEL,
EasyLink_BUTTON,
MICO_GPIO_1 ,
MICO_GPIO_2,
//MICO_GPIO_3,
MICO_GPIO_4,
MICO_GPIO_5,
MICO_GPIO_6,
MICO_GPIO_7,
MICO_GPIO_8,
MICO_GPIO_9,
MICO_GPIO_10,
//MICO_GPIO_11,
MICO_GPIO_12,
MICO_GPIO_13,
MICO_GPIO_14,
//MICO_GPIO_15,
//MICO_GPIO_16,
//MICO_GPIO_17,
MICO_GPIO_18,
MICO_GPIO_19,
MICO_GPIO_20,
MICO_GPIO_21,
MICO_GPIO_22,
MICO_GPIO_23,
//MICO_GPIO_24,
//MICO_GPIO_25,
//MICO_GPIO_26,
//MICO_GPIO_27,
//MICO_GPIO_28,
MICO_GPIO_29,
//MICO_GPIO_30,
MICO_GPIO_MAX, /* Denotes the total number of GPIO port aliases. Not a valid GPIO alias */
MICO_GPIO_NONE,
} mico_gpio_t;
typedef enum
{
MICO_SPI_1,
MICO_SPI_MAX, /* Denotes the total number of SPI port aliases. Not a valid SPI alias */
MICO_SPI_NONE,
} mico_spi_t;
typedef enum
{
MICO_I2C_1,
MICO_I2C_MAX, /* Denotes the total number of I2C port aliases. Not a valid I2C alias */
MICO_I2C_NONE,
} mico_i2c_t;
typedef enum
{
MICO_PWM_1,
MICO_PWM_2,
MICO_PWM_3,
MICO_PWM_MAX, /* Denotes the total number of PWM port aliases. Not a valid PWM alias */
MICO_PWM_NONE,
} mico_pwm_t;
typedef enum
{
MICO_ADC_1,
MICO_ADC_2,
MICO_ADC_3,
MICO_ADC_MAX, /* Denotes the total number of ADC port aliases. Not a valid ADC alias */
MICO_ADC_NONE,
} mico_adc_t;
typedef enum
{
MICO_UART_1,
MICO_UART_2,
MICO_UART_MAX, /* Denotes the total number of UART port aliases. Not a valid UART alias */
MICO_UART_NONE,
} mico_uart_t;
typedef enum
{
MICO_FLASH_EMBEDDED,
MICO_FLASH_MAX,
MICO_FLASH_NONE,
} mico_flash_t;
typedef enum
{
MICO_PARTITION_USER_MAX
} mico_user_partition_t;
#ifdef BOOTLOADER
#define STDIO_UART MICO_UART_1
#define STDIO_UART_BAUDRATE (921600)
#else
#define STDIO_UART MICO_UART_2
#define STDIO_UART_BAUDRATE (115200)
#endif
#define UART_FOR_APP MICO_UART_1
#define MFG_TEST MICO_UART_1
#define CLI_UART MICO_UART_2
/* Components connected to external I/Os*/
#define Standby_SEL (MICO_GPIO_29)
/* I/O connection <-> Peripheral Connections */
#define MICO_I2C_CP (MICO_I2C_1)
#ifdef __cplusplus
} /*extern "C" */
#endif
/**
******************************************************************************
* @file platform.h
* @author William Xu
* @version V1.0.0
* @date 05-May-2014
* @brief This file provides all MICO Peripherals defined for current platform.
******************************************************************************
*
* The MIT License
* Copyright (c) 2014 MXCHIP Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is furnished
* to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 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.
******************************************************************************
*/
#pragma once
#ifdef __cplusplus
extern "C"
{
#endif
/******************************************************
* Macros
******************************************************/
/******************************************************
* Constants
******************************************************/
/******************************************************
* Enumerations
******************************************************/
/*
EMW3162 on EMB-380-S platform pin definitions ...
+-------------------------------------------------------------------------+
| Enum ID |Pin | STM32| Peripheral | Board | Peripheral |
| | # | Port | Available | Connection | Alias |
|---------------+----+------+-------------+--------------+----------------|
| MICO_GPIO_1 | 1 | B 6 | GPIO | | |
| | | | TIM4_CH1 | | |
| | | | CAN2_TX | | |
| | | | USART1_TX | | |
| | | | I2C1_SCL | | MICO_I2C1_SCL |
| | | | CAN2_TX | | |
|---------------+----+------+-------------+--------------+----------------|
| MICO_GPIO_2 | 2 | B 7 | GPIO | | |
| | | | I2C1_SCL | | MICO_I2C1_SDA |
| | | | USART1_RX | | |
| | | | TIM4_CH2 | | |
|---------------+----+------+-------------+--------------+----------------|
| | 3 | A 13| SWDIO | | |
|---------------+----+------+-------------+--------------+----------------|
| MICO_GPIO_4 | 4 | C 7 | USART2_RX | | MICO_UART_2_RX |
| | | | GPIO | | |
| | | | TIM8_CH2 | | |
| | | | TIM3_CH2 | | |
| | | | I2S3_MCK | | |
|---------------+----+------+-------------+--------------+----------------|
| MICO_GPIO_5 | 5 | A 3 | ADC123_IN3 | | MICO_ADC_1 |
| | | | GPIO | | |
| | | | TIM2_CH4 | | |
| | | | TIM5_CH4 | | |
| | | | TIM9_CH2 | | |
| | | | UART2_RX | | |
|---------------+----+------+-------------+--------------+----------------|
| MICO_GPIO_6 | 6 | A 4 | SPI1_NSS | | MICO_SPI_1_NSS |
| | | | GPIO | | |
| | | | SPI3_NSS | | |
| | | | I2S3_WS | | |
|---------------+----+------+-------------+--------------+----------------|
| MICO_GPIO_7 | 7 | B 3 | JTDO | | |
| | | | GPIO | | |
| | | | I2S3_SCK | | |
| | | | TIM2_CH2 | | |
| | | | SPI1_SCK | | MICO_SPI_1_SCK |
| | | | SPI3_SCK | | |
|---------------+----+------+-------------+--------------+----------------|
| MICO_GPIO_8 | 8 | B 4 | NJRST | | |
| | | | GPIO | | |
| | | | SPI3_MISO | | |
| | | | SPI1_MISO | | MICO_SPI_1_MISO|
| | | | TIM3_CH1 | | |
|---------------+----+------+-------------+--------------+----------------|
| MICO_GPIO_9 | 9 | B 5 | I2C1_SMBA | | |
| | | | GPIO | | |
| | | | CAN2_RX | | |
| | | | SPI1_MOSI | | |
| | | | SPI3_MOSI | | MICO_SPI_1_MOSI|
| | | | TIM3_CH2 | | |
|---------------+----+------+-------------+--------------+----------------|
| MICO_GPIO_10 | 10 | B 8 | GPIO | | |
| | | | TIM4_CH3 | | MICO_PWM_1 |
| | | | TIM10_CH1 | | |
| | | | I2C1_SCL | | |
| | | | CAN1_RX | | |
|---------------+----+------+-------------+--------------+----------------|
| MICO_GPIO_11 | 11 | A 1 | GPIO |EasyLink_BUTTON | |
| | | | TIM5_CH2 | | |
| | | | TIM2_CH2 | | |
| | | | ADC123_IN1 | | |
|---------------+----+------+-------------+--------------+----------------|
| MICO_GPIO_12 | 12 | C 2 | GPIO | | |
| | | | ADC123_ IN12| | MICO_ADC_2 |
|---------------+----+------+-------------+--------------+----------------|
| MICO_GPIO_13 | 13 | B 14 | GPIO | | |
| | | | TIM1_CH2N | | |
| | | | TIM12_CH1 | | MICO_PWM_2 |
|---------------+----+------+-------------+--------------+----------------|
| MICO_GPIO_14 | 14 | C 6 | GPIO | | |
| | | | TIM3_CH1 | | |
| | | | TIM8_CH1 | | |
| | | | USART6_TX | | MICO_UART_2_TX |
|---------------+----+------+-------------+--------------+----------------|
| | 15 | GND | | | |
|---------------+----+------+-------------+--------------+----------------|
| MICO_GPIO_16 | 16 | B 1 | GPIO | RF_LED | |
| | | | TIM3_CH4 | | |
| | | | TIM8_CH3N | | |
| | | | TIM1_CH4N | | |
|---------------+----+------+-------------+--------------+----------------|
| | 17 |nReset| | | |
|---------------+----+------+-------------+--------------+----------------|
| MICO_GPIO_18 | 18 | A 15 | GPIO | | |
| | | | JTDI | | |
+---------------+----+--------------------+--------------+----------------+
| MICO_GPIO_19 | 19 | B 11 | GPIO | | |
| | | | TIM2_CH4 | | MICO_PWM_3 |
+---------------+----+--------------------+--------------+----------------+
| MICO_GPIO_20 | 20 | A 12 | GPIO | | |
| | | | USART1_RTS | | |
| | | | CAN1_TX | | |
| | | | TIM1_ETR | | |
| | | | OTG_FS_DP | | |
+---------------+----+--------------------+--------------+----------------+
| MICO_GPIO_21 | 21 | A 11 | GPIO | | |
| | | | USART1_CTS | | |
| | | | CAN1_RX | | |
| | | | TIM1_CH4 | | |
| | | | OTG_FS_DM | | |
+---------------+----+--------------------+--------------+----------------+
| MICO_GPIO_22 | 22 | A 9 | GPIO | | |
| | | | USART1_TX |STDIO_UART_TX | |
| | | | TIM1_CH2 | | |
+---------------+----+--------------------+--------------+----------------+
| MICO_GPIO_23 | 23 | A 10 | GPIO | | |
| | | | USART1_RX |STDIO_UART_RX | |
| | | | TIM1_CH3 | | |
| | | | OTG_FS_ID | | |
+---------------+----+--------------------+--------------+----------------+
| | 24 | VCC | | | |
+---------------+----+--------------------+--------------+----------------+
| | 25 | GND | | | |
+---------------+----+--------------------+--------------+----------------+
| | 26 | NC | | | |
+---------------+----+--------------------+--------------+----------------+
| | 27 | BOOT0| | | |
+---------------+----+--------------------+--------------+----------------+
| | 28 | A 14 | JTCK-SWCLK | | |
+---------------+----+--------------------+--------------+----------------+
| MICO_GPIO_29 | 29 | A 0 | GPIO |StandBy/WakeUp| |
| | | | TIM2_CH1_ETR| | |
| | | | TIM5_CH1 | | |
| | | | TIM8_ETR | | |
+---------------+----+--------------------+--------------+----------------+
| MICO_GPIO_30 | 30 | B 9 | GPIO | Status_Sel | |
| | | | TIM4_CH4 | | |
| | | | TIM11_CH1 | | |
| | | | I2C1_SDA | | |
| | | | CAN1_TX | | |
+---------------+----+--------------------+--------------+----------------+
| MICO_SYS_LED | | B 0 | GPIO | | |
+---------------+----+--------------------+--------------+----------------+
*
*/
#define MICO_UNUSED 0xFF
typedef enum
{
MICO_SYS_LED,
MICO_RF_LED,
BOOT_SEL,
MFG_SEL,
EasyLink_BUTTON,
MICO_GPIO_1 ,
MICO_GPIO_2,
//MICO_GPIO_3,
MICO_GPIO_4,
MICO_GPIO_5,
MICO_GPIO_6,
MICO_GPIO_7,
MICO_GPIO_8,
MICO_GPIO_9,
MICO_GPIO_10,
//MICO_GPIO_11,
MICO_GPIO_12,
MICO_GPIO_13,
MICO_GPIO_14,
//MICO_GPIO_15,
//MICO_GPIO_16,
//MICO_GPIO_17,
MICO_GPIO_18,
MICO_GPIO_19,
MICO_GPIO_20,
MICO_GPIO_21,
MICO_GPIO_22,
MICO_GPIO_23,
//MICO_GPIO_24,
//MICO_GPIO_25,
//MICO_GPIO_26,
//MICO_GPIO_27,
//MICO_GPIO_28,
MICO_GPIO_29,
//MICO_GPIO_30,
MICO_GPIO_MAX, /* Denotes the total number of GPIO port aliases. Not a valid GPIO alias */
MICO_GPIO_NONE,
} mico_gpio_t;
typedef enum
{
MICO_SPI_1,
MICO_SPI_MAX, /* Denotes the total number of SPI port aliases. Not a valid SPI alias */
MICO_SPI_NONE,
} mico_spi_t;
typedef enum
{
MICO_I2C_1,
MICO_I2C_MAX, /* Denotes the total number of I2C port aliases. Not a valid I2C alias */
MICO_I2C_NONE,
} mico_i2c_t;
typedef enum
{
MICO_IIS_MAX, /* Denotes the total number of IIS port aliases. Not a valid IIS alias */
MICO_IIS_NONE,
} mico_iis_t;
typedef enum
{
MICO_PWM_1,
MICO_PWM_2,
MICO_PWM_3,
MICO_PWM_MAX, /* Denotes the total number of PWM port aliases. Not a valid PWM alias */
MICO_PWM_NONE,
} mico_pwm_t;
typedef enum
{
MICO_ADC_1,
MICO_ADC_2,
MICO_ADC_3,
MICO_ADC_MAX, /* Denotes the total number of ADC port aliases. Not a valid ADC alias */
MICO_ADC_NONE,
} mico_adc_t;
typedef enum
{
MICO_UART_1,
MICO_UART_2,
MICO_UART_MAX, /* Denotes the total number of UART port aliases. Not a valid UART alias */
MICO_UART_NONE,
} mico_uart_t;
typedef enum
{
MICO_FLASH_EMBEDDED,
MICO_FLASH_MAX,
MICO_FLASH_NONE,
} mico_flash_t;
typedef enum
{
MICO_PARTITION_USER_MAX
} mico_user_partition_t;
#ifdef BOOTLOADER
#define STDIO_UART MICO_UART_1
#define STDIO_UART_BAUDRATE (921600)
#else
#define STDIO_UART MICO_UART_2
#define STDIO_UART_BAUDRATE (115200)
#endif
#define UART_FOR_APP MICO_UART_1
#define MFG_TEST MICO_UART_1
#define CLI_UART MICO_UART_2
/* Components connected to external I/Os*/
#define Standby_SEL (MICO_GPIO_29)
/* I/O connection <-> Peripheral Connections */
#define MICO_I2C_CP (MICO_I2C_1)
#ifdef __cplusplus
} /*extern "C" */
#endif

View File

@@ -1,163 +1,163 @@
/**
******************************************************************************
* @file platform_config.h
* @author William Xu
* @version V1.0.0
* @date 05-May-2014
* @brief This file provides common configuration for current platform.
******************************************************************************
*
* The MIT License
* Copyright (c) 2014 MXCHIP Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is furnished
* to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 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.
******************************************************************************
*/
#ifndef __PLATFORM_COMMON_CONFIG_H__
#define __PLATFORM_COMMON_CONFIG_H__
#pragma once
/******************************************************
* Macros
******************************************************/
/******************************************************
* Constants
******************************************************/
#define HARDWARE_REVISION "3162"
#define DEFAULT_NAME "EMW3162 Module"
#define MODEL "EMW3162"
/* MICO RTOS tick rate in Hz */
#define MICO_DEFAULT_TICK_RATE_HZ (1000)
/************************************************************************
* Uncomment to disable watchdog. For debugging only */
//#define MICO_DISABLE_WATCHDOG
/************************************************************************
* Uncomment to disable standard IO, i.e. printf(), etc. */
//#define MICO_DISABLE_STDIO
/************************************************************************
* Uncomment to disable MCU powersave API functions */
//#define MICO_DISABLE_MCU_POWERSAVE
/************************************************************************
* Uncomment to enable MCU real time clock */
#define MICO_ENABLE_MCU_RTC
/************************************************************************
* Restore default and start easylink after press down EasyLink button for 3 seconds. */
#define RestoreDefault_TimeOut (3000)
/************************************************************************
* Restore default and start easylink after press down EasyLink button for 3 seconds. */
#define MCU_CLOCK_HZ (120000000)
/************************************************************************
* How many bits are used in NVIC priority configuration */
#define CORTEX_NVIC_PRIO_BITS (4)
/************************************************************************
* Enable write protection to write-disabled embedded flash sectors */
//#define MCU_EBANLE_FLASH_PROTECT
/******************************************************
* MCU Constants and Options
*
* NOTE: The clock configuration utility from ST is used to calculate these values
* http://www.st.com/st-web-ui/static/active/en/st_prod_software_internet/resource/technical/software/utility/stsw-stm32090.zip
******************************************************/
#define HSE_SOURCE RCC_HSE_ON /* Use external crystal */
#define AHB_CLOCK_DIVIDER RCC_SYSCLK_Div1 /* AHB clock = System clock */
#define APB1_CLOCK_DIVIDER RCC_HCLK_Div4 /* APB1 clock = AHB clock / 4 */
#define APB2_CLOCK_DIVIDER RCC_HCLK_Div2 /* APB2 clock = AHB clock / 2 */
#define PLL_SOURCE RCC_PLLSource_HSE /* PLL source = external crystal */
#define PLL_M_CONSTANT 26 /* PLLM = 26 */
#define PLL_N_CONSTANT 240 /* PLLN = 240 */
#define PLL_P_CONSTANT 2 /* PLLP = 2 */
#define PPL_Q_CONSTANT 5 /* PLLQ = 5 */
#define SYSTEM_CLOCK_SOURCE RCC_SYSCLKSource_PLLCLK /* System clock source = PLL clock */
#define SYSTICK_CLOCK_SOURCE SysTick_CLKSource_HCLK /* SysTick clock source = AHB clock */
#define INT_FLASH_WAIT_STATE FLASH_Latency_3 /* Internal flash wait state = 3 cycles */
/******************************************************
* EMW1062 Options
******************************************************/
/* Wi-Fi chip module */
#define EMW1062
/* GPIO pins are used to bootstrap Wi-Fi to SDIO or gSPI mode */
#define MICO_WIFI_USE_GPIO_FOR_BOOTSTRAP_0
#define MICO_WIFI_USE_GPIO_FOR_BOOTSTRAP_1
/* Wi-Fi GPIO0 pin is used for out-of-band interrupt */
#define MICO_WIFI_OOB_IRQ_GPIO_PIN ( 0 )
/* Wi-Fi power pin is present */
#define MICO_USE_WIFI_POWER_PIN
/* Wi-Fi reset pin is present */
#define MICO_USE_WIFI_RESET_PIN
/* Wi-Fi 32K pin is present */
#define MICO_USE_WIFI_32K_PIN
/* USE SDIO 1bit mode */
//#define SDIO_1_BIT
/* Wi-Fi power pin is active high */
//#define MICO_USE_WIFI_POWER_PIN_ACTIVE_HIGH
/* WLAN Powersave Clock Source
* The WLAN sleep clock can be driven from one of two sources:
* 1. MCO (MCU Clock Output) - default
* NOTE: Versions of BCM943362WCD4 up to and including P200 require a hardware patch to enable this mode
* - Connect STM32F205RGT6 pin 41 (PA8) to pin 44 (PA11)
* 2. WLAN 32K internal oscillator (30% inaccuracy)
* - Comment the following directive : MICO_USE_WIFI_32K_CLOCK_MCO
*/
#define MICO_USE_WIFI_32K_CLOCK_MCO
//#define MICO_USE_BUILTIN_RF_DRIVER
/******************************************************
* Enumerations
******************************************************/
/******************************************************
* Type Definitions
******************************************************/
/******************************************************
* Structures
******************************************************/
/******************************************************
* Global Variables
******************************************************/
/******************************************************
* Function Declarations
******************************************************/
#endif
/**
******************************************************************************
* @file platform_config.h
* @author William Xu
* @version V1.0.0
* @date 05-May-2014
* @brief This file provides common configuration for current platform.
******************************************************************************
*
* The MIT License
* Copyright (c) 2014 MXCHIP Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is furnished
* to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 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.
******************************************************************************
*/
#ifndef __PLATFORM_COMMON_CONFIG_H__
#define __PLATFORM_COMMON_CONFIG_H__
#pragma once
/******************************************************
* Macros
******************************************************/
/******************************************************
* Constants
******************************************************/
#define HARDWARE_REVISION "3162"
#define DEFAULT_NAME "EMW3162 Module"
#define MODEL "EMW3162"
/* MICO RTOS tick rate in Hz */
#define MICO_DEFAULT_TICK_RATE_HZ (1000)
/************************************************************************
* Uncomment to disable watchdog. For debugging only */
//#define MICO_DISABLE_WATCHDOG
/************************************************************************
* Uncomment to disable standard IO, i.e. printf(), etc. */
//#define MICO_DISABLE_STDIO
/************************************************************************
* Uncomment to disable MCU powersave API functions */
//#define MICO_DISABLE_MCU_POWERSAVE
/************************************************************************
* Uncomment to enable MCU real time clock */
#define MICO_ENABLE_MCU_RTC
/************************************************************************
* Restore default and start easylink after press down EasyLink button for 3 seconds. */
#define RestoreDefault_TimeOut (3000)
/************************************************************************
* Restore default and start easylink after press down EasyLink button for 3 seconds. */
#define MCU_CLOCK_HZ (120000000)
/************************************************************************
* How many bits are used in NVIC priority configuration */
#define CORTEX_NVIC_PRIO_BITS (4)
/************************************************************************
* Enable write protection to write-disabled embedded flash sectors */
//#define MCU_EBANLE_FLASH_PROTECT
/******************************************************
* MCU Constants and Options
*
* NOTE: The clock configuration utility from ST is used to calculate these values
* http://www.st.com/st-web-ui/static/active/en/st_prod_software_internet/resource/technical/software/utility/stsw-stm32090.zip
******************************************************/
#define HSE_SOURCE RCC_HSE_ON /* Use external crystal */
#define AHB_CLOCK_DIVIDER RCC_SYSCLK_Div1 /* AHB clock = System clock */
#define APB1_CLOCK_DIVIDER RCC_HCLK_Div4 /* APB1 clock = AHB clock / 4 */
#define APB2_CLOCK_DIVIDER RCC_HCLK_Div2 /* APB2 clock = AHB clock / 2 */
#define PLL_SOURCE RCC_PLLSource_HSE /* PLL source = external crystal */
#define PLL_M_CONSTANT 26 /* PLLM = 26 */
#define PLL_N_CONSTANT 240 /* PLLN = 240 */
#define PLL_P_CONSTANT 2 /* PLLP = 2 */
#define PPL_Q_CONSTANT 5 /* PLLQ = 5 */
#define SYSTEM_CLOCK_SOURCE RCC_SYSCLKSource_PLLCLK /* System clock source = PLL clock */
#define SYSTICK_CLOCK_SOURCE SysTick_CLKSource_HCLK /* SysTick clock source = AHB clock */
#define INT_FLASH_WAIT_STATE FLASH_Latency_3 /* Internal flash wait state = 3 cycles */
/******************************************************
* EMW1062 Options
******************************************************/
/* Wi-Fi chip module */
#define EMW1062
/* GPIO pins are used to bootstrap Wi-Fi to SDIO or gSPI mode */
#define MICO_WIFI_USE_GPIO_FOR_BOOTSTRAP_0
#define MICO_WIFI_USE_GPIO_FOR_BOOTSTRAP_1
/* Wi-Fi GPIO0 pin is used for out-of-band interrupt */
#define MICO_WIFI_OOB_IRQ_GPIO_PIN ( 0 )
/* Wi-Fi power pin is present */
#define MICO_USE_WIFI_POWER_PIN
/* Wi-Fi reset pin is present */
#define MICO_USE_WIFI_RESET_PIN
/* Wi-Fi 32K pin is present */
#define MICO_USE_WIFI_32K_PIN
/* USE SDIO 1bit mode */
//#define SDIO_1_BIT
/* Wi-Fi power pin is active high */
//#define MICO_USE_WIFI_POWER_PIN_ACTIVE_HIGH
/* WLAN Powersave Clock Source
* The WLAN sleep clock can be driven from one of two sources:
* 1. MCO (MCU Clock Output) - default
* NOTE: Versions of BCM943362WCD4 up to and including P200 require a hardware patch to enable this mode
* - Connect STM32F205RGT6 pin 41 (PA8) to pin 44 (PA11)
* 2. WLAN 32K internal oscillator (30% inaccuracy)
* - Comment the following directive : MICO_USE_WIFI_32K_CLOCK_MCO
*/
#define MICO_USE_WIFI_32K_CLOCK_MCO
//#define MICO_USE_BUILTIN_RF_DRIVER
/******************************************************
* Enumerations
******************************************************/
/******************************************************
* Type Definitions
******************************************************/
/******************************************************
* Structures
******************************************************/
/******************************************************
* Global Variables
******************************************************/
/******************************************************
* Function Declarations
******************************************************/
#endif