修复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__ = 0x00400000;
/*-Memory Regions-*/
define symbol __ICFEDIT_region_ROM_start__ = 0x00400000;
define symbol __ICFEDIT_region_ROM_end__ = 0x00407FFF;
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__ = 0x00400000;
/*-Memory Regions-*/
define symbol __ICFEDIT_region_ROM_start__ = 0x00400000;
define symbol __ICFEDIT_region_ROM_end__ = 0x00407FFF;
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 0x00008000 {
ER_IROM1 0x08000000 0x00008000
{
*.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 0x00008000 {
ER_IROM1 0x08000000 0x00008000
{
*.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,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__ = 0x00420000;
/*-Memory Regions-*/
define symbol __ICFEDIT_region_ROM_start__ = 0x00420000;
define symbol __ICFEDIT_region_ROM_end__ = 0x0047FFFF;
define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
define symbol __ICFEDIT_region_RAM_end__ = 0x20027FFF;
/*-Sizes-*/
define symbol __ICFEDIT_size_cstack__ = 0x200;
define symbol __ICFEDIT_size_heap__ = 0x1E000;
/**** 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__ = 0x00420000;
/*-Memory Regions-*/
define symbol __ICFEDIT_region_ROM_start__ = 0x00420000;
define symbol __ICFEDIT_region_ROM_end__ = 0x0047FFFF;
define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
define symbol __ICFEDIT_region_RAM_end__ = 0x20027FFF;
/*-Sizes-*/
define symbol __ICFEDIT_size_cstack__ = 0x200;
define symbol __ICFEDIT_size_heap__ = 0x1E000;
/**** 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,428 +1,428 @@
/**
******************************************************************************
* @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 "spi_flash_platform_interface.h"
#include "keypad/gpio_button/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 */
[STDIO_UART_TX] = { IOPORT_CREATE_PIN( PIOA, 10 ), false, 0, 0 },
[STDIO_UART_RX] = { IOPORT_CREATE_PIN( PIOA, 9 ), false, 0, 0 },
[FLASH_PIN_SPI_CS ] = { IOPORT_CREATE_PIN( PIOA, 30 ), false, 0, 0 },
[FLASH_PIN_SPI_CLK ] = { IOPORT_CREATE_PIN( PIOA, 29 ), false, 0, 0 },
[FLASH_PIN_SPI_MOSI] = { IOPORT_CREATE_PIN( PIOA, 28 ), false, 0, 0 },
[FLASH_PIN_SPI_MISO] = { IOPORT_CREATE_PIN( PIOA, 27 ), false, 0, 0 },
[MICO_SYS_LED] = { IOPORT_CREATE_PIN( PIOB, 10 ), false, 0, 0 },
[MICO_RF_LED] = { IOPORT_CREATE_PIN( PIOA, 24 ), false, 0, 0 },
[EasyLink_BUTTON] = { IOPORT_CREATE_PIN( PIOA, 2 ), false, 0, 0 },
[BOOT_SEL] = { IOPORT_CREATE_PIN( PIOB, 14 ), false, 0, 0 },
[MFG_SEL] = { IOPORT_CREATE_PIN( PIOB, 15 ), false, 0, 0 },
/* GPIOs for external use */
[Arduino_RXD] = { IOPORT_CREATE_PIN( PIOB, 1 ), false, 0, 0 },
[Arduino_TXD] = { IOPORT_CREATE_PIN( PIOB, 0 ), false, 0, 0 },
[Arduino_D2] = { IOPORT_CREATE_PIN( PIOA, 21 ), false, 0, 0 },
[Arduino_D3] = { IOPORT_CREATE_PIN( PIOA, 22 ), false, 0, 0 },
[Arduino_D4] = { IOPORT_CREATE_PIN( PIOA, 23 ), false, 0, 0 },
[Arduino_D5] = { IOPORT_CREATE_PIN( PIOA, 6 ), false, 0, 0 },
[Arduino_D6] = { IOPORT_CREATE_PIN( PIOA, 25 ), false, 0, 0 },
[Arduino_D7] = { IOPORT_CREATE_PIN( PIOB, 13 ), false, 0, 0 },
[Arduino_D8] = { IOPORT_CREATE_PIN( PIOA, 0 ), false, 0, 0 },
[Arduino_D9] = { IOPORT_CREATE_PIN( PIOA, 1 ), false, 0, 0 },
[Arduino_CS] = { IOPORT_CREATE_PIN( PIOA, 31 ), false, 0, 0 },
[Arduino_SI] = { IOPORT_CREATE_PIN( PIOA, 28 ), false, 0, 0 },
[Arduino_SO] = { IOPORT_CREATE_PIN( PIOA, 27 ), false, 0, 0 },
[Arduino_SCK] = { IOPORT_CREATE_PIN( PIOA, 29 ), false, 0, 0 },
[Arduino_SDA] = { IOPORT_CREATE_PIN( PIOA, 3 ), false, 0, 0 },
[Arduino_SCL] = { IOPORT_CREATE_PIN( PIOA, 4 ), false, 0, 0 },
};
const platform_adc_t platform_adc_peripherals[] =
{
[ Arduino_A0 ] = { ADC_CHANNEL_0, ADC_INTERRUPT_EOC_0, ADC_12_BITS },
[ Arduino_A1 ] = { ADC_CHANNEL_1, ADC_INTERRUPT_EOC_1, ADC_12_BITS },
[ Arduino_A2 ] = { ADC_CHANNEL_2, ADC_INTERRUPT_EOC_2, ADC_12_BITS },
[ Arduino_A3 ] = { ADC_CHANNEL_3, ADC_INTERRUPT_EOC_3, ADC_12_BITS },
[ Arduino_A4 ] = { ADC_CHANNEL_6, ADC_INTERRUPT_EOC_6, ADC_12_BITS },
[ Arduino_A5 ] = { ADC_CHANNEL_7, ADC_INTERRUPT_EOC_7, ADC_12_BITS },
};
/* PWM mappings */
const platform_pwm_t *platform_pwm_peripherals = NULL;
const platform_spi_t platform_spi_peripherals [] =
{
[MICO_SPI_1] =
{
.spi_id = 7,
.port = SPI7,
.flexcom_base = FLEXCOM7,
.peripheral_id = ID_FLEXCOM7,
.mosi_pin = &platform_gpio_pins[FLASH_PIN_SPI_MOSI],
.mosi_pin_mux_mode = IOPORT_MODE_MUX_B,
.miso_pin = &platform_gpio_pins[FLASH_PIN_SPI_MISO],
.miso_pin_mux_mode = IOPORT_MODE_MUX_B,
.clock_pin = &platform_gpio_pins[FLASH_PIN_SPI_CLK],
.clock_pin_mux_mode = IOPORT_MODE_MUX_B,
},
};
platform_spi_driver_t platform_spi_drivers[MICO_SPI_MAX];
const platform_uart_t platform_uart_peripherals[] =
{
[MICO_UART_1] =
{
.uart_id = 0,
.port = USART0,
.flexcom_base = FLEXCOM0,
.peripheral_id = ID_FLEXCOM0,
.tx_pin = &platform_gpio_pins[STDIO_UART_TX],
.tx_pin_mux_mode = IOPORT_MODE_MUX_A,
.rx_pin = &platform_gpio_pins[STDIO_UART_RX],
.rx_pin_mux_mode = IOPORT_MODE_MUX_A,
.cts_pin = NULL, /* flow control isn't supported */
.cts_pin_mux_mode = IOPORT_MODE_MUX_A,
.rts_pin = NULL, /* flow control isn't supported */
.rts_pin_mux_mode = IOPORT_MODE_MUX_A,
},
[MICO_UART_2] =
{
.uart_id = 6,
.port = USART6,
.flexcom_base = FLEXCOM6,
.peripheral_id = ID_FLEXCOM6,
.tx_pin = &platform_gpio_pins[Arduino_TXD],
.tx_pin_mux_mode = IOPORT_MODE_MUX_B,
.rx_pin = &platform_gpio_pins[Arduino_RXD],
.rx_pin_mux_mode = IOPORT_MODE_MUX_B,
.cts_pin = NULL, /* flow control isn't supported */
.cts_pin_mux_mode = IOPORT_MODE_MUX_B,
.rts_pin = NULL, /* flow control isn't supported */
.rts_pin_mux_mode = IOPORT_MODE_MUX_B,
},
};
platform_uart_driver_t platform_uart_drivers[MICO_UART_MAX];
const platform_i2c_t platform_i2c_peripherals[] =
{
[MICO_I2C_1] =
{
.i2c_id = 3,
.port = TWI3,
.flexcom_base = FLEXCOM3,
.peripheral_id = ID_FLEXCOM3,
.sda_pin = &platform_gpio_pins[Arduino_SDA],
.sda_pin_mux_mode = IOPORT_MODE_MUX_A,
.scl_pin = &platform_gpio_pins[Arduino_SCL],
.scl_pin_mux_mode = IOPORT_MODE_MUX_A,
},
};
platform_i2c_driver_t platform_i2c_drivers[MICO_I2C_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_RESET ] = { IOPORT_CREATE_PIN( PIOA, 26 ), false, 0, 0 },
};
/* Wi-Fi gSPI bus pins. Used by platform/MCU/STM32F2xx/EMW1062_driver/wlan_spi.c */
const platform_gpio_t wifi_spi_pins[] =
{
[WIFI_PIN_SPI_IRQ ] = { IOPORT_CREATE_PIN( PIOA, 16 ), false, 0, 0 },
[WIFI_PIN_SPI_CS ] = { IOPORT_CREATE_PIN( PIOA, 11 ), false, 0, 0 },
[WIFI_PIN_SPI_CLK ] = { IOPORT_CREATE_PIN( PIOA, 14 ), false, 0, 0 },
[WIFI_PIN_SPI_MOSI] = { IOPORT_CREATE_PIN( PIOA, 13 ), false, 0, 0 },
[WIFI_PIN_SPI_MISO] = { IOPORT_CREATE_PIN( PIOA, 12 ), false, 0, 0 },
};
const platform_spi_t wifi_spi =
{
.spi_id = 5,
.port = SPI5,
.flexcom_base = FLEXCOM5,
.mosi_pin = &wifi_spi_pins[WIFI_PIN_SPI_MOSI],
.mosi_pin_mux_mode = IOPORT_MODE_MUX_A,
.miso_pin = &wifi_spi_pins[WIFI_PIN_SPI_MISO],
.miso_pin_mux_mode = IOPORT_MODE_MUX_A,
.clock_pin = &wifi_spi_pins[WIFI_PIN_SPI_CLK],
.clock_pin_mux_mode = IOPORT_MODE_MUX_A,
};
#if defined ( USE_MICO_SPI_FLASH )
const mico_spi_device_t mico_spi_flash =
{
.port = MICO_SPI_1,
.chip_select = FLASH_PIN_SPI_CS,
.speed = 40000000,
.mode = (SPI_CLOCK_RISING_EDGE | SPI_CLOCK_IDLE_HIGH | SPI_NO_DMA | SPI_MSB_FIRST),
.bits = 8,
};
#endif
/* Flash memory devices */
const platform_flash_t platform_flash_peripherals[] =
{
[MICO_FLASH_EMBEDDED] =
{
.flash_type = FLASH_TYPE_EMBEDDED,
.flash_start_addr = 0x00400000,
.flash_length = 0x80000,
},
[MICO_FLASH_SPI] =
{
.flash_type = FLASH_TYPE_SPI,
.flash_start_addr = 0x000000,
.flash_length = 0x200000,
},
};
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 = 0x00400000,
.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 = 0x00420000,
.partition_length = 0x60000, //384k bytes
.partition_options = PAR_OPT_READ_EN | PAR_OPT_WRITE_DIS,
},
[MICO_PARTITION_ATE] =
{
.partition_owner = MICO_FLASH_NONE,
},
[MICO_PARTITION_RF_FIRMWARE] =
{
.partition_owner = MICO_FLASH_SPI,
.partition_description = "RF Firmware",
.partition_start_addr = 0x2000,
.partition_length = 0x4E000, //312k bytes
.partition_options = PAR_OPT_READ_EN | PAR_OPT_WRITE_DIS,
},
[MICO_PARTITION_OTA_TEMP] =
{
.partition_owner = MICO_FLASH_SPI,
.partition_description = "OTA Storage",
.partition_start_addr = 0x50000,
.partition_length = 0x60000, //384k bytes
.partition_options = PAR_OPT_READ_EN | PAR_OPT_WRITE_EN,
},
[MICO_PARTITION_PARAMETER_1] =
{
.partition_owner = MICO_FLASH_SPI,
.partition_description = "PARAMETER1",
.partition_start_addr = 0x0,
.partition_length = 0x1000, // 4k bytes
.partition_options = PAR_OPT_READ_EN | PAR_OPT_WRITE_EN,
},
[MICO_PARTITION_PARAMETER_2] =
{
.partition_owner = MICO_FLASH_SPI,
.partition_description = "PARAMETER1",
.partition_start_addr = 0x1000,
.partition_length = 0x1000, //4k bytes
.partition_options = PAR_OPT_READ_EN | PAR_OPT_WRITE_EN,
}
};
/******************************************************
* Interrupt Handler Definitions
******************************************************/
MICO_RTOS_DEFINE_ISR( FLEXCOM0_Handler )
{
platform_uart_irq( &platform_uart_drivers[MICO_UART_1] );
}
MICO_RTOS_DEFINE_ISR( FLEXCOM6_Handler )
{
platform_uart_irq( &platform_uart_drivers[MICO_UART_2] );
}
#ifndef MICO_NO_WIFI
MICO_RTOS_DEFINE_ISR( FLEXCOM5_Handler )
{
platform_wifi_spi_rx_dma_irq( );
}
#endif
/******************************************************
* Function Definitions
******************************************************/
void platform_init_peripheral_irq_priorities( void )
{
NVIC_SetPriority ( PIOA_IRQn, 14 );
NVIC_SetPriority ( PIOB_IRQn, 14 );
NVIC_SetPriority ( FLEXCOM0_IRQn, 6 ); /* STDIO UART */
NVIC_SetPriority ( FLEXCOM5_IRQn, 3 ); /* WLAN SPI */
NVIC_SetPriority ( FLEXCOM3_IRQn, 3 ); /* I2C on Arduino */
NVIC_SetPriority ( RTT_IRQn, 1 ); /* RTT Wake-up event */
}
void init_platform( void )
{
button_init_t init;
MicoGpioInitialize( MICO_SYS_LED, OUTPUT_PUSH_PULL );
MicoGpioOutputHigh( MICO_SYS_LED );
MicoGpioInitialize( MICO_RF_LED, OUTPUT_OPEN_DRAIN_NO_PULL );
MicoGpioOutputHigh( 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 );
}
void init_platform_bootloader( void )
{
MicoGpioInitialize( MICO_SYS_LED, OUTPUT_PUSH_PULL );
MicoGpioOutputHigh( MICO_SYS_LED );
MicoGpioInitialize( MICO_RF_LED, OUTPUT_OPEN_DRAIN_NO_PULL );
MicoGpioOutputHigh( MICO_RF_LED );
MicoGpioInitialize(BOOT_SEL, INPUT_PULL_UP);
MicoGpioInitialize(MFG_SEL, INPUT_PULL_UP);
#ifdef USE_MiCOKit_EXT
MicoGpioInitialize( Arduino_D9, OUTPUT_PUSH_PULL );
MicoGpioOutputLow( Arduino_D9 );
#endif
}
void MicoSysLed(bool onoff)
{
if (onoff) {
MicoGpioOutputLow( (mico_gpio_t)MICO_SYS_LED );
} else {
MicoGpioOutputHigh( (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 "spi_flash_platform_interface.h"
#include "keypad/gpio_button/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 */
[STDIO_UART_TX] = { IOPORT_CREATE_PIN( PIOA, 10 ), false, 0, 0 },
[STDIO_UART_RX] = { IOPORT_CREATE_PIN( PIOA, 9 ), false, 0, 0 },
[FLASH_PIN_SPI_CS ] = { IOPORT_CREATE_PIN( PIOA, 30 ), false, 0, 0 },
[FLASH_PIN_SPI_CLK ] = { IOPORT_CREATE_PIN( PIOA, 29 ), false, 0, 0 },
[FLASH_PIN_SPI_MOSI] = { IOPORT_CREATE_PIN( PIOA, 28 ), false, 0, 0 },
[FLASH_PIN_SPI_MISO] = { IOPORT_CREATE_PIN( PIOA, 27 ), false, 0, 0 },
[MICO_SYS_LED] = { IOPORT_CREATE_PIN( PIOB, 10 ), false, 0, 0 },
[MICO_RF_LED] = { IOPORT_CREATE_PIN( PIOA, 24 ), false, 0, 0 },
[EasyLink_BUTTON] = { IOPORT_CREATE_PIN( PIOA, 2 ), false, 0, 0 },
[BOOT_SEL] = { IOPORT_CREATE_PIN( PIOB, 14 ), false, 0, 0 },
[MFG_SEL] = { IOPORT_CREATE_PIN( PIOB, 15 ), false, 0, 0 },
/* GPIOs for external use */
[Arduino_RXD] = { IOPORT_CREATE_PIN( PIOB, 1 ), false, 0, 0 },
[Arduino_TXD] = { IOPORT_CREATE_PIN( PIOB, 0 ), false, 0, 0 },
[Arduino_D2] = { IOPORT_CREATE_PIN( PIOA, 21 ), false, 0, 0 },
[Arduino_D3] = { IOPORT_CREATE_PIN( PIOA, 22 ), false, 0, 0 },
[Arduino_D4] = { IOPORT_CREATE_PIN( PIOA, 23 ), false, 0, 0 },
[Arduino_D5] = { IOPORT_CREATE_PIN( PIOA, 6 ), false, 0, 0 },
[Arduino_D6] = { IOPORT_CREATE_PIN( PIOA, 25 ), false, 0, 0 },
[Arduino_D7] = { IOPORT_CREATE_PIN( PIOB, 13 ), false, 0, 0 },
[Arduino_D8] = { IOPORT_CREATE_PIN( PIOA, 0 ), false, 0, 0 },
[Arduino_D9] = { IOPORT_CREATE_PIN( PIOA, 1 ), false, 0, 0 },
[Arduino_CS] = { IOPORT_CREATE_PIN( PIOA, 31 ), false, 0, 0 },
[Arduino_SI] = { IOPORT_CREATE_PIN( PIOA, 28 ), false, 0, 0 },
[Arduino_SO] = { IOPORT_CREATE_PIN( PIOA, 27 ), false, 0, 0 },
[Arduino_SCK] = { IOPORT_CREATE_PIN( PIOA, 29 ), false, 0, 0 },
[Arduino_SDA] = { IOPORT_CREATE_PIN( PIOA, 3 ), false, 0, 0 },
[Arduino_SCL] = { IOPORT_CREATE_PIN( PIOA, 4 ), false, 0, 0 },
};
const platform_adc_t platform_adc_peripherals[] =
{
[ Arduino_A0 ] = { ADC_CHANNEL_0, ADC_INTERRUPT_EOC_0, ADC_12_BITS },
[ Arduino_A1 ] = { ADC_CHANNEL_1, ADC_INTERRUPT_EOC_1, ADC_12_BITS },
[ Arduino_A2 ] = { ADC_CHANNEL_2, ADC_INTERRUPT_EOC_2, ADC_12_BITS },
[ Arduino_A3 ] = { ADC_CHANNEL_3, ADC_INTERRUPT_EOC_3, ADC_12_BITS },
[ Arduino_A4 ] = { ADC_CHANNEL_6, ADC_INTERRUPT_EOC_6, ADC_12_BITS },
[ Arduino_A5 ] = { ADC_CHANNEL_7, ADC_INTERRUPT_EOC_7, ADC_12_BITS },
};
/* PWM mappings */
const platform_pwm_t *platform_pwm_peripherals = NULL;
const platform_spi_t platform_spi_peripherals [] =
{
[MICO_SPI_1] =
{
.spi_id = 7,
.port = SPI7,
.flexcom_base = FLEXCOM7,
.peripheral_id = ID_FLEXCOM7,
.mosi_pin = &platform_gpio_pins[FLASH_PIN_SPI_MOSI],
.mosi_pin_mux_mode = IOPORT_MODE_MUX_B,
.miso_pin = &platform_gpio_pins[FLASH_PIN_SPI_MISO],
.miso_pin_mux_mode = IOPORT_MODE_MUX_B,
.clock_pin = &platform_gpio_pins[FLASH_PIN_SPI_CLK],
.clock_pin_mux_mode = IOPORT_MODE_MUX_B,
},
};
platform_spi_driver_t platform_spi_drivers[MICO_SPI_MAX];
const platform_uart_t platform_uart_peripherals[] =
{
[MICO_UART_1] =
{
.uart_id = 0,
.port = USART0,
.flexcom_base = FLEXCOM0,
.peripheral_id = ID_FLEXCOM0,
.tx_pin = &platform_gpio_pins[STDIO_UART_TX],
.tx_pin_mux_mode = IOPORT_MODE_MUX_A,
.rx_pin = &platform_gpio_pins[STDIO_UART_RX],
.rx_pin_mux_mode = IOPORT_MODE_MUX_A,
.cts_pin = NULL, /* flow control isn't supported */
.cts_pin_mux_mode = IOPORT_MODE_MUX_A,
.rts_pin = NULL, /* flow control isn't supported */
.rts_pin_mux_mode = IOPORT_MODE_MUX_A,
},
[MICO_UART_2] =
{
.uart_id = 6,
.port = USART6,
.flexcom_base = FLEXCOM6,
.peripheral_id = ID_FLEXCOM6,
.tx_pin = &platform_gpio_pins[Arduino_TXD],
.tx_pin_mux_mode = IOPORT_MODE_MUX_B,
.rx_pin = &platform_gpio_pins[Arduino_RXD],
.rx_pin_mux_mode = IOPORT_MODE_MUX_B,
.cts_pin = NULL, /* flow control isn't supported */
.cts_pin_mux_mode = IOPORT_MODE_MUX_B,
.rts_pin = NULL, /* flow control isn't supported */
.rts_pin_mux_mode = IOPORT_MODE_MUX_B,
},
};
platform_uart_driver_t platform_uart_drivers[MICO_UART_MAX];
const platform_i2c_t platform_i2c_peripherals[] =
{
[MICO_I2C_1] =
{
.i2c_id = 3,
.port = TWI3,
.flexcom_base = FLEXCOM3,
.peripheral_id = ID_FLEXCOM3,
.sda_pin = &platform_gpio_pins[Arduino_SDA],
.sda_pin_mux_mode = IOPORT_MODE_MUX_A,
.scl_pin = &platform_gpio_pins[Arduino_SCL],
.scl_pin_mux_mode = IOPORT_MODE_MUX_A,
},
};
platform_i2c_driver_t platform_i2c_drivers[MICO_I2C_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_RESET ] = { IOPORT_CREATE_PIN( PIOA, 26 ), false, 0, 0 },
};
/* Wi-Fi gSPI bus pins. Used by platform/MCU/STM32F2xx/EMW1062_driver/wlan_spi.c */
const platform_gpio_t wifi_spi_pins[] =
{
[WIFI_PIN_SPI_IRQ ] = { IOPORT_CREATE_PIN( PIOA, 16 ), false, 0, 0 },
[WIFI_PIN_SPI_CS ] = { IOPORT_CREATE_PIN( PIOA, 11 ), false, 0, 0 },
[WIFI_PIN_SPI_CLK ] = { IOPORT_CREATE_PIN( PIOA, 14 ), false, 0, 0 },
[WIFI_PIN_SPI_MOSI] = { IOPORT_CREATE_PIN( PIOA, 13 ), false, 0, 0 },
[WIFI_PIN_SPI_MISO] = { IOPORT_CREATE_PIN( PIOA, 12 ), false, 0, 0 },
};
const platform_spi_t wifi_spi =
{
.spi_id = 5,
.port = SPI5,
.flexcom_base = FLEXCOM5,
.mosi_pin = &wifi_spi_pins[WIFI_PIN_SPI_MOSI],
.mosi_pin_mux_mode = IOPORT_MODE_MUX_A,
.miso_pin = &wifi_spi_pins[WIFI_PIN_SPI_MISO],
.miso_pin_mux_mode = IOPORT_MODE_MUX_A,
.clock_pin = &wifi_spi_pins[WIFI_PIN_SPI_CLK],
.clock_pin_mux_mode = IOPORT_MODE_MUX_A,
};
#if defined ( USE_MICO_SPI_FLASH )
const mico_spi_device_t mico_spi_flash =
{
.port = MICO_SPI_1,
.chip_select = FLASH_PIN_SPI_CS,
.speed = 40000000,
.mode = (SPI_CLOCK_RISING_EDGE | SPI_CLOCK_IDLE_HIGH | SPI_NO_DMA | SPI_MSB_FIRST),
.bits = 8,
};
#endif
/* Flash memory devices */
const platform_flash_t platform_flash_peripherals[] =
{
[MICO_FLASH_EMBEDDED] =
{
.flash_type = FLASH_TYPE_EMBEDDED,
.flash_start_addr = 0x00400000,
.flash_length = 0x80000,
},
[MICO_FLASH_SPI] =
{
.flash_type = FLASH_TYPE_SPI,
.flash_start_addr = 0x000000,
.flash_length = 0x200000,
},
};
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 = 0x00400000,
.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 = 0x00420000,
.partition_length = 0x60000, //384k bytes
.partition_options = PAR_OPT_READ_EN | PAR_OPT_WRITE_DIS,
},
[MICO_PARTITION_ATE] =
{
.partition_owner = MICO_FLASH_NONE,
},
[MICO_PARTITION_RF_FIRMWARE] =
{
.partition_owner = MICO_FLASH_SPI,
.partition_description = "RF Firmware",
.partition_start_addr = 0x2000,
.partition_length = 0x4E000, //312k bytes
.partition_options = PAR_OPT_READ_EN | PAR_OPT_WRITE_DIS,
},
[MICO_PARTITION_OTA_TEMP] =
{
.partition_owner = MICO_FLASH_SPI,
.partition_description = "OTA Storage",
.partition_start_addr = 0x50000,
.partition_length = 0x60000, //384k bytes
.partition_options = PAR_OPT_READ_EN | PAR_OPT_WRITE_EN,
},
[MICO_PARTITION_PARAMETER_1] =
{
.partition_owner = MICO_FLASH_SPI,
.partition_description = "PARAMETER1",
.partition_start_addr = 0x0,
.partition_length = 0x1000, // 4k bytes
.partition_options = PAR_OPT_READ_EN | PAR_OPT_WRITE_EN,
},
[MICO_PARTITION_PARAMETER_2] =
{
.partition_owner = MICO_FLASH_SPI,
.partition_description = "PARAMETER1",
.partition_start_addr = 0x1000,
.partition_length = 0x1000, //4k bytes
.partition_options = PAR_OPT_READ_EN | PAR_OPT_WRITE_EN,
}
};
/******************************************************
* Interrupt Handler Definitions
******************************************************/
MICO_RTOS_DEFINE_ISR( FLEXCOM0_Handler )
{
platform_uart_irq( &platform_uart_drivers[MICO_UART_1] );
}
MICO_RTOS_DEFINE_ISR( FLEXCOM6_Handler )
{
platform_uart_irq( &platform_uart_drivers[MICO_UART_2] );
}
#ifndef MICO_NO_WIFI
MICO_RTOS_DEFINE_ISR( FLEXCOM5_Handler )
{
platform_wifi_spi_rx_dma_irq( );
}
#endif
/******************************************************
* Function Definitions
******************************************************/
void platform_init_peripheral_irq_priorities( void )
{
NVIC_SetPriority ( PIOA_IRQn, 14 );
NVIC_SetPriority ( PIOB_IRQn, 14 );
NVIC_SetPriority ( FLEXCOM0_IRQn, 6 ); /* STDIO UART */
NVIC_SetPriority ( FLEXCOM5_IRQn, 3 ); /* WLAN SPI */
NVIC_SetPriority ( FLEXCOM3_IRQn, 3 ); /* I2C on Arduino */
NVIC_SetPriority ( RTT_IRQn, 1 ); /* RTT Wake-up event */
}
void init_platform( void )
{
button_init_t init;
MicoGpioInitialize( MICO_SYS_LED, OUTPUT_PUSH_PULL );
MicoGpioOutputHigh( MICO_SYS_LED );
MicoGpioInitialize( MICO_RF_LED, OUTPUT_OPEN_DRAIN_NO_PULL );
MicoGpioOutputHigh( 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 );
}
void init_platform_bootloader( void )
{
MicoGpioInitialize( MICO_SYS_LED, OUTPUT_PUSH_PULL );
MicoGpioOutputHigh( MICO_SYS_LED );
MicoGpioInitialize( MICO_RF_LED, OUTPUT_OPEN_DRAIN_NO_PULL );
MicoGpioOutputHigh( MICO_RF_LED );
MicoGpioInitialize(BOOT_SEL, INPUT_PULL_UP);
MicoGpioInitialize(MFG_SEL, INPUT_PULL_UP);
#ifdef USE_MiCOKit_EXT
MicoGpioInitialize( Arduino_D9, OUTPUT_PUSH_PULL );
MicoGpioOutputLow( Arduino_D9 );
#endif
}
void MicoSysLed(bool onoff)
{
if (onoff) {
MicoGpioOutputLow( (mico_gpio_t)MICO_SYS_LED );
} else {
MicoGpioOutputHigh( (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,188 +1,194 @@
/**
******************************************************************************
* @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
#ifndef __PLATFORM_H__
#define __PLATFORM_H__
#ifdef __cplusplus
extern "C"
{
#endif
/******************************************************
* Macros
******************************************************/
/******************************************************
* Constants
******************************************************/
/******************************************************
* Enumerations
******************************************************/
typedef enum
{
STDIO_UART_TX,
STDIO_UART_RX,
FLASH_PIN_SPI_CS,
FLASH_PIN_SPI_CLK,
FLASH_PIN_SPI_MOSI,
FLASH_PIN_SPI_MISO,
MICO_SYS_LED,
MICO_RF_LED,
EasyLink_BUTTON,
BOOT_SEL,
MFG_SEL,
Arduino_RXD,
Arduino_TXD,
Arduino_D2,
Arduino_D3,
Arduino_D4,
Arduino_D5,
Arduino_D6,
Arduino_D7,
Arduino_D8,
Arduino_D9,
Arduino_CS,
Arduino_SI,
Arduino_SO,
Arduino_SCK,
Arduino_SDA,
Arduino_SCL,
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
{
Arduino_A0,
Arduino_A1,
Arduino_A2,
Arduino_A3,
Arduino_A4,
Arduino_A5,
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_SPI,
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 (115200)
#else
#define STDIO_UART MICO_UART_1
#define STDIO_UART_BAUDRATE (115200)
#endif
#define UART_FOR_APP MICO_UART_2
#define MFG_TEST MICO_UART_1
#define CLI_UART MICO_UART_1
#define USE_MICO_SPI_FLASH
//#define SFLASH_SUPPORT_MACRONIX_PARTS
//#define SFLASH_SUPPORT_SST_PARTS
#define SFLASH_SUPPORT_WINBOND_PARTS
#define USE_MiCOKit_EXT
/* I/O connection <-> Peripheral Connections */
#define Standby_SEL (MICO_GPIO_NONE)
#define Arduino_SPI (MICO_SPI_1)
#define Arduino_I2C (MICO_I2C_1)
#define Arduino_UART (MICO_UART_2)
#ifdef USE_MiCOKit_EXT
#define MICO_I2C_CP (MICO_I2C_NONE)
#include "micokit_ext_def.h"
#else
#define MICO_I2C_CP (MICO_I2C_NONE)
#endif //USE_MiCOKit_EXT
#ifdef __cplusplus
} /*extern "C" */
#endif
#endif // __PLATFORM__H__
/**
******************************************************************************
* @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
#ifndef __PLATFORM_H__
#define __PLATFORM_H__
#ifdef __cplusplus
extern "C"
{
#endif
/******************************************************
* Macros
******************************************************/
/******************************************************
* Constants
******************************************************/
/******************************************************
* Enumerations
******************************************************/
typedef enum
{
STDIO_UART_TX,
STDIO_UART_RX,
FLASH_PIN_SPI_CS,
FLASH_PIN_SPI_CLK,
FLASH_PIN_SPI_MOSI,
FLASH_PIN_SPI_MISO,
MICO_SYS_LED,
MICO_RF_LED,
EasyLink_BUTTON,
BOOT_SEL,
MFG_SEL,
Arduino_RXD,
Arduino_TXD,
Arduino_D2,
Arduino_D3,
Arduino_D4,
Arduino_D5,
Arduino_D6,
Arduino_D7,
Arduino_D8,
Arduino_D9,
Arduino_CS,
Arduino_SI,
Arduino_SO,
Arduino_SCK,
Arduino_SDA,
Arduino_SCL,
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
{
Arduino_A0,
Arduino_A1,
Arduino_A2,
Arduino_A3,
Arduino_A4,
Arduino_A5,
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_SPI,
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 (115200)
#else
#define STDIO_UART MICO_UART_1
#define STDIO_UART_BAUDRATE (115200)
#endif
#define UART_FOR_APP MICO_UART_2
#define MFG_TEST MICO_UART_1
#define CLI_UART MICO_UART_1
#define USE_MICO_SPI_FLASH
//#define SFLASH_SUPPORT_MACRONIX_PARTS
//#define SFLASH_SUPPORT_SST_PARTS
#define SFLASH_SUPPORT_WINBOND_PARTS
#define USE_MiCOKit_EXT
/* I/O connection <-> Peripheral Connections */
#define Standby_SEL (MICO_GPIO_NONE)
#define Arduino_SPI (MICO_SPI_1)
#define Arduino_I2C (MICO_I2C_1)
#define Arduino_UART (MICO_UART_2)
#ifdef USE_MiCOKit_EXT
#define MICO_I2C_CP (MICO_I2C_NONE)
#include "micokit_ext_def.h"
#else
#define MICO_I2C_CP (MICO_I2C_NONE)
#endif //USE_MiCOKit_EXT
#ifdef __cplusplus
} /*extern "C" */
#endif
#endif // __PLATFORM__H__

View File

@@ -1,198 +1,198 @@
/**
******************************************************************************
* @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_CONFIG_H__
#define __PLATFORM_CONFIG_H__
#pragma once
#ifdef __cplusplus
extern "C"
{
#endif
/******************************************************
* Macros
******************************************************/
/******************************************************
* Constants
******************************************************/
#define HARDWARE_REVISION "MKG55_1"
#define DEFAULT_NAME "MiCOKit G55"
#define MODEL "MiCOKit-G55"
/* 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
/** \name Resonator definitions
* @{ */
#define BOARD_FREQ_SLCK_XTAL (32768U)
#define BOARD_FREQ_SLCK_BYPASS (32768U)
#define BOARD_FREQ_MAINCK_XTAL 0 /* Not Mounted */
#define BOARD_FREQ_MAINCK_BYPASS 0 /* Not Mounted */
#define BOARD_MCK CHIP_FREQ_CPU_MAX
/*TBD startup time needs to be adjusted according to measurements */
#define BOARD_OSC_STARTUP_US 15625
/* ===== System Clock (MCK) Source Options */
/* #define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_SLCK_RC */
/* #define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_SLCK_XTAL */
/* #define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_SLCK_BYPASS */
/* #define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_MAINCK_8M_RC */
/* #define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_MAINCK_16M_RC */
/* #define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_MAINCK_24M_RC */
/* #define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_MAINCK_XTAL */
/* #define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_MAINCK_BYPASS */
#define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_PLLACK
/* ===== System Clock (MCK) Prescaler Options (Fmck = Fsys / (SYSCLK_PRES)) */
#define CONFIG_SYSCLK_PRES SYSCLK_PRES_1
/* #define CONFIG_SYSCLK_PRES SYSCLK_PRES_2 */
/* #define CONFIG_SYSCLK_PRES SYSCLK_PRES_4 */
/* #define CONFIG_SYSCLK_PRES SYSCLK_PRES_8 */
/* #define CONFIG_SYSCLK_PRES SYSCLK_PRES_16 */
/* #define CONFIG_SYSCLK_PRES SYSCLK_PRES_32 */
/* #define CONFIG_SYSCLK_PRES SYSCLK_PRES_64 */
/* #define CONFIG_SYSCLK_PRES SYSCLK_PRES_3 */
// ===== PLL0 (A) Options (Fpll = (Fclk * PLL_mul) / PLL_div)
// Use mul and div effective values here.
#define CONFIG_PLL0_SOURCE PLL_SRC_SLCK_XTAL
#define CONFIG_PLL0_MUL 3662
#define CONFIG_PLL0_DIV 1
// ===== Target frequency (System clock)
// - External XTAL frequency: 32768Hz
// - System clock source: SLCK XTAL
// - System clock prescaler: 1 (divided by 1)
// - PLLA source: SLCK_XTAL
// - PLLA output: SLCK_XTAL * 3662 / 1
// - System clock: SLCK_XTAL * 3662 / 1 / 1 = 120MHz
/* CPU clock : 48MHz */
#define CPU_CLOCK_HZ ( 120000000 )
/******************************************************
* 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
/* 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
//#define MICO_USE_BUILTIN_RF_DRIVER
/******************************************************
* Enumerations
******************************************************/
/******************************************************
* Type Definitions
******************************************************/
/******************************************************
* Structures
******************************************************/
/******************************************************
* Global Variables
******************************************************/
/******************************************************
* Function Declarations
******************************************************/
#ifdef __cplusplus
} /*extern "C" */
#endif
#endif // __PLATFORM_CONFIG_H__
/**
******************************************************************************
* @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_CONFIG_H__
#define __PLATFORM_CONFIG_H__
#pragma once
#ifdef __cplusplus
extern "C"
{
#endif
/******************************************************
* Macros
******************************************************/
/******************************************************
* Constants
******************************************************/
#define HARDWARE_REVISION "MKG55_1"
#define DEFAULT_NAME "MiCOKit G55"
#define MODEL "MiCOKit-G55"
/* 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
/** \name Resonator definitions
* @{ */
#define BOARD_FREQ_SLCK_XTAL (32768U)
#define BOARD_FREQ_SLCK_BYPASS (32768U)
#define BOARD_FREQ_MAINCK_XTAL 0 /* Not Mounted */
#define BOARD_FREQ_MAINCK_BYPASS 0 /* Not Mounted */
#define BOARD_MCK CHIP_FREQ_CPU_MAX
/*TBD startup time needs to be adjusted according to measurements */
#define BOARD_OSC_STARTUP_US 15625
/* ===== System Clock (MCK) Source Options */
/* #define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_SLCK_RC */
/* #define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_SLCK_XTAL */
/* #define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_SLCK_BYPASS */
/* #define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_MAINCK_8M_RC */
/* #define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_MAINCK_16M_RC */
/* #define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_MAINCK_24M_RC */
/* #define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_MAINCK_XTAL */
/* #define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_MAINCK_BYPASS */
#define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_PLLACK
/* ===== System Clock (MCK) Prescaler Options (Fmck = Fsys / (SYSCLK_PRES)) */
#define CONFIG_SYSCLK_PRES SYSCLK_PRES_1
/* #define CONFIG_SYSCLK_PRES SYSCLK_PRES_2 */
/* #define CONFIG_SYSCLK_PRES SYSCLK_PRES_4 */
/* #define CONFIG_SYSCLK_PRES SYSCLK_PRES_8 */
/* #define CONFIG_SYSCLK_PRES SYSCLK_PRES_16 */
/* #define CONFIG_SYSCLK_PRES SYSCLK_PRES_32 */
/* #define CONFIG_SYSCLK_PRES SYSCLK_PRES_64 */
/* #define CONFIG_SYSCLK_PRES SYSCLK_PRES_3 */
// ===== PLL0 (A) Options (Fpll = (Fclk * PLL_mul) / PLL_div)
// Use mul and div effective values here.
#define CONFIG_PLL0_SOURCE PLL_SRC_SLCK_XTAL
#define CONFIG_PLL0_MUL 3662
#define CONFIG_PLL0_DIV 1
// ===== Target frequency (System clock)
// - External XTAL frequency: 32768Hz
// - System clock source: SLCK XTAL
// - System clock prescaler: 1 (divided by 1)
// - PLLA source: SLCK_XTAL
// - PLLA output: SLCK_XTAL * 3662 / 1
// - System clock: SLCK_XTAL * 3662 / 1 / 1 = 120MHz
/* CPU clock : 48MHz */
#define CPU_CLOCK_HZ ( 120000000 )
/******************************************************
* 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
/* 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
//#define MICO_USE_BUILTIN_RF_DRIVER
/******************************************************
* Enumerations
******************************************************/
/******************************************************
* Type Definitions
******************************************************/
/******************************************************
* Structures
******************************************************/
/******************************************************
* Global Variables
******************************************************/
/******************************************************
* Function Declarations
******************************************************/
#ifdef __cplusplus
} /*extern "C" */
#endif
#endif // __PLATFORM_CONFIG_H__