mirror of
https://github.com/oopuuu/zTC1.git
synced 2025-12-14 22:18:14 +08:00
修复mico-sdk错误
This commit is contained in:
@@ -1,193 +1,193 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file platform.c
|
||||
* @author William Xu
|
||||
* @version V1.0.0
|
||||
* @date 05-Oct-2016
|
||||
* @brief This file provides all MICO Peripherals mapping table and platform
|
||||
* specific functions.
|
||||
******************************************************************************
|
||||
*
|
||||
* The MIT License
|
||||
* Copyright (c) 2016 MXCHIP Inc.
|
||||
*
|
||||
* Permission is hereby gra nted, 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 "common.h"
|
||||
#include "mico_platform.h"
|
||||
|
||||
#include "platform.h"
|
||||
#include "button.h"
|
||||
#include "moc_api.h"
|
||||
|
||||
#ifdef USE_MiCOKit_EXT
|
||||
#include "MiCOKit_EXT/micokit_ext.h"
|
||||
#endif
|
||||
|
||||
/******************************************************
|
||||
* Macros
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Constants
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Enumerations
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Type Definitions
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Structures
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Function Declarations
|
||||
******************************************************/
|
||||
extern WEAK void PlatformEasyLinkButtonClickedCallback(void);
|
||||
extern WEAK void PlatformEasyLinkButtonLongPressedCallback(void);
|
||||
|
||||
/******************************************************
|
||||
* Variables Definitions
|
||||
******************************************************/
|
||||
const mico_gpio_init_t gpio_init[] =
|
||||
{
|
||||
{MICO_GPIO_12, INPUT_PULL_UP, 0},
|
||||
{MICO_GPIO_13, INPUT_PULL_UP, 0},
|
||||
{MICO_GPIO_14, INPUT_PULL_UP, 0},
|
||||
{MICO_GPIO_NC, 0, 0}
|
||||
};
|
||||
|
||||
const mico_pwm_pinmap_t pwm_pinmap[] =
|
||||
{
|
||||
|
||||
[MICO_PWM_3] = {.pin = MICO_GPIO_12,},
|
||||
[MICO_PWM_4] = {.pin = MICO_GPIO_13,},
|
||||
[MICO_PWM_5] = {.pin = MICO_GPIO_14,},
|
||||
};
|
||||
|
||||
const mico_spi_pinmap_t spi_pinmap[] =
|
||||
{
|
||||
[MICO_SPI_1] =
|
||||
{
|
||||
.mosi = MICO_GPIO_9,
|
||||
.miso = MICO_GPIO_7,
|
||||
.sclk = MICO_GPIO_10,
|
||||
.ssel = MICO_GPIO_8,
|
||||
},
|
||||
};
|
||||
|
||||
const mico_uart_pinmap_t uart_pinmap[] =
|
||||
{
|
||||
[MICO_UART_1] =
|
||||
{
|
||||
.tx = MICO_GPIO_9,
|
||||
.rx = MICO_GPIO_10,
|
||||
.rts = MICO_GPIO_7,
|
||||
.cts = MICO_GPIO_8,
|
||||
},
|
||||
[MICO_UART_2] =
|
||||
{
|
||||
.tx = MICO_GPIO_21,
|
||||
.rx = MICO_GPIO_22,
|
||||
.rts = MICO_GPIO_NONE,
|
||||
.cts = MICO_GPIO_NONE,
|
||||
},
|
||||
};
|
||||
|
||||
const mico_i2c_pinmap_t i2c_pinmap[] =
|
||||
{
|
||||
[MICO_I2C_1] =
|
||||
{
|
||||
.sda = MICO_GPIO_8,
|
||||
.scl = MICO_GPIO_7,
|
||||
},
|
||||
};
|
||||
|
||||
const platform_peripherals_pinmap_t peripherals_pinmap =
|
||||
{
|
||||
.pwm_pinmap = pwm_pinmap,
|
||||
.spi_pinmap = spi_pinmap,
|
||||
.uart_pinmap = uart_pinmap,
|
||||
.i2c_pinmap = i2c_pinmap,
|
||||
};
|
||||
/******************************************************
|
||||
* Function Definitions
|
||||
******************************************************/
|
||||
void init_platform( void )
|
||||
{
|
||||
#if defined (MOC) && (MOC == 1)
|
||||
button_init_t init;
|
||||
extern int get_last_reset_reason(void);
|
||||
|
||||
if ( get_last_reset_reason() & LAST_RST_CAUSE_WDT )
|
||||
{
|
||||
platform_log( "WARNING: Watchdog reset occured previously." );
|
||||
}
|
||||
|
||||
MicoGpioInitialize( (mico_gpio_t)MICO_SYS_LED, OUTPUT_PUSH_PULL );
|
||||
MicoGpioOutputLow( (mico_gpio_t)MICO_SYS_LED );
|
||||
|
||||
// Initialise EasyLink buttons
|
||||
init.gpio = EasyLink_BUTTON;
|
||||
init.pressed_func = PlatformEasyLinkButtonClickedCallback;
|
||||
init.long_pressed_func = PlatformEasyLinkButtonLongPressedCallback;
|
||||
init.long_pressed_timeout = RestoreDefault_TimeOut;
|
||||
|
||||
button_init( IOBUTTON_EASYLINK, init );
|
||||
#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 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef USE_MiCOKit_EXT
|
||||
// add test mode for MiCOKit-EXT board,check Arduino_D5 pin when system startup
|
||||
bool MicoExtShouldEnterTestMode(void)
|
||||
{
|
||||
if( MicoGpioInputGet((mico_gpio_t)Arduino_D5)==false ){
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file platform.c
|
||||
* @author William Xu
|
||||
* @version V1.0.0
|
||||
* @date 05-Oct-2016
|
||||
* @brief This file provides all MICO Peripherals mapping table and platform
|
||||
* specific functions.
|
||||
******************************************************************************
|
||||
*
|
||||
* The MIT License
|
||||
* Copyright (c) 2016 MXCHIP Inc.
|
||||
*
|
||||
* Permission is hereby gra nted, 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 "common.h"
|
||||
#include "mico_platform.h"
|
||||
|
||||
#include "platform.h"
|
||||
#include "button.h"
|
||||
#include "moc_api.h"
|
||||
|
||||
#ifdef USE_MiCOKit_EXT
|
||||
#include "MiCOKit_EXT/micokit_ext.h"
|
||||
#endif
|
||||
|
||||
/******************************************************
|
||||
* Macros
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Constants
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Enumerations
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Type Definitions
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Structures
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Function Declarations
|
||||
******************************************************/
|
||||
extern WEAK void PlatformEasyLinkButtonClickedCallback(void);
|
||||
extern WEAK void PlatformEasyLinkButtonLongPressedCallback(void);
|
||||
|
||||
/******************************************************
|
||||
* Variables Definitions
|
||||
******************************************************/
|
||||
const mico_gpio_init_t gpio_init[] =
|
||||
{
|
||||
{MICO_GPIO_12, INPUT_PULL_UP, 0},
|
||||
{MICO_GPIO_13, INPUT_PULL_UP, 0},
|
||||
{MICO_GPIO_14, INPUT_PULL_UP, 0},
|
||||
{MICO_GPIO_NC, 0, 0}
|
||||
};
|
||||
|
||||
const mico_pwm_pinmap_t pwm_pinmap[] =
|
||||
{
|
||||
|
||||
[MICO_PWM_3] = {.pin = MICO_GPIO_12,},
|
||||
[MICO_PWM_4] = {.pin = MICO_GPIO_13,},
|
||||
[MICO_PWM_5] = {.pin = MICO_GPIO_14,},
|
||||
};
|
||||
|
||||
const mico_spi_pinmap_t spi_pinmap[] =
|
||||
{
|
||||
[MICO_SPI_1] =
|
||||
{
|
||||
.mosi = MICO_GPIO_9,
|
||||
.miso = MICO_GPIO_7,
|
||||
.sclk = MICO_GPIO_10,
|
||||
.ssel = MICO_GPIO_8,
|
||||
},
|
||||
};
|
||||
|
||||
const mico_uart_pinmap_t uart_pinmap[] =
|
||||
{
|
||||
[MICO_UART_1] =
|
||||
{
|
||||
.tx = MICO_GPIO_9,
|
||||
.rx = MICO_GPIO_10,
|
||||
.rts = MICO_GPIO_7,
|
||||
.cts = MICO_GPIO_8,
|
||||
},
|
||||
[MICO_UART_2] =
|
||||
{
|
||||
.tx = MICO_GPIO_21,
|
||||
.rx = MICO_GPIO_22,
|
||||
.rts = MICO_GPIO_NONE,
|
||||
.cts = MICO_GPIO_NONE,
|
||||
},
|
||||
};
|
||||
|
||||
const mico_i2c_pinmap_t i2c_pinmap[] =
|
||||
{
|
||||
[MICO_I2C_1] =
|
||||
{
|
||||
.sda = MICO_GPIO_8,
|
||||
.scl = MICO_GPIO_7,
|
||||
},
|
||||
};
|
||||
|
||||
const platform_peripherals_pinmap_t peripherals_pinmap =
|
||||
{
|
||||
.pwm_pinmap = pwm_pinmap,
|
||||
.spi_pinmap = spi_pinmap,
|
||||
.uart_pinmap = uart_pinmap,
|
||||
.i2c_pinmap = i2c_pinmap,
|
||||
};
|
||||
/******************************************************
|
||||
* Function Definitions
|
||||
******************************************************/
|
||||
void init_platform( void )
|
||||
{
|
||||
#if defined (MOC) && (MOC == 1)
|
||||
button_init_t init;
|
||||
extern int get_last_reset_reason(void);
|
||||
|
||||
if ( get_last_reset_reason() & LAST_RST_CAUSE_WDT )
|
||||
{
|
||||
platform_log( "WARNING: Watchdog reset occured previously." );
|
||||
}
|
||||
|
||||
MicoGpioInitialize( (mico_gpio_t)MICO_SYS_LED, OUTPUT_PUSH_PULL );
|
||||
MicoGpioOutputLow( (mico_gpio_t)MICO_SYS_LED );
|
||||
|
||||
// Initialise EasyLink buttons
|
||||
init.gpio = EasyLink_BUTTON;
|
||||
init.pressed_func = PlatformEasyLinkButtonClickedCallback;
|
||||
init.long_pressed_func = PlatformEasyLinkButtonLongPressedCallback;
|
||||
init.long_pressed_timeout = RestoreDefault_TimeOut;
|
||||
|
||||
button_init( IOBUTTON_EASYLINK, init );
|
||||
#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 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef USE_MiCOKit_EXT
|
||||
// add test mode for MiCOKit-EXT board,check Arduino_D5 pin when system startup
|
||||
bool MicoExtShouldEnterTestMode(void)
|
||||
{
|
||||
if( MicoGpioInputGet((mico_gpio_t)Arduino_D5)==false ){
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -1,231 +1,237 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file platform.h
|
||||
* @author William Xu
|
||||
* @version V1.0.0
|
||||
* @date 05-Oct-2016
|
||||
* @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
|
||||
******************************************************/
|
||||
typedef enum
|
||||
{
|
||||
MICO_GPIO_1,
|
||||
MICO_GPIO_2,
|
||||
MICO_GPIO_7,
|
||||
MICO_GPIO_8,
|
||||
MICO_GPIO_9,
|
||||
MICO_GPIO_10,
|
||||
MICO_GPIO_12,
|
||||
MICO_GPIO_13,
|
||||
MICO_GPIO_14,
|
||||
MICO_GPIO_19,
|
||||
MICO_GPIO_21,
|
||||
MICO_GPIO_22,
|
||||
MICO_GPIO_23,
|
||||
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_3,
|
||||
MICO_PWM_4,
|
||||
MICO_PWM_5,
|
||||
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_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_SPI,
|
||||
MICO_FLASH_MAX,
|
||||
MICO_FLASH_NONE,
|
||||
} mico_flash_t;
|
||||
|
||||
/* Donot change MICO_PARTITION_USER_MAX!! */
|
||||
typedef enum
|
||||
{
|
||||
MICO_PARTITION_USER_MAX = 0,
|
||||
MICO_PARTITION_USER = 7,
|
||||
MICO_PARTITION_SDS,
|
||||
} mico_user_partition_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
mico_gpio_t pin;
|
||||
unsigned char config; /* @ref mico_gpio_config_t */
|
||||
unsigned char out; /* 0: low, 1: high */
|
||||
}mico_gpio_init_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
mico_gpio_t pin;
|
||||
} mico_pwm_pinmap_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
mico_gpio_t mosi;
|
||||
mico_gpio_t miso;
|
||||
mico_gpio_t sclk;
|
||||
mico_gpio_t ssel;
|
||||
} mico_spi_pinmap_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
mico_gpio_t tx;
|
||||
mico_gpio_t rx;
|
||||
mico_gpio_t rts;
|
||||
mico_gpio_t cts;
|
||||
} mico_uart_pinmap_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
mico_gpio_t sda;
|
||||
mico_gpio_t scl;
|
||||
} mico_i2c_pinmap_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const mico_pwm_pinmap_t *pwm_pinmap;
|
||||
const mico_spi_pinmap_t *spi_pinmap;
|
||||
const mico_uart_pinmap_t *uart_pinmap;
|
||||
const mico_i2c_pinmap_t *i2c_pinmap;
|
||||
} platform_peripherals_pinmap_t;
|
||||
|
||||
#define STDIO_UART MICO_UART_2
|
||||
#define STDIO_UART_BAUDRATE (115200)
|
||||
|
||||
#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 BOOT_SEL MICO_GPIO_19
|
||||
#define MFG_SEL MICO_GPIO_NONE
|
||||
#define MICO_RF_LED MICO_GPIO_NONE
|
||||
#define MICO_SYS_LED MICO_GPIO_19
|
||||
#define EasyLink_BUTTON MICO_GPIO_23
|
||||
|
||||
#define MICO_GPIO_NC 0xFF
|
||||
|
||||
typedef struct {
|
||||
int country_code;
|
||||
int enable_healthmon;
|
||||
int dhcp_arp_check;
|
||||
} mico_system_config_t;
|
||||
|
||||
/* Arduino extention connector */
|
||||
#define Arduino_RXD (MICO_GPIO_23)
|
||||
#define Arduino_TXD (MICO_GPIO_18)
|
||||
#define Arduino_D2 (MICO_GPIO_NONE)
|
||||
#define Arduino_D3 (MICO_GPIO_NONE)
|
||||
#define Arduino_D4 (MICO_GPIO_NONE)
|
||||
#define Arduino_D5 (MICO_GPIO_NONE)
|
||||
#define Arduino_D6 (MICO_GPIO_NONE)
|
||||
#define Arduino_D7 (MICO_GPIO_NONE)
|
||||
|
||||
#define Arduino_D8 (MICO_GPIO_NONE)
|
||||
#define Arduino_D9 (MICO_GPIO_NONE)
|
||||
#define Arduino_CS (MICO_GPIO_8)
|
||||
#define Arduino_SI (MICO_GPIO_9)
|
||||
#define Arduino_SO (MICO_GPIO_7)
|
||||
#define Arduino_SCK (MICO_GPIO_10)
|
||||
#define Arduino_SDA (MICO_GPIO_8)
|
||||
#define Arduino_SCL (MICO_GPIO_7)
|
||||
|
||||
#define Arduino_A0 (MICO_ADC_NONE)
|
||||
#define Arduino_A1 (MICO_ADC_NONE)
|
||||
#define Arduino_A2 (MICO_ADC_NONE)
|
||||
#define Arduino_A3 (MICO_ADC_NONE)
|
||||
#define Arduino_A4 (MICO_ADC_NONE)
|
||||
#define Arduino_A5 (MICO_ADC_NONE)
|
||||
|
||||
#define Arduino_I2C (MICO_I2C_1)
|
||||
#define Arduino_SPI (MICO_SPI_1)
|
||||
#define Arduino_UART (MICO_UART_1)
|
||||
|
||||
#ifdef USE_MiCOKit_EXT
|
||||
#define MICO_I2C_CP (Arduino_I2C)
|
||||
#include "micokit_ext_def.h"
|
||||
#else
|
||||
#define MICO_I2C_CP (MICO_I2C_NONE)
|
||||
#endif //USE_MiCOKit_EXT
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C" */
|
||||
#endif
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file platform.h
|
||||
* @author William Xu
|
||||
* @version V1.0.0
|
||||
* @date 05-Oct-2016
|
||||
* @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
|
||||
******************************************************/
|
||||
typedef enum
|
||||
{
|
||||
MICO_GPIO_1,
|
||||
MICO_GPIO_2,
|
||||
MICO_GPIO_7,
|
||||
MICO_GPIO_8,
|
||||
MICO_GPIO_9,
|
||||
MICO_GPIO_10,
|
||||
MICO_GPIO_12,
|
||||
MICO_GPIO_13,
|
||||
MICO_GPIO_14,
|
||||
MICO_GPIO_19,
|
||||
MICO_GPIO_21,
|
||||
MICO_GPIO_22,
|
||||
MICO_GPIO_23,
|
||||
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_3,
|
||||
MICO_PWM_4,
|
||||
MICO_PWM_5,
|
||||
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_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_SPI,
|
||||
MICO_FLASH_MAX,
|
||||
MICO_FLASH_NONE,
|
||||
} mico_flash_t;
|
||||
|
||||
/* Donot change MICO_PARTITION_USER_MAX!! */
|
||||
typedef enum
|
||||
{
|
||||
MICO_PARTITION_USER_MAX = 0,
|
||||
MICO_PARTITION_USER = 7,
|
||||
MICO_PARTITION_SDS,
|
||||
} mico_user_partition_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
mico_gpio_t pin;
|
||||
unsigned char config; /* @ref mico_gpio_config_t */
|
||||
unsigned char out; /* 0: low, 1: high */
|
||||
}mico_gpio_init_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
mico_gpio_t pin;
|
||||
} mico_pwm_pinmap_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
mico_gpio_t mosi;
|
||||
mico_gpio_t miso;
|
||||
mico_gpio_t sclk;
|
||||
mico_gpio_t ssel;
|
||||
} mico_spi_pinmap_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
mico_gpio_t tx;
|
||||
mico_gpio_t rx;
|
||||
mico_gpio_t rts;
|
||||
mico_gpio_t cts;
|
||||
} mico_uart_pinmap_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
mico_gpio_t sda;
|
||||
mico_gpio_t scl;
|
||||
} mico_i2c_pinmap_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const mico_pwm_pinmap_t *pwm_pinmap;
|
||||
const mico_spi_pinmap_t *spi_pinmap;
|
||||
const mico_uart_pinmap_t *uart_pinmap;
|
||||
const mico_i2c_pinmap_t *i2c_pinmap;
|
||||
} platform_peripherals_pinmap_t;
|
||||
|
||||
#define STDIO_UART MICO_UART_2
|
||||
#define STDIO_UART_BAUDRATE (115200)
|
||||
|
||||
#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 BOOT_SEL MICO_GPIO_19
|
||||
#define MFG_SEL MICO_GPIO_NONE
|
||||
#define MICO_RF_LED MICO_GPIO_NONE
|
||||
#define MICO_SYS_LED MICO_GPIO_19
|
||||
#define EasyLink_BUTTON MICO_GPIO_23
|
||||
|
||||
#define MICO_GPIO_NC 0xFF
|
||||
|
||||
typedef struct {
|
||||
int country_code;
|
||||
int enable_healthmon;
|
||||
int dhcp_arp_check;
|
||||
} mico_system_config_t;
|
||||
|
||||
/* Arduino extention connector */
|
||||
#define Arduino_RXD (MICO_GPIO_23)
|
||||
#define Arduino_TXD (MICO_GPIO_18)
|
||||
#define Arduino_D2 (MICO_GPIO_NONE)
|
||||
#define Arduino_D3 (MICO_GPIO_NONE)
|
||||
#define Arduino_D4 (MICO_GPIO_NONE)
|
||||
#define Arduino_D5 (MICO_GPIO_NONE)
|
||||
#define Arduino_D6 (MICO_GPIO_NONE)
|
||||
#define Arduino_D7 (MICO_GPIO_NONE)
|
||||
|
||||
#define Arduino_D8 (MICO_GPIO_NONE)
|
||||
#define Arduino_D9 (MICO_GPIO_NONE)
|
||||
#define Arduino_CS (MICO_GPIO_8)
|
||||
#define Arduino_SI (MICO_GPIO_9)
|
||||
#define Arduino_SO (MICO_GPIO_7)
|
||||
#define Arduino_SCK (MICO_GPIO_10)
|
||||
#define Arduino_SDA (MICO_GPIO_8)
|
||||
#define Arduino_SCL (MICO_GPIO_7)
|
||||
|
||||
#define Arduino_A0 (MICO_ADC_NONE)
|
||||
#define Arduino_A1 (MICO_ADC_NONE)
|
||||
#define Arduino_A2 (MICO_ADC_NONE)
|
||||
#define Arduino_A3 (MICO_ADC_NONE)
|
||||
#define Arduino_A4 (MICO_ADC_NONE)
|
||||
#define Arduino_A5 (MICO_ADC_NONE)
|
||||
|
||||
#define Arduino_I2C (MICO_I2C_1)
|
||||
#define Arduino_SPI (MICO_SPI_1)
|
||||
#define Arduino_UART (MICO_UART_1)
|
||||
|
||||
#ifdef USE_MiCOKit_EXT
|
||||
#define MICO_I2C_CP (Arduino_I2C)
|
||||
#include "micokit_ext_def.h"
|
||||
#else
|
||||
#define MICO_I2C_CP (MICO_I2C_NONE)
|
||||
#endif //USE_MiCOKit_EXT
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C" */
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,108 +1,108 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file platform_config.h
|
||||
* @author William Xu
|
||||
* @version V1.0.0
|
||||
* @date 05-Oct-2016
|
||||
* @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.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __PLATFORM_COMMON_CONFIG_H__
|
||||
#define __PLATFORM_COMMON_CONFIG_H__
|
||||
|
||||
|
||||
/******************************************************
|
||||
* Macros
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Constants
|
||||
******************************************************/
|
||||
|
||||
#define HARDWARE_REVISION "3080C"
|
||||
#define DEFAULT_NAME "EMW3080C Module"
|
||||
#define MODEL "EMW3080C"
|
||||
|
||||
/* 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)
|
||||
|
||||
/************************************************************************
|
||||
* CPU clock */
|
||||
#define MCU_CLOCK_HZ (100000000)
|
||||
|
||||
/************************************************************************
|
||||
* 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
|
||||
|
||||
/************************************************************************
|
||||
* Platform provide OTA temporary partition as secondary application partition */
|
||||
//#define MICO_ENABLE_SECONDARY_APPLICATION
|
||||
|
||||
/******************************************************
|
||||
* Enumerations
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Type Definitions
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Structures
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Global Variables
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Function Declarations
|
||||
******************************************************/
|
||||
#endif
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file platform_config.h
|
||||
* @author William Xu
|
||||
* @version V1.0.0
|
||||
* @date 05-Oct-2016
|
||||
* @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.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __PLATFORM_COMMON_CONFIG_H__
|
||||
#define __PLATFORM_COMMON_CONFIG_H__
|
||||
|
||||
|
||||
/******************************************************
|
||||
* Macros
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Constants
|
||||
******************************************************/
|
||||
|
||||
#define HARDWARE_REVISION "3080C"
|
||||
#define DEFAULT_NAME "EMW3080C Module"
|
||||
#define MODEL "EMW3080C"
|
||||
|
||||
/* 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)
|
||||
|
||||
/************************************************************************
|
||||
* CPU clock */
|
||||
#define MCU_CLOCK_HZ (100000000)
|
||||
|
||||
/************************************************************************
|
||||
* 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
|
||||
|
||||
/************************************************************************
|
||||
* Platform provide OTA temporary partition as secondary application partition */
|
||||
//#define MICO_ENABLE_SECONDARY_APPLICATION
|
||||
|
||||
/******************************************************
|
||||
* Enumerations
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Type Definitions
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Structures
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Global Variables
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Function Declarations
|
||||
******************************************************/
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user