├── .gitignore ├── GoKit3ForOpenHamtaro ├── README.md ├── Dal │ ├── dal_rb.h │ └── dal_rb.c ├── User │ ├── main.c │ ├── zigbee_ha.c │ ├── zigbee_ha.h │ ├── header.h │ ├── delay.h │ ├── delay.c │ ├── stm32f10x_it.h │ ├── stm32f10x_conf.h │ └── stm32f10x_it.c ├── Lib │ ├── CMSIS │ │ ├── License.doc │ │ ├── CMSIS debug support.htm │ │ ├── Documentation │ │ │ └── CMSIS_Core.htm │ │ └── CM3 │ │ │ └── DeviceSupport │ │ │ └── ST │ │ │ └── STM32F10x │ │ │ ├── stm32f10x.h │ │ │ └── system_stm32f10x.h │ └── STM32F10x_StdPeriph_Driver │ │ ├── src │ │ ├── stm32f10x_flash.c │ │ ├── stm32f10x_i2c.c │ │ ├── stm32f10x_usart.c │ │ ├── stm32f10x_crc.c │ │ ├── stm32f10x_iwdg.c │ │ ├── stm32f10x_dbgmcu.c │ │ └── stm32f10x_wwdg.c │ │ └── inc │ │ ├── stm32f10x_crc.h │ │ ├── stm32f10x_wwdg.h │ │ ├── stm32f10x_dbgmcu.h │ │ ├── stm32f10x_iwdg.h │ │ ├── stm32f10x_rtc.h │ │ └── stm32f10x_pwr.h ├── Hal │ ├── Hal_Usart │ │ ├── hal_uart.c │ │ └── hal_uart.h │ ├── Hal_Watchdog │ │ ├── hal_watchdog.h │ │ └── hal_watchdog.c │ ├── Hal_infrared │ │ ├── Hal_infrared.h │ │ └── hal_infrared.c │ ├── hal_motor │ │ ├── Hal_motor.h │ │ └── hal_motor.c │ ├── Hal_rgb_led │ │ ├── Hal_rgb_led.h │ │ └── hal_rgb_led.c │ ├── Hal_led │ │ ├── Hal_led.h │ │ └── Hal_led.c │ ├── hal_temp_hum │ │ ├── Hal_temp_hum.h │ │ ├── sys.h │ │ └── hal_temp_hum.c │ └── Hal_key │ │ └── Hal_key.h ├── Docs │ ├── 仓鼠管家-机智云接入串口通信协议文档.pdf │ └── 仓鼠管家-机智云接入JSON文档.json └── Gizwits │ ├── gizwits_product.c │ ├── gizwits_protocol.c │ ├── gizwits_protocol.h │ └── gizwits_product.h ├── ISD9160ForOpenHamtaro ├── Lib │ └── libSPIFlash.lib ├── NuvotonPlatform_Keil │ ├── Lib │ │ ├── LibAdpacm.lib │ │ ├── LibSiren7.lib │ │ ├── libSPIFlash.lib │ │ ├── SemiHost_Keil.lib │ │ ├── libSPIFlash.lib_old │ │ └── BNDetection16b_Keil.lib │ ├── Src │ │ ├── Driver │ │ │ ├── DrvPWM.c │ │ │ ├── DrvSPI.c │ │ │ ├── DrvCapSense.c │ │ │ └── retarget.c │ │ └── retarget.c │ ├── Sample │ │ └── CSpotter_OpenHamtaro │ │ │ ├── VR_sep.c │ │ │ ├── CSpotterSDK16k24d.lib │ │ │ ├── base_types.h │ │ │ ├── CSpotterSDKApi_Const.h │ │ │ └── CSpotterSDKApi.h │ └── Include │ │ ├── SemiHost.h │ │ ├── Driver │ │ ├── DrvOSC.h │ │ ├── DrvCRC.h │ │ ├── DrvCapSense.h │ │ ├── DrvACMP.H │ │ ├── DrvDPWM.h │ │ ├── DrvBODTALARM.H │ │ ├── DrvALC.H │ │ ├── DrvPMU.H │ │ ├── DrvI2C.h │ │ ├── DrvFMC_20120320.h │ │ ├── DrvFMC.h │ │ ├── DrvSDCard.h │ │ └── DrvGPIO.h │ │ ├── Lib │ │ ├── libSPIFlash.h │ │ ├── libSPIFlash.h.bak │ │ ├── LibAdpcmCodec.h │ │ └── LibSiren7.h │ │ └── System │ │ └── SysInfra.h └── CMSIS │ └── CM0 │ └── DeviceSupport │ └── Nuvoton │ └── ISD91xx │ ├── system_ISD9xx.c │ ├── system_ISD9xx.h │ ├── boot_ISD9xx.c │ └── startup_ISD9xx.c └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | /GoKit3ForOpenHamtaro/Project 2 | /GoKit3ForOpenHamtaro/SI -------------------------------------------------------------------------------- /GoKit3ForOpenHamtaro/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/twowinter/OpenHamtaro/HEAD/GoKit3ForOpenHamtaro/README.md -------------------------------------------------------------------------------- /GoKit3ForOpenHamtaro/Dal/dal_rb.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/twowinter/OpenHamtaro/HEAD/GoKit3ForOpenHamtaro/Dal/dal_rb.h -------------------------------------------------------------------------------- /GoKit3ForOpenHamtaro/User/main.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/twowinter/OpenHamtaro/HEAD/GoKit3ForOpenHamtaro/User/main.c -------------------------------------------------------------------------------- /GoKit3ForOpenHamtaro/User/zigbee_ha.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/twowinter/OpenHamtaro/HEAD/GoKit3ForOpenHamtaro/User/zigbee_ha.c -------------------------------------------------------------------------------- /GoKit3ForOpenHamtaro/User/zigbee_ha.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/twowinter/OpenHamtaro/HEAD/GoKit3ForOpenHamtaro/User/zigbee_ha.h -------------------------------------------------------------------------------- /GoKit3ForOpenHamtaro/Lib/CMSIS/License.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/twowinter/OpenHamtaro/HEAD/GoKit3ForOpenHamtaro/Lib/CMSIS/License.doc -------------------------------------------------------------------------------- /ISD9160ForOpenHamtaro/Lib/libSPIFlash.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/twowinter/OpenHamtaro/HEAD/ISD9160ForOpenHamtaro/Lib/libSPIFlash.lib -------------------------------------------------------------------------------- /GoKit3ForOpenHamtaro/Hal/Hal_Usart/hal_uart.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/twowinter/OpenHamtaro/HEAD/GoKit3ForOpenHamtaro/Hal/Hal_Usart/hal_uart.c -------------------------------------------------------------------------------- /GoKit3ForOpenHamtaro/Docs/仓鼠管家-机智云接入串口通信协议文档.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/twowinter/OpenHamtaro/HEAD/GoKit3ForOpenHamtaro/Docs/仓鼠管家-机智云接入串口通信协议文档.pdf -------------------------------------------------------------------------------- /GoKit3ForOpenHamtaro/Gizwits/gizwits_product.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/twowinter/OpenHamtaro/HEAD/GoKit3ForOpenHamtaro/Gizwits/gizwits_product.c -------------------------------------------------------------------------------- /GoKit3ForOpenHamtaro/Gizwits/gizwits_protocol.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/twowinter/OpenHamtaro/HEAD/GoKit3ForOpenHamtaro/Gizwits/gizwits_protocol.c -------------------------------------------------------------------------------- /GoKit3ForOpenHamtaro/Gizwits/gizwits_protocol.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/twowinter/OpenHamtaro/HEAD/GoKit3ForOpenHamtaro/Gizwits/gizwits_protocol.h -------------------------------------------------------------------------------- /GoKit3ForOpenHamtaro/Lib/CMSIS/CMSIS debug support.htm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/twowinter/OpenHamtaro/HEAD/GoKit3ForOpenHamtaro/Lib/CMSIS/CMSIS debug support.htm -------------------------------------------------------------------------------- /GoKit3ForOpenHamtaro/User/header.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ifndef _HEADER_H 4 | #define _HEADER_H 5 | 6 | #define EN_DEBUG 0 7 | 8 | 9 | 10 | 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /GoKit3ForOpenHamtaro/Lib/CMSIS/Documentation/CMSIS_Core.htm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/twowinter/OpenHamtaro/HEAD/GoKit3ForOpenHamtaro/Lib/CMSIS/Documentation/CMSIS_Core.htm -------------------------------------------------------------------------------- /ISD9160ForOpenHamtaro/NuvotonPlatform_Keil/Lib/LibAdpacm.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/twowinter/OpenHamtaro/HEAD/ISD9160ForOpenHamtaro/NuvotonPlatform_Keil/Lib/LibAdpacm.lib -------------------------------------------------------------------------------- /ISD9160ForOpenHamtaro/NuvotonPlatform_Keil/Lib/LibSiren7.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/twowinter/OpenHamtaro/HEAD/ISD9160ForOpenHamtaro/NuvotonPlatform_Keil/Lib/LibSiren7.lib -------------------------------------------------------------------------------- /ISD9160ForOpenHamtaro/NuvotonPlatform_Keil/Lib/libSPIFlash.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/twowinter/OpenHamtaro/HEAD/ISD9160ForOpenHamtaro/NuvotonPlatform_Keil/Lib/libSPIFlash.lib -------------------------------------------------------------------------------- /ISD9160ForOpenHamtaro/NuvotonPlatform_Keil/Src/Driver/DrvPWM.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/twowinter/OpenHamtaro/HEAD/ISD9160ForOpenHamtaro/NuvotonPlatform_Keil/Src/Driver/DrvPWM.c -------------------------------------------------------------------------------- /ISD9160ForOpenHamtaro/NuvotonPlatform_Keil/Src/Driver/DrvSPI.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/twowinter/OpenHamtaro/HEAD/ISD9160ForOpenHamtaro/NuvotonPlatform_Keil/Src/Driver/DrvSPI.c -------------------------------------------------------------------------------- /ISD9160ForOpenHamtaro/NuvotonPlatform_Keil/Lib/SemiHost_Keil.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/twowinter/OpenHamtaro/HEAD/ISD9160ForOpenHamtaro/NuvotonPlatform_Keil/Lib/SemiHost_Keil.lib -------------------------------------------------------------------------------- /ISD9160ForOpenHamtaro/NuvotonPlatform_Keil/Lib/libSPIFlash.lib_old: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/twowinter/OpenHamtaro/HEAD/ISD9160ForOpenHamtaro/NuvotonPlatform_Keil/Lib/libSPIFlash.lib_old -------------------------------------------------------------------------------- /ISD9160ForOpenHamtaro/NuvotonPlatform_Keil/Lib/BNDetection16b_Keil.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/twowinter/OpenHamtaro/HEAD/ISD9160ForOpenHamtaro/NuvotonPlatform_Keil/Lib/BNDetection16b_Keil.lib -------------------------------------------------------------------------------- /GoKit3ForOpenHamtaro/Lib/CMSIS/CM3/DeviceSupport/ST/STM32F10x/stm32f10x.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/twowinter/OpenHamtaro/HEAD/GoKit3ForOpenHamtaro/Lib/CMSIS/CM3/DeviceSupport/ST/STM32F10x/stm32f10x.h -------------------------------------------------------------------------------- /GoKit3ForOpenHamtaro/Lib/STM32F10x_StdPeriph_Driver/src/stm32f10x_flash.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/twowinter/OpenHamtaro/HEAD/GoKit3ForOpenHamtaro/Lib/STM32F10x_StdPeriph_Driver/src/stm32f10x_flash.c -------------------------------------------------------------------------------- /GoKit3ForOpenHamtaro/Lib/STM32F10x_StdPeriph_Driver/src/stm32f10x_i2c.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/twowinter/OpenHamtaro/HEAD/GoKit3ForOpenHamtaro/Lib/STM32F10x_StdPeriph_Driver/src/stm32f10x_i2c.c -------------------------------------------------------------------------------- /GoKit3ForOpenHamtaro/Lib/STM32F10x_StdPeriph_Driver/src/stm32f10x_usart.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/twowinter/OpenHamtaro/HEAD/GoKit3ForOpenHamtaro/Lib/STM32F10x_StdPeriph_Driver/src/stm32f10x_usart.c -------------------------------------------------------------------------------- /ISD9160ForOpenHamtaro/NuvotonPlatform_Keil/Sample/CSpotter_OpenHamtaro/VR_sep.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/twowinter/OpenHamtaro/HEAD/ISD9160ForOpenHamtaro/NuvotonPlatform_Keil/Sample/CSpotter_OpenHamtaro/VR_sep.c -------------------------------------------------------------------------------- /GoKit3ForOpenHamtaro/Hal/Hal_Watchdog/hal_watchdog.h: -------------------------------------------------------------------------------- 1 | #ifndef WATCHDOG_H 2 | #define WATCHDOG_H 3 | #include "stm32f10x.h" 4 | 5 | void watchdogInit(uint8_t timeoutS); 6 | void watchdogFeed(void); 7 | 8 | #endif 9 | 10 | -------------------------------------------------------------------------------- /ISD9160ForOpenHamtaro/NuvotonPlatform_Keil/Sample/CSpotter_OpenHamtaro/CSpotterSDK16k24d.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/twowinter/OpenHamtaro/HEAD/ISD9160ForOpenHamtaro/NuvotonPlatform_Keil/Sample/CSpotter_OpenHamtaro/CSpotterSDK16k24d.lib -------------------------------------------------------------------------------- /GoKit3ForOpenHamtaro/User/delay.h: -------------------------------------------------------------------------------- 1 | #ifndef __DELAY_H 2 | #define __DELAY_H 3 | 4 | #include 5 | 6 | void delayInit(uint8_t SYSCLK); 7 | void delayMs(uint16_t nms); 8 | void delayUs(uint32_t nus); 9 | 10 | 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /GoKit3ForOpenHamtaro/Hal/Hal_infrared/Hal_infrared.h: -------------------------------------------------------------------------------- 1 | #ifndef _HAL_INFRARED_H 2 | #define _HAL_INFRARED_H 3 | #include "stdbool.h" 4 | 5 | #define Infrared_GPIO_CLK RCC_APB2Periph_GPIOB 6 | #define Infrared_GPIO_PORT GPIOB 7 | #define Infrared_GPIO_PIN GPIO_Pin_7 8 | #define Infrared_EXTI_LineX EXTI_Line7 9 | 10 | void irInit(void); 11 | bool irHandle(void); 12 | 13 | #endif /*_HAL_INFRARED_H*/ 14 | 15 | 16 | -------------------------------------------------------------------------------- /GoKit3ForOpenHamtaro/Hal/hal_motor/Hal_motor.h: -------------------------------------------------------------------------------- 1 | #ifndef _HAL_MOTOR_H 2 | #define _HAL_MOTOR_H 3 | 4 | #include 5 | #include "stm32f10x_gpio.h" 6 | 7 | 8 | 9 | #define Motor_stop 0 10 | #define Motor_Forward 1 11 | #define Motor_Reverse 2 12 | 13 | 14 | #define MOT1 PBout(8) 15 | #define MOT2 PBout(9) 16 | 17 | #define MOTOR_ARR 899 //8kHZ 18 | #define MOTOR_MAX 100 19 | #define MOTOR_MAX1 -100 20 | #define MOTOR_MIN 0 21 | 22 | #ifdef MOTOR_16 23 | typedef int16_t motor_t; 24 | #else 25 | typedef int8_t motor_t; 26 | #endif 27 | 28 | void motorInit(void); 29 | void motorStatus(motor_t status); 30 | 31 | #endif /*_HAL_MOTOR_H*/ 32 | -------------------------------------------------------------------------------- /GoKit3ForOpenHamtaro/Hal/Hal_rgb_led/Hal_rgb_led.h: -------------------------------------------------------------------------------- 1 | #ifndef _HAL_RGB_LED_H 2 | #define _HAL_RGB_LED_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | /*兼容V2.2,RGB开关IO*/ 9 | #define GPIO_RGB_CLK RCC_APB2Periph_GPIOA 10 | #define GPIO_RGB_PORT GPIOA 11 | #define GPIO_RGB_PIN GPIO_Pin_0 12 | 13 | #define R_MAX 255 14 | #define G_MAX 255 15 | #define B_MAX 255 16 | 17 | #define SCL_LOW GPIO_ResetBits(GPIOB,GPIO_Pin_8) 18 | #define SCL_HIGH GPIO_SetBits(GPIOB,GPIO_Pin_8) 19 | 20 | #define SDA_LOW GPIO_ResetBits(GPIOB,GPIO_Pin_9) 21 | #define SDA_HIGH GPIO_SetBits(GPIOB,GPIO_Pin_9) 22 | 23 | void rgbLedInit(void); 24 | void ledRgbControl(uint8_t R,uint8_t B,uint8_t G); 25 | void rgbKeyGpioInit(void); 26 | 27 | //void LED_R_Control(uint8_t R); 28 | //void LED_G_Control(uint8_t G); 29 | //void LED_B_Control(uint8_t B); 30 | 31 | #endif /*_HAL_RGB_LED_H*/ 32 | 33 | -------------------------------------------------------------------------------- /GoKit3ForOpenHamtaro/Hal/Hal_led/Hal_led.h: -------------------------------------------------------------------------------- 1 | #ifndef _HAL_LED_H 2 | #define _HAL_LED_H 3 | 4 | #include 5 | #include 6 | 7 | #define GPIO_LED1_CLK RCC_APB2Periph_GPIOB 8 | #define GPIO_LED1_PORT GPIOB 9 | #define GPIO_LED1_PIN GPIO_Pin_15 10 | 11 | #define GPIO_LED2_CLK RCC_APB2Periph_GPIOB 12 | #define GPIO_LED2_PORT GPIOB 13 | #define GPIO_LED2_PIN GPIO_Pin_14 14 | 15 | #define GPIO_LED3_CLK RCC_APB2Periph_GPIOB 16 | #define GPIO_LED3_PORT GPIOB 17 | #define GPIO_LED3_PIN GPIO_Pin_11 18 | 19 | #define GPIO_LED4_CLK RCC_APB2Periph_GPIOB 20 | #define GPIO_LED4_PORT GPIOB 21 | #define GPIO_LED4_PIN GPIO_Pin_1 22 | 23 | 24 | 25 | #define LED1 0X01 26 | #define LED2 0X02 27 | #define LED3 0X04 28 | #define LED4 0X08 29 | 30 | void ledGpioInit(void); 31 | void ledOn(uint8_t ledNum); 32 | void ledOff(uint8_t ledNum); 33 | 34 | #endif /*_HAL_LED_H*/ 35 | 36 | -------------------------------------------------------------------------------- /GoKit3ForOpenHamtaro/Hal/Hal_infrared/hal_infrared.c: -------------------------------------------------------------------------------- 1 | /** 2 | ******************************************************** 3 | * 4 | * @file Hal_infrared.c 5 | * @author Gizwtis 6 | * @version V03010100 7 | * @date 2016-07-05 8 | * 9 | * @brief 机智云.只为智能硬件而生 10 | * Gizwits Smart Cloud for Smart Products 11 | * 链接|增值ֵ|开放|中立|安全|自有|自由|生态 12 | * www.gizwits.com 13 | * 14 | *********************************************************/ 15 | 16 | #include 17 | #include "Hal_infrared/Hal_infrared.h" 18 | 19 | void irInit(void) 20 | { 21 | GPIO_InitTypeDef GPIO_InitStructure; 22 | RCC_APB2PeriphClockCmd(Infrared_GPIO_CLK,ENABLE);//使能PORTA,PORTE时钟 23 | GPIO_InitStructure.GPIO_Pin = Infrared_GPIO_PIN; 24 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; //设置成上拉输入 25 | GPIO_InitStructure.GPIO_Speed=GPIO_Speed_2MHz; 26 | GPIO_Init(Infrared_GPIO_PORT, &GPIO_InitStructure); 27 | } 28 | 29 | bool irHandle(void) 30 | { 31 | if(GPIO_ReadInputDataBit(Infrared_GPIO_PORT, Infrared_GPIO_PIN)) 32 | { 33 | return 0; 34 | } 35 | else 36 | { 37 | return 1; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /ISD9160ForOpenHamtaro/NuvotonPlatform_Keil/Include/SemiHost.h: -------------------------------------------------------------------------------- 1 | /**************************************************************** 2 | * * 3 | * Copyright (c) Nuvoton Technology Corp. All rights reserved. * 4 | * * 5 | ****************************************************************/ 6 | #ifndef __SEMIHOST_H__ 7 | #define __SEMIHOST_H__ 8 | 9 | #include "NUC1xx.h" 10 | #include "System/SysInfra.h" 11 | 12 | #ifdef __cplusplus 13 | extern "C" 14 | { 15 | #endif 16 | 17 | #define SEMIHOST_MAJOR_NUM 1 18 | #define SEMIHOST_MINOR_NUM 00 19 | #define SEMIHOST_BUILD_NUM 001 20 | 21 | #define SEMIHOST_VERSION_NUM _SYSINFRA_VERSION(SEMIHOST_MAJOR_NUM, SEMIHOST_MINOR_NUM, SEMIHOST_BUILD_NUM) 22 | 23 | /****************************************************************************************** 24 | * Description: 25 | * Version control API. 26 | * Arguments: 27 | * None. 28 | ******************************************************************************************/ 29 | 30 | uint32_t 31 | SemiHost_GetVersion(void); 32 | 33 | void SemiHost_Init(void); 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | 39 | #endif //__SEMIHOST_H__ 40 | -------------------------------------------------------------------------------- /ISD9160ForOpenHamtaro/NuvotonPlatform_Keil/Src/Driver/DrvCapSense.c: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------*/ 2 | /* */ 3 | /* Copyright(c) 2009 Nuvoton Technology Corp. All rights reserved. */ 4 | /* */ 5 | /*---------------------------------------------------------------------------------------------------------*/ 6 | #include 7 | #include "ISD9xx.h" 8 | #include "DrvCapSense.h" 9 | 10 | 11 | void DrvCAPSENSE_ISRC_En(uint32_t bits) 12 | { 13 | ANA->ISRC.EN = bits; 14 | } 15 | 16 | void DrvCAPSENSE_ISRC_Val(uint32_t val) 17 | { 18 | ANA->ISRC.VAL = val; 19 | } 20 | 21 | void DrvCAPSENSE_Ctrl(uint32_t time, uint32_t cnt) 22 | { 23 | ANA->CAPS_CTRL.LOW_TIME = time; 24 | ANA->CAPS_CTRL.CYCLE_CNT = cnt; 25 | } 26 | 27 | void DrvCAPSENSE_INT_Enable(void) 28 | { 29 | ANA->CAPS_CTRL.INT_EN = 1; 30 | } 31 | 32 | void DrvCAPSENSE_INT_Disable(void) 33 | { 34 | ANA->CAPS_CTRL.INT_EN = 0; 35 | } 36 | 37 | void DrvCAPSENSE_ResetCnt(void) 38 | { 39 | ANA->CAPS_CTRL.RST_CNT = 1; 40 | ANA->CAPS_CTRL.RST_CNT = 0; 41 | } 42 | 43 | void DrvCAPSENSE_CntEnable(void) 44 | { 45 | ANA->CAPS_CTRL.CNT_EN = 1; 46 | } 47 | 48 | -------------------------------------------------------------------------------- /GoKit3ForOpenHamtaro/Hal/Hal_Watchdog/hal_watchdog.c: -------------------------------------------------------------------------------- 1 | /** 2 | ******************************************************** 3 | * 4 | * @file hal_watchdog.c 5 | * @author Gizwtis 6 | * @version V03010100 7 | * @date 2016-07-05 8 | * 9 | * @brief 机智云.只为智能硬件而生 10 | * Gizwits Smart Cloud for Smart Products 11 | * 链接|增值ֵ|开放|中立|安全|自有|自由|生态 12 | * www.gizwits.com 13 | * 14 | *********************************************************/ 15 | /* 16 | void IWDG_Init(u8 prer,u16 rlr)是独立看门狗初始化函数,就是按照 17 | 上面介绍的步骤来初始化独立看门狗的。该函数有2 个参数,分别用来设置与预分频数与重装 18 | 寄存器的值的。通过这两个参数,就可以大概知道看门狗复位的时间周期为多少了。其计算方 19 | 式上面有详细的介绍,这里不再多说了。 20 | void IWDG_Feed(void)函数,该函数用来喂狗,因为STM32 的喂狗只需要向键值寄存器写 21 | 入0XAAAA 即可 22 | */ 23 | 24 | #include "hal_watchdog.h" 25 | #define WATCHDOG 26 | /* 27 | Tout=((4×2^prer) ×rlr) /40 = ((4 * 2^4) * 625) / 40 = 1000ms = 1s 28 | prer 为看门狗时钟预分频值(IWDG_PR 值),范围为0~7 ; 29 | rlr 为看门狗的重装载值(IWDG_RLR 的值) 30 | 1s内喂狗,看门狗就可以不复位 , 看门狗时钟不标准的40kHz 31 | */ 32 | void watchdogInit(uint8_t timeoutS)//宏 33 | { 34 | #ifdef WATCHDOG 35 | /* 输入 参数修改 */ 36 | uint8_t prer = 4; 37 | uint16_t rlr = timeoutS * 625; 38 | IWDG_WriteAccessCmd(IWDG_WriteAccess_Enable); /* 使能对寄存器IWDG_PR和IWDG_RLR的写操作*/ 39 | IWDG_SetPrescaler(prer); /*设置IWDG预分频值:设置IWDG预分频值*/ 40 | IWDG_SetReload(rlr); /*设置IWDG重装载值*/ 41 | IWDG_ReloadCounter(); /*按照IWDG重装载寄存器的值重装载IWDG计数器*/ 42 | IWDG_Enable(); /*使能IWDG*/ 43 | #endif 44 | } 45 | 46 | // 喂狗 47 | void watchdogFeed(void) 48 | { 49 | #ifdef WATCHDOG 50 | IWDG->KR=0xaaaa; 51 | #endif 52 | } 53 | 54 | -------------------------------------------------------------------------------- /GoKit3ForOpenHamtaro/Hal/hal_temp_hum/Hal_temp_hum.h: -------------------------------------------------------------------------------- 1 | #ifndef _HAL_HEMP_HUM_H 2 | #define _HAL_HEMP_HUM_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include "delay.h" 8 | #include "Hal_temp_hum/sys.h" 9 | 10 | //Set GPIO Direction 11 | #define DHT11_IO_IN() GPIO_InitTypeDef GPIO_InitStruct;\ 12 | GPIO_InitStruct.GPIO_Pin = GPIO_Pin_3;\ 13 | GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IPU;\ 14 | GPIO_InitStruct.GPIO_Speed = GPIO_Speed_10MHz;\ 15 | GPIO_Init(GPIOB, &GPIO_InitStruct); 16 | 17 | #define DHT11_IO_OUT() GPIO_InitTypeDef GPIO_InitStruct;\ 18 | GPIO_InitStruct.GPIO_Pin = GPIO_Pin_3;\ 19 | GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;\ 20 | GPIO_InitStruct.GPIO_Speed = GPIO_Speed_10MHz;\ 21 | GPIO_Init(GPIOB, &GPIO_InitStruct); 22 | 23 | #define DHT11_DQ_OUT PBout(3) 24 | #define DHT11_DQ_IN PBin(3) 25 | 26 | #define MEAN_NUM 10 27 | 28 | typedef struct 29 | { 30 | uint8_t curI; 31 | uint8_t thAmount; 32 | uint8_t thBufs[10][2]; 33 | }thTypedef_t; 34 | 35 | /* Function declaration */ 36 | uint8_t dht11Init(void); //Init DHT11 37 | uint8_t dht11Read(uint8_t *temperature, uint8_t *humidity); //Read DHT11 Value 38 | static uint8_t dht11ReadData(uint8_t *temperature, uint8_t *humidity); 39 | static uint8_t dht11ReadByte(void);//Read One Byte 40 | static uint8_t dht11ReadBit(void);//Read One Bit 41 | static uint8_t dht11Check(void);//Chack DHT11 42 | static void dht11Rst(void);//Reset DHT11 43 | void dht11SensorTest(void); 44 | 45 | #endif /*_HAL_HEMP_HUM_H*/ 46 | 47 | -------------------------------------------------------------------------------- /GoKit3ForOpenHamtaro/User/delay.c: -------------------------------------------------------------------------------- 1 | /** 2 | ******************************************************** 3 | * 4 | * @file delay.c 5 | * @author Gizwtis 6 | * @version V03010100 7 | * @date 2016-07-05 8 | * 9 | * @brief 机智云.只为智能硬件而生 10 | * Gizwits Smart Cloud for Smart Products 11 | * 链接|增值ֵ|开放|中立|安全|自有|自由|生态 12 | * www.gizwits.com 13 | * 14 | *********************************************************/ 15 | 16 | #include "delay.h" 17 | 18 | static uint8_t facUs=0; //us延时倍乘数 19 | static uint16_t facMs=0; //ms延时倍乘数 20 | 21 | void delayInit(uint8_t SYSCLK) 22 | { 23 | SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK_Div8); //选择外部时钟,HCLK/8 24 | facUs=SYSCLK/8; //硬件分频,fac_us得出的值要给下面的时钟函数使用 25 | facMs =(u16)facUs*1000; 26 | } 27 | 28 | void delayUs(uint32_t nus) 29 | { 30 | uint32_t temp; 31 | SysTick->LOAD = nus*facUs; //延时10us,10*9 = 90,装到load寄存器中 32 | SysTick->VAL=0x00;//计数器清0 33 | SysTick->CTRL = 0x01;//配置异常生效,也就是计数器倒数到0时发出异常通知 34 | do 35 | { 36 | temp = SysTick->CTRL;//时间到,该位将被硬件置1,但被查询后自动清0 37 | } 38 | while(temp & 0x01 && !(temp &(1<<16)));//查询 39 | SysTick->CTRL = 0x00;//关闭定时器 40 | SysTick->VAL = 0x00;//清空val,清空定时器 41 | } 42 | 43 | 44 | void delayMs(uint16_t nms) 45 | { 46 | uint32_t temp; 47 | SysTick->LOAD = nms*facMs;//延时10ms,10*9 = 90,装到load寄存器中 48 | SysTick->VAL=0x00;//计数器清0 49 | SysTick->CTRL = 0x01;//配置异常生效,也就是计数器倒数到0时发出异常通知 50 | do 51 | { 52 | temp = SysTick->CTRL;//时间到,该位将被硬件置1,但被查询后自动清0 53 | } 54 | while(temp & 0x01 && !(temp &(1<<16)));//查询 55 | 56 | SysTick->CTRL = 0x00;//关闭定时器 57 | SysTick->VAL = 0x00;//清空val,清空定时器 58 | } 59 | -------------------------------------------------------------------------------- /ISD9160ForOpenHamtaro/CMSIS/CM0/DeviceSupport/Nuvoton/ISD91xx/system_ISD9xx.c: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------*/ 2 | /* */ 3 | /* Copyright(c) 2011 Nuvoton Technology Corp. All rights reserved. */ 4 | /* */ 5 | /*---------------------------------------------------------------------------------------------------------*/ 6 | #include 7 | #include "ISD9xx.h" 8 | 9 | /*---------------------------------------------------------------------------- 10 | Define SYSCLK 11 | *----------------------------------------------------------------------------*/ 12 | #define __SYSTEM_CLOCK (49152000UL) 13 | 14 | /*---------------------------------------------------------------------------- 15 | Clock Variable definitions 16 | *----------------------------------------------------------------------------*/ 17 | uint32_t SystemCoreClock = __SYSTEM_CLOCK;/*!< System Clock Frequency (Core Clock)*/ 18 | 19 | 20 | /*---------------------------------------------------------------------------- 21 | Clock functions 22 | *----------------------------------------------------------------------------*/ 23 | void SystemCoreClockUpdate (void) /* Get Core Clock Frequency */ 24 | { 25 | SystemCoreClock = __SYSTEM_CLOCK; 26 | } 27 | 28 | /** 29 | * Initialize the system 30 | * 31 | * @param none 32 | * @return none 33 | * 34 | * @brief Setup the microcontroller system. 35 | * Initialize the System. 36 | */ 37 | void SystemInit (void) 38 | { 39 | SystemCoreClock = __SYSTEM_CLOCK; 40 | 41 | } 42 | 43 | 44 | -------------------------------------------------------------------------------- /GoKit3ForOpenHamtaro/Hal/Hal_key/Hal_key.h: -------------------------------------------------------------------------------- 1 | #ifndef _HAL_KEY_H 2 | #define _HAL_KEY_H 3 | 4 | #include 5 | #include 6 | 7 | #define GPIO_KEY1_CLK RCC_APB2Periph_GPIOB 8 | #define GPIO_KEY1_PORT GPIOB 9 | #define GPIO_KEY1_PIN GPIO_Pin_10 10 | 11 | #define GPIO_KEY2_CLK RCC_APB2Periph_GPIOA 12 | #define GPIO_KEY2_PORT GPIOA 13 | #define GPIO_KEY2_PIN GPIO_Pin_8 14 | 15 | #define GPIO_KEY3_CLK RCC_APB2Periph_GPIOC 16 | #define GPIO_KEY3_PORT GPIOC 17 | #define GPIO_KEY3_PIN GPIO_Pin_13 18 | 19 | #define PRESS_KEY1 0x01 20 | #define PRESS_KEY2 0x02 21 | #define PRESS_KEY3 0x04 22 | 23 | #define NO_KEY 0x00 24 | #define KEY_DOWN 0x10 25 | #define KEY_UP 0x20 26 | #define KEY_LIAN 0x40 27 | #define KEY_LONG 0x80 28 | 29 | #define KEY_CLICK_DELAY 10 30 | 31 | #define KEY1_Long_Action 0x01 32 | #define KEY2_Long_Action 0x02 33 | 34 | 35 | typedef void (*gokitKeyFunction)(void); 36 | 37 | __packed typedef struct 38 | { 39 | uint8_t keyNum; 40 | uint32_t keyRccPeriph; 41 | GPIO_TypeDef *keyPort; 42 | uint32_t keyGpio; 43 | gokitKeyFunction shortPress; 44 | gokitKeyFunction longPress; 45 | }keyTypedef_t; 46 | 47 | __packed typedef struct 48 | { 49 | uint8_t keyNum; 50 | keyTypedef_t *singleKey; 51 | }keysTypedef_t; 52 | 53 | 54 | void keyGpioInit(void); 55 | void keyHandle(keysTypedef_t *keys); 56 | uint8_t getKey(keysTypedef_t *key); 57 | uint8_t readKeyValue(keysTypedef_t *keys); 58 | void keyParaInit(keysTypedef_t *keys); 59 | keyTypedef_t keyInitOne(uint8_t keyNo ,uint32_t keyRccPeriph, GPIO_TypeDef * keyPort, uint32_t keyGpio, gokitKeyFunction shortPress, gokitKeyFunction longPress); 60 | 61 | //uint8_t readKeyState(keysTypedef_t *key); 62 | //void keyHandle(keyTypedef_t *key); 63 | //void keyLongHandle(uint8_t KeyAction); 64 | #endif /*_HAL_KEY_H*/ 65 | 66 | -------------------------------------------------------------------------------- /GoKit3ForOpenHamtaro/Hal/hal_temp_hum/sys.h: -------------------------------------------------------------------------------- 1 | #include "stm32f10x.h" 2 | 3 | //GPIO Macro Definition 4 | #define BITBAND(addr, bitnum) ((addr & 0xF0000000)+0x2000000+((addr &0xFFFFF)<<5)+(bitnum<<2)) 5 | #define MEM_ADDR(addr) *((volatile unsigned long *)(addr)) 6 | #define BIT_ADDR(addr, bitnum) MEM_ADDR(BITBAND(addr, bitnum)) 7 | 8 | //GPIO Adress Map 9 | #define GPIOA_ODR_Addr (GPIOA_BASE+12) //0x4001080C 10 | #define GPIOB_ODR_Addr (GPIOB_BASE+12) //0x40010C0C 11 | #define GPIOC_ODR_Addr (GPIOC_BASE+12) //0x4001100C 12 | #define GPIOD_ODR_Addr (GPIOD_BASE+12) //0x4001140C 13 | #define GPIOE_ODR_Addr (GPIOE_BASE+12) //0x4001180C 14 | #define GPIOF_ODR_Addr (GPIOF_BASE+12) //0x40011A0C 15 | #define GPIOG_ODR_Addr (GPIOG_BASE+12) //0x40011E0C 16 | 17 | #define GPIOA_IDR_Addr (GPIOA_BASE+8) //0x40010808 18 | #define GPIOB_IDR_Addr (GPIOB_BASE+8) //0x40010C08 19 | #define GPIOC_IDR_Addr (GPIOC_BASE+8) //0x40011008 20 | #define GPIOD_IDR_Addr (GPIOD_BASE+8) //0x40011408 21 | #define GPIOE_IDR_Addr (GPIOE_BASE+8) //0x40011808 22 | #define GPIOF_IDR_Addr (GPIOF_BASE+8) //0x40011A08 23 | #define GPIOG_IDR_Addr (GPIOG_BASE+8) //0x40011E08 24 | 25 | #define PAout(n) BIT_ADDR(GPIOA_ODR_Addr,n) 26 | #define PAin(n) BIT_ADDR(GPIOA_IDR_Addr,n) 27 | 28 | #define PBout(n) BIT_ADDR(GPIOB_ODR_Addr,n) 29 | #define PBin(n) BIT_ADDR(GPIOB_IDR_Addr,n) 30 | 31 | #define PCout(n) BIT_ADDR(GPIOC_ODR_Addr,n) 32 | #define PCin(n) BIT_ADDR(GPIOC_IDR_Addr,n) 33 | 34 | #define PDout(n) BIT_ADDR(GPIOD_ODR_Addr,n) 35 | #define PDin(n) BIT_ADDR(GPIOD_IDR_Addr,n) 36 | 37 | #define PEout(n) BIT_ADDR(GPIOE_ODR_Addr,n) 38 | #define PEin(n) BIT_ADDR(GPIOE_IDR_Addr,n) 39 | 40 | #define PFout(n) BIT_ADDR(GPIOF_ODR_Addr,n) 41 | #define PFin(n) BIT_ADDR(GPIOF_IDR_Addr,n) 42 | 43 | #define PGout(n) BIT_ADDR(GPIOG_ODR_Addr,n) 44 | #define PGin(n) BIT_ADDR(GPIOG_IDR_Addr,n) 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /GoKit3ForOpenHamtaro/User/stm32f10x_it.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file GPIO/IOToggle/stm32f10x_it.h 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 08-April-2011 7 | * @brief This file contains the headers of the interrupt handlers. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2011 STMicroelectronics

19 | ****************************************************************************** 20 | */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __STM32F10x_IT_H 24 | #define __STM32F10x_IT_H 25 | 26 | /* Includes ------------------------------------------------------------------*/ 27 | #include "stm32f10x.h" 28 | 29 | /* Exported types ------------------------------------------------------------*/ 30 | /* Exported constants --------------------------------------------------------*/ 31 | /* Exported macro ------------------------------------------------------------*/ 32 | /* Exported functions ------------------------------------------------------- */ 33 | 34 | void NMI_Handler(void); 35 | void HardFault_Handler(void); 36 | void MemManage_Handler(void); 37 | void BusFault_Handler(void); 38 | void UsageFault_Handler(void); 39 | void SVC_Handler(void); 40 | void DebugMon_Handler(void); 41 | void PendSV_Handler(void); 42 | void SysTick_Handler(void); 43 | 44 | #endif /* __STM32F10x_IT_H */ 45 | 46 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 47 | -------------------------------------------------------------------------------- /GoKit3ForOpenHamtaro/Hal/Hal_Usart/hal_uart.h: -------------------------------------------------------------------------------- 1 | #ifndef _HAL_UART_H 2 | #define _HAL_UART_H 3 | 4 | #include 5 | #include 6 | 7 | 8 | #define Open_UART1 9 | //#define Open_UART2 10 | #define Open_UART3 11 | 12 | 13 | #if defined (Open_UART1) 14 | 15 | /*************************************************************** 16 | * UART1_TX PA9 17 | * UART1_RX PA10 18 | ****************************************************************/ 19 | #define USART1_GPIO_Cmd RCC_APB2PeriphClockCmd 20 | #define USART1_GPIO_CLK RCC_APB2Periph_GPIOA 21 | 22 | #define USART1_AFIO_Cmd RCC_APB2PeriphClockCmd 23 | #define USART1_AFIO_CLK RCC_APB2Periph_AFIO 24 | 25 | #define USART1_CLK_Cmd RCC_APB2PeriphClockCmd 26 | #define USART1_CLK RCC_APB2Periph_USART1 27 | 28 | #define USART1_GPIO_PORT GPIOA 29 | #define USART1_RxPin GPIO_Pin_10 30 | #define USART1_TxPin GPIO_Pin_9 31 | 32 | #endif 33 | 34 | #if defined (Open_UART2) 35 | 36 | #define USART2_GPIO_Cmd RCC_APB2PeriphClockCmd 37 | #define USART2_GPIO_CLK RCC_APB2Periph_GPIOA 38 | 39 | #define USART2_AFIO_Cmd RCC_APB2PeriphClockCmd 40 | #define USART2_AFIO_CLK RCC_APB2Periph_AFIO 41 | 42 | #define USART2_CLK_Cmd RCC_APB1PeriphClockCmd 43 | #define USART2_CLK RCC_APB1Periph_USART2 44 | 45 | #define USART2_GPIO_PORT GPIOA 46 | #define USART2_RxPin GPIO_Pin_3 47 | #define USART2_TxPin GPIO_Pin_2 48 | 49 | #endif 50 | 51 | 52 | #if defined (Open_UART3) 53 | 54 | #define USART3_GPIO_Cmd RCC_APB2PeriphClockCmd 55 | #define USART3_GPIO_CLK RCC_APB2Periph_GPIOC 56 | 57 | #define USART3_AFIO_Cmd RCC_APB2PeriphClockCmd 58 | #define USART3_AFIO_CLK RCC_APB2Periph_AFIO 59 | 60 | #define USART3_CLK_Cmd RCC_APB1PeriphClockCmd 61 | #define USART3_CLK RCC_APB1Periph_USART3 62 | 63 | #define USART3_GPIO_PORT GPIOC 64 | #define USART3_RxPin GPIO_Pin_11 65 | #define USART3_TxPin GPIO_Pin_10 66 | 67 | #endif 68 | 69 | void uartxInit(void); 70 | void uart2SendData(uint8_t data); 71 | void uart1SendData(uint8_t data); 72 | #endif /*_HAL_UART_H*/ 73 | 74 | 75 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # OpenHamtaro 2 | 3 | ## 项目背景 4 | 大家好,我是多多的爸爸,多多是在李志唱了“多多你不要哭”之后来到这个世界上的小女孩。 5 | 6 | 前段时间给多多买了个语音仓鼠玩具,主要功能就是你说一句,它重复一句,里头有个电机,讲话的时候电机跟着转动,相当于自带抽风效果。多多特别喜欢,整天抓在手里又亲又咬,仓鼠一抽风,她也乐地抽风。后来仓鼠坏掉了,怎么叫都叫不醒,多多以为是开关没打开,我跟她解释说仓鼠坏掉了,她听不懂,一直拉着我的手往底座去拨开关,让人怜惜。 7 | 8 | 机智云Cherry从CSDN联系到我说要赠送一个GoKit3的时候,我很开心,很早就知道它支持语音识别,我脑海中蹦出的想法就是利用Gokit3给闺女的仓鼠玩具做个大换血。记得5月的时候,周杰伦随手就给女儿写了首歌《前世情人》,让我嫉妒不已,老婆鼓励我说“会写代码的爸爸同样牛逼”。这次我也终于能够得偿所愿,给多多写段代码了。 9 | 10 | 这就是这个开源项目的由来。 11 | 12 | ![](http://7xkqvo.com1.z0.glb.clouddn.com/open_hamtaro_kiss_ok.jpg) 13 | 14 | ## 项目介绍 15 | OpenHamtaro是一个以仓鼠玩偶为原型的语音机器人项目,具备语音交互能力,可与不同品牌的ZigBee智能家居产品互联互通。项目希望通过开源方式,集合大家的力量,一起打造一个开放自由的智能家居网络,让大家可以挑选喜欢的设备进入个人生活。 16 | 17 | OpenHamtaro有如下特点: 18 | 19 | - 1.语音交互。 20 | Apple有Siri,Google有Goolge Now,你说“OK glass”可以与谷歌眼镜交谈,你说“Alexa”可以让亚马逊Echo播放音乐。 在OpenHamtaro,你念叨下“仓鼠管家”,就可以操作智能家居设备了。 21 | 22 | - 2.ZigBee互联互通。 23 | 在智能家居的应用领域,ZigBee在互联互通、网络接入数量等方面都比WiFi要更有优势。虽然ZigBee联盟已经公布了有1072款的认证产品,但似乎离我们还比较远。 24 | 希望通过这个OpenHamtaro项目,逐个接入各个品牌的ZigBeeHomeAutomation智能家居单品,比如飞利浦的HUE灯,南京物联的插座,施耐德的开关等等。甚至给小米的ZigBee智能家居套装重写满足ZHA协议的固件,用于接入标准ZHA网络。(如果绿米的工程师看到这,希望官方能发布一个标准ZHA固件,实现与其他ZHA产品的互联互通。) 25 | 26 | - 3.全球领先的GreenPower协议实现。 27 | 这两年免电池开关很受欢迎,Enocean联盟、以及国内的领普等专做无源免电池设备的厂商都大火。其实早在2012年ZigBee协议中就加入对无源免电池设备的兼容,但是技术上一直攻克不下来。最近从上游供应商那传来喜讯,有了工程样机,期待能在这个项目中实现这个技术的接入。 28 | 29 | 总的来说,OpenHamtaro要做一个开放包容且有意思的智能家居网关,这也是这个“产品”的差异化特点。 30 | 31 | ## 一期项目成果展示 32 | 33 | ### 原型照片 34 | 35 | GoKit3+仓鼠玩偶 36 | ![](http://7xkqvo.com1.z0.glb.clouddn.com/open_hamtaro_prototype_ok.jpg) 37 | 38 | 飞利浦HUE闪亮登场,感谢领导大力支持。 39 | ![](http://7xkqvo.com1.z0.glb.clouddn.com/open_hamtaro_hue.jpg) 40 | 41 | 42 | ### 功能演示视频 43 | 44 | 严肃演示版视频(锤子T1闪亮出境): 45 | [http://v.qq.com/x/page/z0324xe9wtm.html](http://v.qq.com/x/page/z0324xe9wtm.html) 46 | 47 | 语音调戏版视频(仓鼠管家抽风特写): 48 | [http://v.qq.com/x/page/p0324kjqakq.html](http://v.qq.com/x/page/p0324kjqakq.html) 49 | 50 | ## 总体设计方案 51 | 52 | ### 系统拓扑 53 | ![](http://7xkqvo.com1.z0.glb.clouddn.com/open_hamtaro_topo.png) 54 | 55 | 56 | ### BOM 57 | ![](http://7xkqvo.com1.z0.glb.clouddn.com/open_hamtaro_bom.png) 58 | 59 | 60 | ### 项目计划 61 | 62 | - 一期计划(20160728~20160831): 63 | 以GoKit3为硬件原型机,主要实现软件功能验证。 64 | ![](http://7xkqvo.com1.z0.glb.clouddn.com/open_hamtaro_plan.png) 65 | 66 | - 二期计划(20160901~20161131): 67 | 硬件方面可以开工,着手制作样机。软件方面,接入更多的HA设备,如无源开关等。 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /GoKit3ForOpenHamtaro/Docs/仓鼠管家-机智云接入JSON文档.json: -------------------------------------------------------------------------------- 1 | {"name": "仓鼠管家", "packetVersion": "0x00000004", "protocolType": "standard", "product_key": "efea64cc739c4c68bee4fc6826b1762e", "entities": [{"display_name": "机智云开发套件", "attrs": [{"display_name": "开启/关闭红色灯", "name": "LED_OnOff", "data_type": "bool", "position": {"byte_offset": 0, "unit": "bit", "len": 1, "bit_offset": 0}, "type": "status_writable", "id": 0, "desc": "....."}, {"display_name": "设定LED组合颜色", "name": "LED_Color", "data_type": "enum", "enum": ["自定义", "黄色", "紫色", "粉色"], "position": {"byte_offset": 0, "unit": "bit", "len": 2, "bit_offset": 1}, "type": "status_writable", "id": 1, "desc": "....."}, {"display_name": "设定LED红色值", "name": "LED_R", "data_type": "uint8", "position": {"byte_offset": 1, "unit": "byte", "len": 1, "bit_offset": 0}, "uint_spec": {"addition": 0, "max": 254, "ratio": 1, "min": 0}, "type": "status_writable", "id": 2, "desc": "....."}, {"display_name": "设定LED绿色值", "name": "LED_G", "data_type": "uint8", "position": {"byte_offset": 2, "unit": "byte", "len": 1, "bit_offset": 0}, "uint_spec": {"addition": 0, "max": 254, "ratio": 1, "min": 0}, "type": "status_writable", "id": 3, "desc": "....."}, {"display_name": "设定LED蓝色值", "name": "LED_B", "data_type": "uint8", "position": {"byte_offset": 3, "unit": "byte", "len": 1, "bit_offset": 0}, "uint_spec": {"addition": 0, "max": 254, "ratio": 1, "min": 0}, "type": "status_writable", "id": 4, "desc": "....."}, {"display_name": "设定电机转速", "name": "Motor_Speed", "data_type": "uint16", "position": {"byte_offset": 4, "unit": "byte", "len": 2, "bit_offset": 0}, "uint_spec": {"addition": -5, "max": 10, "ratio": 1, "min": 0}, "type": "status_writable", "id": 5, "desc": "....."}, {"display_name": "报警1", "name": "Alert_1", "data_type": "bool", "position": {"byte_offset": 6, "unit": "bit", "len": 1, "bit_offset": 0}, "type": "alert", "id": 6, "desc": "....."}, {"display_name": "报警2", "name": "Alert_2", "data_type": "bool", "position": {"byte_offset": 6, "unit": "bit", "len": 1, "bit_offset": 1}, "type": "alert", "id": 7, "desc": "....."}, {"display_name": "LED故障", "name": "Fault_LED", "data_type": "bool", "position": {"byte_offset": 7, "unit": "bit", "len": 1, "bit_offset": 0}, "type": "fault", "id": 8, "desc": "....."}, {"display_name": "电机故障", "name": "Fault_Motor", "data_type": "bool", "position": {"byte_offset": 7, "unit": "bit", "len": 1, "bit_offset": 1}, "type": "fault", "id": 9, "desc": "....."}], "name": "entity0", "id": 0}]} -------------------------------------------------------------------------------- /ISD9160ForOpenHamtaro/NuvotonPlatform_Keil/Sample/CSpotter_OpenHamtaro/base_types.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2002 Cyberon Corp. All right reserved. 3 | File: base_types.h 4 | Desc: Define all base types 5 | Author: Calvin 6 | Date: 2013/05/02 7 | Version : 1.50.00 8 | */ 9 | 10 | #ifndef __BASE_TYPES_H 11 | #define __BASE_TYPES_H 12 | 13 | #include 14 | #include 15 | 16 | #if defined(_WIN32) 17 | 18 | #include 19 | 20 | typedef signed char INT8; 21 | typedef unsigned short USHORT; 22 | typedef unsigned int UINT; 23 | typedef unsigned long ULONG; 24 | typedef unsigned short WCHAR; 25 | 26 | #else 27 | 28 | typedef signed char CHAR; 29 | typedef unsigned char BYTE; 30 | typedef signed char INT8; 31 | typedef signed short SHORT; 32 | typedef unsigned short WORD; 33 | typedef unsigned short USHORT; 34 | typedef signed long LONG; 35 | typedef unsigned int DWORD; 36 | typedef unsigned long ULONG; 37 | typedef signed int INT; 38 | typedef unsigned int UINT; 39 | // typedef int BOOL; 40 | typedef void VOID; 41 | typedef unsigned short WCHAR; /*typedef wchar_t WCHAR;*/ 42 | 43 | #endif 44 | 45 | #ifdef UNICODE 46 | #undef UNICODE 47 | #endif 48 | 49 | #define UNICODE WCHAR 50 | 51 | #ifdef LPVOID 52 | #undef LPVOID 53 | #endif 54 | #define LPVOID void* 55 | 56 | #ifndef TRUE 57 | #define TRUE (1 == 1) 58 | #endif 59 | 60 | #ifndef FALSE 61 | #define FALSE (1 == 0) 62 | #endif 63 | 64 | #ifndef HANDLE 65 | #define HANDLE VOID* 66 | #endif 67 | 68 | #ifndef NULL 69 | #define NULL ((VOID*)0) 70 | #endif 71 | 72 | #define PNULL ((VOID*)0) 73 | 74 | #ifndef STATIC 75 | #define STATIC static 76 | #endif 77 | 78 | #ifndef max 79 | #define max(a,b) (((a) > (b)) ? (a) : (b)) 80 | #endif 81 | 82 | #ifndef min 83 | #define min(a,b) (((a) < (b)) ? (a) : (b)) 84 | #endif 85 | 86 | #if defined(_WIN32) 87 | #define EXPAPI WINAPI 88 | #else 89 | #define EXPAPI 90 | #endif 91 | 92 | #ifndef SAFE_DELETE 93 | #define SAFE_DELETE(a) if ( (a) != NULL ) {delete (a); (a) = NULL;} 94 | #endif 95 | 96 | #ifndef SAFE_FREE 97 | #define SAFE_FREE(a) if ( (a) != NULL ) {free(a); (a) = NULL;} 98 | #endif 99 | 100 | #ifndef INLINE 101 | #ifdef _WIN32 102 | #define INLINE _inline 103 | #else 104 | #define INLINE __inline 105 | #endif 106 | #endif 107 | 108 | #endif /* __BASE_TYPES_H */ 109 | -------------------------------------------------------------------------------- /GoKit3ForOpenHamtaro/Lib/CMSIS/CM3/DeviceSupport/ST/STM32F10x/system_stm32f10x.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file system_stm32f10x.h 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief CMSIS Cortex-M3 Device Peripheral Access Layer System Header File. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2011 STMicroelectronics

19 | ****************************************************************************** 20 | */ 21 | 22 | /** @addtogroup CMSIS 23 | * @{ 24 | */ 25 | 26 | /** @addtogroup stm32f10x_system 27 | * @{ 28 | */ 29 | 30 | /** 31 | * @brief Define to prevent recursive inclusion 32 | */ 33 | #ifndef __SYSTEM_STM32F10X_H 34 | #define __SYSTEM_STM32F10X_H 35 | 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | /** @addtogroup STM32F10x_System_Includes 41 | * @{ 42 | */ 43 | 44 | /** 45 | * @} 46 | */ 47 | 48 | 49 | /** @addtogroup STM32F10x_System_Exported_types 50 | * @{ 51 | */ 52 | 53 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ 54 | 55 | /** 56 | * @} 57 | */ 58 | 59 | /** @addtogroup STM32F10x_System_Exported_Constants 60 | * @{ 61 | */ 62 | 63 | /** 64 | * @} 65 | */ 66 | 67 | /** @addtogroup STM32F10x_System_Exported_Macros 68 | * @{ 69 | */ 70 | 71 | /** 72 | * @} 73 | */ 74 | 75 | /** @addtogroup STM32F10x_System_Exported_Functions 76 | * @{ 77 | */ 78 | 79 | extern void SystemInit(void); 80 | extern void SystemCoreClockUpdate(void); 81 | /** 82 | * @} 83 | */ 84 | 85 | #ifdef __cplusplus 86 | } 87 | #endif 88 | 89 | #endif /*__SYSTEM_STM32F10X_H */ 90 | 91 | /** 92 | * @} 93 | */ 94 | 95 | /** 96 | * @} 97 | */ 98 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 99 | -------------------------------------------------------------------------------- /GoKit3ForOpenHamtaro/Hal/Hal_led/Hal_led.c: -------------------------------------------------------------------------------- 1 | /** 2 | ******************************************************** 3 | * 4 | * @file Hal_led.c 5 | * @author Gizwtis 6 | * @version V03010100 7 | * @date 2016-07-05 8 | * 9 | * @brief 机智云.只为智能硬件而生 10 | * Gizwits Smart Cloud for Smart Products 11 | * 链接|增值ֵ|开放|中立|安全|自有|自由|生态 12 | * www.gizwits.com 13 | * 14 | *********************************************************/ 15 | #include "Hal_led/Hal_led.h" 16 | 17 | 18 | void ledGpioInit(void) 19 | { 20 | GPIO_InitTypeDef GPIO_InitStructure; 21 | RCC_APB2PeriphClockCmd(GPIO_LED1_CLK | GPIO_LED2_CLK | GPIO_LED3_CLK | GPIO_LED4_CLK, ENABLE); 22 | 23 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 24 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; 25 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 26 | GPIO_InitStructure.GPIO_Pin = GPIO_LED1_PIN; 27 | GPIO_Init(GPIO_LED1_PORT, &GPIO_InitStructure); 28 | 29 | GPIO_InitStructure.GPIO_Pin = GPIO_LED2_PIN; 30 | GPIO_Init(GPIO_LED2_PORT, &GPIO_InitStructure); 31 | 32 | GPIO_InitStructure.GPIO_Pin = GPIO_LED3_PIN; 33 | GPIO_Init(GPIO_LED3_PORT, &GPIO_InitStructure); 34 | 35 | GPIO_InitStructure.GPIO_Pin = GPIO_LED4_PIN; 36 | GPIO_Init(GPIO_LED4_PORT, &GPIO_InitStructure); 37 | 38 | ledOff(LED1); 39 | ledOff(LED2); 40 | ledOff(LED3); 41 | ledOff(LED4); 42 | } 43 | 44 | void ledOn(uint8_t ledNum) 45 | { 46 | switch (ledNum) 47 | { 48 | case LED1: 49 | GPIO_SetBits(GPIO_LED1_PORT,GPIO_LED1_PIN); 50 | break; 51 | case LED2: 52 | GPIO_SetBits(GPIO_LED2_PORT,GPIO_LED2_PIN); 53 | break; 54 | case LED3: 55 | GPIO_SetBits(GPIO_LED3_PORT,GPIO_LED3_PIN); 56 | break; 57 | case LED4: 58 | GPIO_SetBits(GPIO_LED4_PORT,GPIO_LED4_PIN); 59 | break; 60 | default: 61 | break; 62 | } 63 | } 64 | 65 | void ledOff(uint8_t ledNum) 66 | { 67 | switch (ledNum) 68 | { 69 | case LED1: 70 | GPIO_ResetBits(GPIO_LED1_PORT,GPIO_LED1_PIN); 71 | break; 72 | case LED2: 73 | GPIO_ResetBits(GPIO_LED2_PORT,GPIO_LED2_PIN); 74 | break; 75 | case LED3: 76 | GPIO_ResetBits(GPIO_LED3_PORT,GPIO_LED3_PIN); 77 | break; 78 | case LED4: 79 | GPIO_ResetBits(GPIO_LED4_PORT,GPIO_LED4_PIN); 80 | break; 81 | default: 82 | break; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /GoKit3ForOpenHamtaro/Lib/STM32F10x_StdPeriph_Driver/inc/stm32f10x_crc.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_crc.h 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief This file contains all the functions prototypes for the CRC firmware 8 | * library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 13 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 14 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 15 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 16 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 17 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 18 | * 19 | *

© COPYRIGHT 2011 STMicroelectronics

20 | ****************************************************************************** 21 | */ 22 | 23 | /* Define to prevent recursive inclusion -------------------------------------*/ 24 | #ifndef __STM32F10x_CRC_H 25 | #define __STM32F10x_CRC_H 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | /* Includes ------------------------------------------------------------------*/ 32 | #include "stm32f10x.h" 33 | 34 | /** @addtogroup STM32F10x_StdPeriph_Driver 35 | * @{ 36 | */ 37 | 38 | /** @addtogroup CRC 39 | * @{ 40 | */ 41 | 42 | /** @defgroup CRC_Exported_Types 43 | * @{ 44 | */ 45 | 46 | /** 47 | * @} 48 | */ 49 | 50 | /** @defgroup CRC_Exported_Constants 51 | * @{ 52 | */ 53 | 54 | /** 55 | * @} 56 | */ 57 | 58 | /** @defgroup CRC_Exported_Macros 59 | * @{ 60 | */ 61 | 62 | /** 63 | * @} 64 | */ 65 | 66 | /** @defgroup CRC_Exported_Functions 67 | * @{ 68 | */ 69 | 70 | void CRC_ResetDR(void); 71 | uint32_t CRC_CalcCRC(uint32_t Data); 72 | uint32_t CRC_CalcBlockCRC(uint32_t pBuffer[], uint32_t BufferLength); 73 | uint32_t CRC_GetCRC(void); 74 | void CRC_SetIDRegister(uint8_t IDValue); 75 | uint8_t CRC_GetIDRegister(void); 76 | 77 | #ifdef __cplusplus 78 | } 79 | #endif 80 | 81 | #endif /* __STM32F10x_CRC_H */ 82 | /** 83 | * @} 84 | */ 85 | 86 | /** 87 | * @} 88 | */ 89 | 90 | /** 91 | * @} 92 | */ 93 | 94 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 95 | -------------------------------------------------------------------------------- /ISD9160ForOpenHamtaro/NuvotonPlatform_Keil/Include/Driver/DrvOSC.h: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------*/ 2 | /* */ 3 | /* Copyright(c) 2011 Nuvoton Technology Corp. All rights reserved. */ 4 | /* */ 5 | /*---------------------------------------------------------------------------------------------------------*/ 6 | #ifndef DRVOSC_H 7 | #define DRVOSC_H 8 | 9 | #include "ISD9xx.h" 10 | 11 | /*---------------------------------------------------------------------------------------------------------*/ 12 | /* Macro, type and constant definitions */ 13 | /*---------------------------------------------------------------------------------------------------------*/ 14 | #define DRVOSC_MAJOR_NUM 1 15 | #define DRVOSC_MINOR_NUM 00 16 | #define DRVOSC_BUILD_NUM 1 17 | 18 | #define DRVOSC_VERSION_NUM _SYSINFRA_VERSION(DRVOSC_MAJOR_NUM,DRVOSC_MINOR_NUM,DRVOSC_BUILD_NUM) 19 | 20 | // Define some reserve range in oscillator trim so it doesn't trim to maximum fine settings. 21 | // This may be used in I2S slave mode for synchronization purposes. 22 | #define DRVOSC_RESERVE_RANGE 2 23 | #define DRVOSC_MAX_COARSE 7 24 | #define DRVOSC_MAX_FINE 31 25 | #define DRVOSC_NUM_CYCLES 18 26 | #define DRVOSC_MEAS_HCLK_DIV 2 27 | 28 | /*---------------------------------------------------------------------------------------------------------*/ 29 | /* Define Error Code */ 30 | /*---------------------------------------------------------------------------------------------------------*/ 31 | /* Error code */ 32 | //E_DRVOSC_COARSE_OVF Osc trimming error during coarse range 33 | //E_DRVOSC_MEAS_TIMEOUT Oscillator measurement error. Reference clock not available? 34 | //E_DRVOSC_FINE_OVF Osc trimming error during fine range 35 | #define E_DRVOSC_COARSE_OVF _SYSINFRA_ERRCODE(TRUE, MODULE_ID_DRVOSC, 1) 36 | #define E_DRVOSC_MEAS_TIMEOUT _SYSINFRA_ERRCODE(TRUE, MODULE_ID_DRVOSC, 2) 37 | #define E_DRVOSC_FINE_OVF _SYSINFRA_ERRCODE(TRUE, MODULE_ID_DRVOSC, 3) 38 | 39 | int32_t DrvOSC_TrimOscillator(int32_t target, int32_t index); 40 | 41 | int32_t DrvOSC_MeasureOsc(int32_t hclk_div, int32_t num_cycles); 42 | #endif 43 | 44 | -------------------------------------------------------------------------------- /GoKit3ForOpenHamtaro/Gizwits/gizwits_product.h: -------------------------------------------------------------------------------- 1 | #ifndef _GIZWITS_PRODUCT_H 2 | #define _GIZWITS_PRODUCT_H 3 | 4 | #include 5 | #include 6 | #include "gizwits_protocol.h" 7 | 8 | #define SOFTWARE_VERSION "03010100" 9 | #define HARDWARE_VERSION "03010100" 10 | 11 | #ifndef SOFTWARE_VERSION 12 | #error "no define SOFTWARE_VERSION" 13 | #endif 14 | 15 | #ifndef HARDWARE_VERSION 16 | #error "no define HARDWARE_VERSION" 17 | #endif 18 | 19 | 20 | 21 | #define TIMER TIM3 22 | #define TIMER_IRQ TIM3_IRQn 23 | #define TIMER_RCC RCC_APB1Periph_TIM3 24 | #define TIMER_IRQ_FUN TIM3_IRQHandler 25 | 26 | #define UART_BAUDRATE 9600 27 | #define UART_PORT 2 28 | #define UART USART2 29 | #define UART_IRQ USART2_IRQn 30 | #define UART_IRQ_FUN USART2_IRQHandler 31 | 32 | #if (UART_PORT == 1) 33 | #define UART_GPIO_Cmd RCC_APB2PeriphClockCmd 34 | #define UART_GPIO_CLK RCC_APB2Periph_GPIOA 35 | 36 | #define UART_AFIO_Cmd RCC_APB2PeriphClockCmd 37 | #define UART_AFIO_CLK RCC_APB2Periph_AFIO 38 | 39 | #define UART_CLK_Cmd RCC_APB2PeriphClockCmd 40 | #define UART_CLK RCC_APB2Periph_USART1 41 | 42 | #define UART_GPIO_PORT GPIOA 43 | #define UART_RxPin GPIO_Pin_10 44 | #define UART_TxPin GPIO_Pin_9 45 | #endif 46 | 47 | #if (UART_PORT == 2) 48 | #define UART_GPIO_Cmd RCC_APB2PeriphClockCmd 49 | #define UART_GPIO_CLK RCC_APB2Periph_GPIOA 50 | 51 | #define UART_AFIO_Cmd RCC_APB2PeriphClockCmd 52 | #define UART_AFIO_CLK RCC_APB2Periph_AFIO 53 | 54 | #define UART_CLK_Cmd RCC_APB1PeriphClockCmd 55 | #define UART_CLK RCC_APB1Periph_USART2 56 | 57 | #define UART_GPIO_PORT GPIOA 58 | #define UART_RxPin GPIO_Pin_3 59 | #define UART_TxPin GPIO_Pin_2 60 | #endif 61 | 62 | 63 | #if (UART_PORT == 3) 64 | 65 | #define UART_GPIO_Cmd RCC_APB2PeriphClockCmd 66 | #define UART_GPIO_CLK RCC_APB2Periph_GPIOC 67 | 68 | #define UART_AFIO_Cmd RCC_APB2PeriphClockCmd 69 | #define UART_AFIO_CLK RCC_APB2Periph_AFIO 70 | 71 | #define UART_CLK_Cmd RCC_APB1PeriphClockCmd 72 | #define UART_CLK RCC_APB1Periph_USART3 73 | 74 | #define UART_GPIO_PORT GPIOC 75 | #define UART_RxPin GPIO_Pin_11 76 | #define UART_TxPin GPIO_Pin_10 77 | 78 | #endif 79 | 80 | #define REPORT_TIME_MAX 2000 //2S 81 | 82 | 83 | void timerInit(void); 84 | void uartInit(void); 85 | int8_t uartWrite(uint8_t *buf, uint32_t len); 86 | void platformInit(void); 87 | void platformHandle(void); 88 | #endif 89 | -------------------------------------------------------------------------------- /ISD9160ForOpenHamtaro/CMSIS/CM0/DeviceSupport/Nuvoton/ISD91xx/system_ISD9xx.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file system_ARMCM0.h 3 | * @brief CMSIS Cortex-M0 Device System Header File 4 | * for CM0 Device Series 5 | * @version V1.03 6 | * @date 24. September 2010 7 | * 8 | * @note 9 | * Copyright (C) 2010 ARM Limited. All rights reserved. 10 | * 11 | * @par 12 | * ARM Limited (ARM) is supplying this software for use with Cortex-M 13 | * processor based microcontrollers. This file can be freely distributed 14 | * within development tools that are supporting such ARM based processors. 15 | * 16 | * @par 17 | * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED 18 | * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF 19 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. 20 | * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR 21 | * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. 22 | * 23 | ******************************************************************************/ 24 | 25 | 26 | #ifndef __SYSTEM_ARMCM0_H 27 | #define __SYSTEM_ARMCM0_H 28 | 29 | #ifdef __cplusplus 30 | extern "C" { 31 | #endif 32 | 33 | 34 | /* SysTick constants */ 35 | #define SYSTICK_ENABLE 0 /* Config-Bit to start or stop the SysTick Timer */ 36 | #define SYSTICK_TICKINT 1 /* Config-Bit to enable or disable the SysTick interrupt */ 37 | #define SYSTICK_CLKSOURCE 2 /* Clocksource has the offset 2 in SysTick Control and Status Register */ 38 | #define SYSTICK_MAXCOUNT ((1<<24) -1) /* SysTick MaxCount */ 39 | 40 | 41 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ 42 | 43 | 44 | /** 45 | * Initialize the system 46 | * 47 | * @param none 48 | * @return none 49 | * 50 | * @brief Setup the microcontroller system. 51 | * Initialize the System and update the SystemCoreClock variable. 52 | */ 53 | extern void SystemInit (void); 54 | 55 | /** 56 | * Update SystemCoreClock variable 57 | * 58 | * @param none 59 | * @return none 60 | * 61 | * @brief Updates the SystemCoreClock with current core Clock 62 | * retrieved from cpu registers. 63 | */ 64 | extern void SystemCoreClockUpdate (void); 65 | 66 | #ifdef __cplusplus 67 | } 68 | #endif 69 | 70 | #endif /* __SYSTEM_ARMCM0_H */ 71 | -------------------------------------------------------------------------------- /ISD9160ForOpenHamtaro/NuvotonPlatform_Keil/Sample/CSpotter_OpenHamtaro/CSpotterSDKApi_Const.h: -------------------------------------------------------------------------------- 1 | #ifndef __CSPOTTER_SDK_API_CONST_H__ 2 | #define __CSPOTTER_SDK_API_CONST_H__ 3 | 4 | 5 | #define CSPOTTER_SUCCESS ( 0 ) 6 | #define CSPOTTER_ERR_SDKError ( -2000 ) 7 | #define CSPOTTER_ERR_LexiconError ( -3000 ) 8 | #define CSPOTTER_ERR_EngineError ( -5000 ) 9 | 10 | 11 | /************************************************************************/ 12 | // Recognition type 13 | /************************************************************************/ 14 | #define CSPOTTER_RecogType_Unknown (0) 15 | #define CSPOTTER_RecogType_Passed (1) 16 | #define CSPOTTER_RecogType_NotGoodEnough (2) 17 | #define CSPOTTER_RecogType_MissStartSyllalbe (3) 18 | #define CSPOTTER_RecogType_MissEndSyllalbe (4) 19 | 20 | 21 | 22 | /************************************************************************/ 23 | // Error code 24 | /************************************************************************/ 25 | 26 | #define CSPOTTER_ERR_IllegalHandle ( CSPOTTER_ERR_SDKError - 1 ) 27 | #define CSPOTTER_ERR_IllegalParam ( CSPOTTER_ERR_SDKError - 2 ) 28 | #define CSPOTTER_ERR_LeaveNoMemory ( CSPOTTER_ERR_SDKError - 3 ) 29 | #define CSPOTTER_ERR_LoadDLLFailed ( CSPOTTER_ERR_SDKError - 4 ) 30 | #define CSPOTTER_ERR_LoadModelFailed ( CSPOTTER_ERR_SDKError - 5 ) 31 | #define CSPOTTER_ERR_GetFunctionFailed ( CSPOTTER_ERR_SDKError - 6 ) 32 | #define CSPOTTER_ERR_ParseEINFailed ( CSPOTTER_ERR_SDKError - 7 ) 33 | #define CSPOTTER_ERR_OpenFileFailed ( CSPOTTER_ERR_SDKError - 8 ) 34 | #define CSPOTTER_ERR_NeedMoreSample ( CSPOTTER_ERR_SDKError - 9 ) 35 | #define CSPOTTER_ERR_Timeout ( CSPOTTER_ERR_SDKError - 10 ) 36 | #define CSPOTTER_ERR_InitWTFFailed ( CSPOTTER_ERR_SDKError - 11 ) 37 | #define CSPOTTER_ERR_AddSampleFailed ( CSPOTTER_ERR_SDKError - 12 ) 38 | #define CSPOTTER_ERR_BuildUserCommandFailed ( CSPOTTER_ERR_SDKError - 13 ) 39 | #define CSPOTTER_ERR_MergeUserCommandFailed ( CSPOTTER_ERR_SDKError - 14 ) 40 | #define CSPOTTER_ERR_IllegalUserCommandFile ( CSPOTTER_ERR_SDKError - 15 ) 41 | #define CSPOTTER_ERR_IllegalWaveFile ( CSPOTTER_ERR_SDKError - 16 ) 42 | #define CSPOTTER_ERR_BuildCommandFailed ( CSPOTTER_ERR_SDKError - 17 ) 43 | #define CSPOTTER_ERR_InitFixNRFailed ( CSPOTTER_ERR_SDKError - 18 ) 44 | #define CSPOTTER_ERR_EXCEED_NR_BUFFER_SIZE ( CSPOTTER_ERR_SDKError - 19 ) 45 | #define CSPOTTER_ERR_Expired ( CSPOTTER_ERR_SDKError - 100 ) 46 | #define CSPOTTER_ERR_LicenseFailed ( CSPOTTER_ERR_SDKError - 200 ) 47 | 48 | #endif //__CSPOTTER_SDK_API_CONST_H__ 49 | 50 | -------------------------------------------------------------------------------- /ISD9160ForOpenHamtaro/NuvotonPlatform_Keil/Include/Driver/DrvCRC.h: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------*/ 2 | /* */ 3 | /* Copyright(c) 2011 Nuvoton Technology Corp. All rights reserved. */ 4 | /* */ 5 | /*---------------------------------------------------------------------------------------------------------*/ 6 | #ifndef __DRVCRC_H__ 7 | #define __DRVCRC_H__ 8 | 9 | #include "ISD9xx.h" 10 | #include "System/SysInfra.h" 11 | 12 | /*---------------------------------------------------------------------------------------------------------*/ 13 | /* Macro, type and constant definitions */ 14 | /*---------------------------------------------------------------------------------------------------------*/ 15 | #define DRVCRC_MAJOR_NUM 1 16 | #define DRVCRC_MINOR_NUM 00 17 | #define DRVCRC_BUILD_NUM 001 18 | 19 | #define DRVCRC_VERSION_NUM _SYSINFRA_VERSION(DRVCRC_MAJOR_NUM,DRVCRC_MINOR_NUM,DRVCRC_BUILD_NUM) 20 | 21 | /*---------------------------------------------------------------------------------------------------------*/ 22 | /* Define Error Code */ 23 | /*---------------------------------------------------------------------------------------------------------*/ 24 | // E_DRVSPI_ERR_BURST_CNT Wrong Burst Number 25 | // E_DRVSPI_ERR_TRANSMIT_INTERVAL Wrong Transmit Number 26 | // E_DRVSPI_ERR_BIT_LENGTH Wrong Bit Length 27 | // E_DRVSPI_ERR_INIT Init Fail 28 | // E_DRVSPI_ERR_BUSY SPI is busy 29 | // E_DRVSPI_ERR_PORT SPI Port does not exist 30 | #define E_DRVCRC_ERR_ODD_PACKET _SYSINFRA_ERRCODE(TRUE, MODULE_ID_DRVCRC, 0) 31 | #define E_DRVCRC_ERR_PACKET_TOO_LONG _SYSINFRA_ERRCODE(TRUE, MODULE_ID_DRVCRC, 1) 32 | #define E_DRVCRC_ERR_BIT_LENGTH _SYSINFRA_ERRCODE(TRUE, MODULE_ID_DRVCRC, 2) 33 | 34 | typedef int32_t ERRCODE; 35 | typedef unsigned char BOOL; 36 | 37 | typedef enum { 38 | eDRVCRC_MSB, 39 | eDRVCRC_LSB 40 | } E_DRVCRC_ENDIAN; 41 | 42 | 43 | 44 | /*---------------------------------------------------------------------------------------------------------*/ 45 | /* Define Function Prototypes */ 46 | /*---------------------------------------------------------------------------------------------------------*/ 47 | ERRCODE DrvCRC_Open(void); 48 | ERRCODE DrvCRC_Init(E_DRVCRC_ENDIAN eLSB, int32_t i32PacketLen); 49 | int16_t DrvCRC_Calc( uint32_t *Data, int32_t i32PacketLen); 50 | void DrvCRC_Close(void); 51 | uint32_t DrvCRC_GetVersion(void); 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /ISD9160ForOpenHamtaro/NuvotonPlatform_Keil/Include/Lib/libSPIFlash.h: -------------------------------------------------------------------------------- 1 | 2 | // qkdang 3 | 4 | #ifndef SFLASHHDR 5 | #define SFLASHHDR 6 | 7 | /////////Flash cmd status 8 | #define CMDSUCCESS 0 9 | #define CMDFAIL 1 10 | #define CMDFLASHBUSY 2 11 | #define CMDINVALID 3 12 | 13 | typedef struct tagSFLASH_CTX 14 | { 15 | unsigned long spi_base; 16 | unsigned long spi_chnl; // 1, 2 17 | void (*spi_setcs)(const struct tagSFLASH_CTX *ctx, int csOn); 18 | }SFLASH_CTX; 19 | 20 | extern void sflash_set(const SFLASH_CTX *ctx); 21 | extern void sflash_write_ena(const SFLASH_CTX *ctx); 22 | extern int sflash_erase(const SFLASH_CTX *ctx, unsigned long addr, unsigned long len); 23 | extern int sflash_eraseall(const SFLASH_CTX *ctx); 24 | extern int sflash_canwrite(const SFLASH_CTX *ctx); 25 | extern int sflash_write(const SFLASH_CTX *ctx, unsigned long addr, unsigned long* p, unsigned long bytes); 26 | extern int sflash_read(const SFLASH_CTX *ctx, unsigned long addr, unsigned long* p, unsigned long bytes); 27 | extern int sflash_fread(const SFLASH_CTX *ctx, unsigned long addr, unsigned long* p, unsigned long bytes); 28 | extern int sflash_getid(const SFLASH_CTX *ctx); 29 | extern int sflash_power_down(const SFLASH_CTX *ctx); 30 | extern int sflash_release_power_down(const SFLASH_CTX *ctx); 31 | 32 | extern int sflash_check_busy(const SFLASH_CTX *ctx); 33 | extern int sflash_nonblock_eraseall(const SFLASH_CTX *ctx); 34 | extern int sflash_nonblock_power_down(const SFLASH_CTX *ctx); 35 | extern int sflash_nonblock_sectorerase(const SFLASH_CTX *ctx, unsigned long addr); 36 | extern int sflash_nonblock_write(const SFLASH_CTX *ctx, unsigned long addr, unsigned long* p, unsigned long bytes); 37 | extern int sflash_nonblock_read(const SFLASH_CTX *ctx, unsigned long addr, unsigned long* p, unsigned long bytes); 38 | extern int sflash_nonblock_MIDIread(const SFLASH_CTX *ctx, unsigned long addr, unsigned char* p, long bytes); 39 | extern int sflash_nonblock_fread(const SFLASH_CTX *ctx, unsigned long addr, unsigned long* p, unsigned long bytes); 40 | 41 | 42 | #define LibSPIFlash_Open sflash_set //Set ISD9160 related register 43 | #define LibSPIFlash_WriteEnable sflash_write_ena //command 06 44 | #define LibSPIFlash_Erase sflash_erase //command 20 45 | #define LibSPIFlash_EraseAll sflash_eraseall //command 60 46 | //#define LibSPIFlash_ReadWEL sflash_canwrite 47 | #define LibSPIFlash_Write sflash_write //command 02, page program 48 | #define LibSPIFlash_FastRead sflash_fread //command 0B 49 | #define LibSPIFlash_Read sflash_read //command 03 50 | #define LibSPIFlash_GetID sflash_getid //command 9F 51 | #define LibSPIFlash_PowerDown sflash_power_down //command B9 52 | #define LibSPIFlash_ReleasePD sflash_release_power_down //command AB 53 | 54 | #define LibSPIFlash_Nonblock_Erase sflash_nonblock_sectorerase //command 20 55 | #define LibSPIFlash_Nonblock_EraseAll sflash_nonblock_eraseall //command 60 56 | #define LibSPIFlash_Nonblock_PowerDown sflash_nonblock_power_down //command B9 57 | #define LibSPIFlash_Nonblock_Write sflash_nonblock_write //command 02 58 | 59 | 60 | #endif // SFLASHHDR 61 | -------------------------------------------------------------------------------- /ISD9160ForOpenHamtaro/NuvotonPlatform_Keil/Include/Lib/libSPIFlash.h.bak: -------------------------------------------------------------------------------- 1 | 2 | // qkdang 3 | 4 | #ifndef SFLASHHDR 5 | #define SFLASHHDR 6 | 7 | /////////Flash cmd status 8 | #define CMDSUCCESS 0 9 | #define CMDFAIL 1 10 | #define CMDFLASHBUSY 2 11 | #define CMDINVALID 3 12 | 13 | typedef struct tagSFLASH_CTX 14 | { 15 | unsigned long spi_base; 16 | unsigned long spi_chnl; // 1, 2 17 | void (*spi_setcs)(const struct tagSFLASH_CTX *ctx, int csOn); 18 | }SFLASH_CTX; 19 | 20 | extern void sflash_set(const SFLASH_CTX *ctx); 21 | extern void sflash_write_ena(const SFLASH_CTX *ctx); 22 | extern int sflash_erase(const SFLASH_CTX *ctx, unsigned long addr, unsigned long len); 23 | extern int sflash_eraseall(const SFLASH_CTX *ctx); 24 | extern int sflash_canwrite(const SFLASH_CTX *ctx); 25 | extern int sflash_write(const SFLASH_CTX *ctx, unsigned long addr, unsigned long* p, unsigned long bytes); 26 | extern int sflash_read(const SFLASH_CTX *ctx, unsigned long addr, unsigned long* p, unsigned long bytes); 27 | extern int sflash_fread(const SFLASH_CTX *ctx, unsigned long addr, unsigned long* p, unsigned long bytes); 28 | extern int sflash_getid(const SFLASH_CTX *ctx); 29 | extern int sflash_power_down(const SFLASH_CTX *ctx); 30 | extern int sflash_release_power_down(const SFLASH_CTX *ctx); 31 | 32 | extern int sflash_check_busy(const SFLASH_CTX *ctx); 33 | extern int sflash_nonblock_eraseall(const SFLASH_CTX *ctx); 34 | extern int sflash_nonblock_power_down(const SFLASH_CTX *ctx); 35 | extern int sflash_nonblock_sectorerase(const SFLASH_CTX *ctx, unsigned long addr); 36 | extern int sflash_nonblock_write(const SFLASH_CTX *ctx, unsigned long addr, unsigned long* p, unsigned long bytes); 37 | extern int sflash_nonblock_read(const SFLASH_CTX *ctx, unsigned long addr, unsigned long* p, unsigned long bytes); 38 | extern int sflash_nonblock_MIDIread(const SFLASH_CTX *ctx, unsigned long addr, unsigned char* p, long bytes); 39 | extern int sflash_nonblock_fread(const SFLASH_CTX *ctx, unsigned long addr, unsigned long* p, unsigned long bytes); 40 | 41 | 42 | #define LibSPIFlash_Open sflash_set //Set ISD9160 related register 43 | #define LibSPIFlash_WriteEnable sflash_write_ena //command 06 44 | #define LibSPIFlash_Erase sflash_erase //command 20 45 | #define LibSPIFlash_EraseAll sflash_eraseall //command 60 46 | //#define LibSPIFlash_ReadWEL sflash_canwrite 47 | #define LibSPIFlash_Write sflash_write //command 02, page program 48 | #define LibSPIFlash_FastRead sflash_fread //command 0B 49 | #define LibSPIFlash_Read sflash_read //command 03 50 | #define LibSPIFlash_GetID sflash_getid //command 9F 51 | #define LibSPIFlash_PowerDown sflash_power_down //command B9 52 | #define LibSPIFlash_ReleasePD sflash_release_power_down //command AB 53 | 54 | #define LibSPIFlash_Nonblock_Erase sflash_nonblock_erase //command 20 55 | #define LibSPIFlash_Nonblock_EraseAll sflash_nonblock_eraseall //command 60 56 | #define LibSPIFlash_Nonblock_PowerDown sflash_nonblock_power_down //command B9 57 | #define LibSPIFlash_Nonblock_Write sflash_nonblock_write //command 02 58 | 59 | 60 | #endif // SFLASHHDR 61 | -------------------------------------------------------------------------------- /ISD9160ForOpenHamtaro/NuvotonPlatform_Keil/Include/Driver/DrvCapSense.h: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------*/ 2 | /* */ 3 | /* Copyright(c) 2009 Nuvoton Technology Corp. All rights reserved. */ 4 | /* */ 5 | /*---------------------------------------------------------------------------------------------------------*/ 6 | #ifndef _DRVCAPSENSE_H 7 | #define _DRVCAPSENSE_H 8 | 9 | #include "ISD9xx.h" 10 | 11 | /*---------------------------------------------------------------------------------------------------------*/ 12 | /* Define Version number */ 13 | /*---------------------------------------------------------------------------------------------------------*/ 14 | 15 | /*---------------------------------------------------------------------------------------------------------*/ 16 | /* Version define with SysInfra */ 17 | /*---------------------------------------------------------------------------------------------------------*/ 18 | 19 | /*---------------------------------------------------------------------------------------------------------*/ 20 | /* Define Error Code */ 21 | /*---------------------------------------------------------------------------------------------------------*/ 22 | 23 | /*---------------------------------------------------------------------------------------------------------*/ 24 | /* Define parameter */ 25 | /*---------------------------------------------------------------------------------------------------------*/ 26 | 27 | #define LOW_TIME_3 0x3 28 | #define LOW_TIME_2 0x2 29 | #define LOW_TIME_1 0x1 30 | #define LOW_TIME_0 0x0 31 | 32 | #define CYCLE_CNT_7 0x7 33 | #define CYCLE_CNT_6 0x6 34 | #define CYCLE_CNT_5 0x5 35 | #define CYCLE_CNT_4 0x4 36 | #define CYCLE_CNT_3 0x3 37 | #define CYCLE_CNT_2 0x2 38 | #define CYCLE_CNT_1 0x1 39 | #define CYCLE_CNT_0 0x0 40 | 41 | typedef enum { 42 | eDRVCAP_0p5uA, 43 | eDRVCAP_1uA, 44 | eDRVCAP_2p5uA, 45 | eDRVCAP_5uA 46 | } E_DRVCAO_ISRC; 47 | 48 | /*---------------------------------------------------------------------------------------------------------*/ 49 | /* Define I2S functions prototype */ 50 | /*---------------------------------------------------------------------------------------------------------*/ 51 | 52 | void DrvCAPSENSE_ISRC_En(uint32_t bits); 53 | void DrvCAPSENSE_ISRC_Val(uint32_t val); 54 | void DrvCAPSENSE_Ctrl(uint32_t time, uint32_t cnt); 55 | void DrvCAPSENSE_INT_Enable(void); 56 | void DrvCAPSENSE_INT_Disable(void); 57 | void DrvCAPSENSE_ResetCnt(void); 58 | void DrvCAPSENSE_CntEnable(void); 59 | 60 | #endif 61 | 62 | -------------------------------------------------------------------------------- /ISD9160ForOpenHamtaro/NuvotonPlatform_Keil/Include/Driver/DrvACMP.H: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------*/ 2 | /* */ 3 | /* Copyright(c) 2009 Nuvoton Technology Corp. All rights reserved. */ 4 | /* */ 5 | /*---------------------------------------------------------------------------------------------------------*/ 6 | #ifndef __DRVACMP_H__ 7 | #define __DRVACMP_H__ 8 | 9 | #include "ISD9xx.h" 10 | 11 | /*---------------------------------------------------------------------------------------------------------*/ 12 | /* Macro, type and constant definitions */ 13 | /*---------------------------------------------------------------------------------------------------------*/ 14 | typedef void (PFN_DRVACMP_CALLBACK)(void); 15 | 16 | #define CMP0 0 17 | #define CMP1 1 18 | 19 | /*---------------------------------------------------------------------------------------------------------*/ 20 | /* Define Version number */ 21 | /*---------------------------------------------------------------------------------------------------------*/ 22 | #define DRVACMP_MAJOR_NUM 1 23 | #define DRVACMP_MINOR_NUM 00 24 | #define DRVACMP_BUILD_NUM 1 25 | 26 | 27 | #define DRVACMP_VERSION_NUM _SYSINFRA_VERSION(DRVACMP_MAJOR_NUM, DRVACMP_MINOR_NUM, DRVACMP_BUILD_NUM) 28 | /*---------------------------------------------------------------------------------------------------------*/ 29 | /* Define Error Code */ 30 | /*---------------------------------------------------------------------------------------------------------*/ 31 | 32 | /*---------------------------------------------------------------------------------------------------------*/ 33 | /* Global interface variables declarations */ 34 | /*---------------------------------------------------------------------------------------------------------*/ 35 | #define CMPCR_CN0_VMID 1 36 | #define CMPCR_CN0_VBG 0 37 | #define CMPCR_CN1_VBG 1 38 | #define CMPCR_CN1_GPIB7 0 39 | #define CMPCR_CMPIE_EN 1 40 | #define CMPCR_CMPIE_DIS 0 41 | #define CMPCR_CMPEN_EN 1 42 | #define CMPCR_CMPEN_DIS 0 43 | 44 | 45 | /*---------------------------------------------------------------------------------------------------------*/ 46 | /* Define Function Prototype */ 47 | /*---------------------------------------------------------------------------------------------------------*/ 48 | void DrvACMP_Ctrl(uint8_t com, uint8_t CN, uint8_t IE, uint8_t EN); 49 | void DrvACMP_InstallISR(PFN_DRVACMP_CALLBACK callback); 50 | 51 | 52 | 53 | #endif // __DRVACMP_H__ 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /ISD9160ForOpenHamtaro/NuvotonPlatform_Keil/Include/Lib/LibAdpcmCodec.h: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------------------------------------*/ 2 | /* */ 3 | /* Copyright(c) 2011 Nuvoton Technology Corp. All rights reserved. */ 4 | /* */ 5 | /*----------------------------------------------------------------------------------------*/ 6 | /*----------------------------------------------------------------------------------------*/ 7 | /* Include related headers */ 8 | /*----------------------------------------------------------------------------------------*/ 9 | #ifndef __LIBADPCMCODEC_H__ 10 | #define __LIBADPCMCODEC_H__ 11 | 12 | #include "ISD9xx.h" 13 | #include "System/SysInfra.h" 14 | #include "NVTTypes.h" 15 | 16 | /*---------------------------------------------------------------------------------------------------------*/ 17 | /* Macro, type and constant definitions */ 18 | /*---------------------------------------------------------------------------------------------------------*/ 19 | #define LIBADPCM_HEADER_SIZE 4 20 | 21 | typedef struct tsAdpcm_BufInfo 22 | { 23 | BYTE* pbyInBufAddr; 24 | uint16_t ui16InBufSize; 25 | uint16_t ui16RIndex; 26 | uint16_t ui16WIndex; 27 | uint16_t ui16WSize; 28 | }sAdpcm_BufInfo; 29 | 30 | typedef struct tsAdpcmState 31 | { 32 | int16_t i16PrevValue; // Previous output value. 33 | int8_t i8StepIndex; // Index of stepsize table 34 | 35 | uint8_t ui8Channels; // Channel number. 36 | uint16_t ui16SmplPerBlock; // Total samples per block. 37 | uint16_t ui16BytesPerBlock; // Total bytes per block. 38 | uint16_t ui16SmplIndex; // Sample index of current block 39 | uint8_t ui8PrevByte; // pointer to previous output bytes address 40 | }sLibAdpcmState; 41 | 42 | /*----------------------------------------------------------------------------------------*/ 43 | /* Define functions prototype */ 44 | /*----------------------------------------------------------------------------------------*/ 45 | uint32_t LibAdpcmInit(sLibAdpcmState* psState, uint16_t ui16Channels, 46 | uint32_t ui32SamplingRate, uint16_t ui16BitsPerSample); 47 | 48 | void LibAdpcm_Encode(PINT16 pi16Indata, BYTE* pbOutdata, 49 | uint16_t ui16Len, sLibAdpcmState* psState); 50 | 51 | void LibAdpcm_Decode(BYTE* pbIndata, PINT16 pi16Outdata, uint16_t ui16Len, sLibAdpcmState* psState, 52 | uint8_t ui8ChannelIndex, uint8_t ui8ChannelNextDataWordOffset); 53 | 54 | extern BOOL LibAdpcm_EncodeBlock(PINT16 pi16InData, BYTE* pbOutData, 55 | uint16_t ui16SampleCount, sLibAdpcmState* psState); 56 | 57 | extern BOOL LibAdpcm_DecodeBlock(BYTE* pbInData, PINT16 pi16OutData, uint16_t ui16SampleCount, 58 | sLibAdpcmState* psState); 59 | #endif //__LIBADPCMCODEC_H__ 60 | 61 | 62 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /GoKit3ForOpenHamtaro/User/stm32f10x_conf.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file GPIO/IOToggle/stm32f10x_conf.h 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 08-April-2011 7 | * @brief Library configuration file. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2011 STMicroelectronics

19 | ****************************************************************************** 20 | */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __STM32F10x_CONF_H 24 | #define __STM32F10x_CONF_H 25 | 26 | /* Includes ------------------------------------------------------------------*/ 27 | /* Uncomment/Comment the line below to enable/disable peripheral header file inclusion */ 28 | #include "stm32f10x_adc.h" 29 | #include "stm32f10x_bkp.h" 30 | #include "stm32f10x_can.h" 31 | #include "stm32f10x_cec.h" 32 | #include "stm32f10x_crc.h" 33 | #include "stm32f10x_dac.h" 34 | #include "stm32f10x_dbgmcu.h" 35 | #include "stm32f10x_dma.h" 36 | #include "stm32f10x_exti.h" 37 | #include "stm32f10x_flash.h" 38 | #include "stm32f10x_fsmc.h" 39 | #include "stm32f10x_gpio.h" 40 | #include "stm32f10x_i2c.h" 41 | #include "stm32f10x_iwdg.h" 42 | #include "stm32f10x_pwr.h" 43 | #include "stm32f10x_rcc.h" 44 | #include "stm32f10x_rtc.h" 45 | #include "stm32f10x_sdio.h" 46 | #include "stm32f10x_spi.h" 47 | #include "stm32f10x_tim.h" 48 | #include "stm32f10x_usart.h" 49 | #include "stm32f10x_wwdg.h" 50 | #include "misc.h" /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */ 51 | 52 | /* Exported types ------------------------------------------------------------*/ 53 | /* Exported constants --------------------------------------------------------*/ 54 | /* Uncomment the line below to expanse the "assert_param" macro in the 55 | Standard Peripheral Library drivers code */ 56 | /* #define USE_FULL_ASSERT 1 */ 57 | 58 | /* Exported macro ------------------------------------------------------------*/ 59 | #ifdef USE_FULL_ASSERT 60 | 61 | /** 62 | * @brief The assert_param macro is used for function's parameters check. 63 | * @param expr: If expr is false, it calls assert_failed function which reports 64 | * the name of the source file and the source line number of the call 65 | * that failed. If expr is true, it returns no value. 66 | * @retval None 67 | */ 68 | #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__)) 69 | /* Exported functions ------------------------------------------------------- */ 70 | void assert_failed(uint8_t* file, uint32_t line); 71 | #else 72 | #define assert_param(expr) ((void)0) 73 | #endif /* USE_FULL_ASSERT */ 74 | 75 | #endif /* __STM32F10x_CONF_H */ 76 | 77 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 78 | -------------------------------------------------------------------------------- /GoKit3ForOpenHamtaro/Lib/STM32F10x_StdPeriph_Driver/inc/stm32f10x_wwdg.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_wwdg.h 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief This file contains all the functions prototypes for the WWDG firmware 8 | * library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 13 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 14 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 15 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 16 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 17 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 18 | * 19 | *

© COPYRIGHT 2011 STMicroelectronics

20 | ****************************************************************************** 21 | */ 22 | 23 | /* Define to prevent recursive inclusion -------------------------------------*/ 24 | #ifndef __STM32F10x_WWDG_H 25 | #define __STM32F10x_WWDG_H 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | /* Includes ------------------------------------------------------------------*/ 32 | #include "stm32f10x.h" 33 | 34 | /** @addtogroup STM32F10x_StdPeriph_Driver 35 | * @{ 36 | */ 37 | 38 | /** @addtogroup WWDG 39 | * @{ 40 | */ 41 | 42 | /** @defgroup WWDG_Exported_Types 43 | * @{ 44 | */ 45 | 46 | /** 47 | * @} 48 | */ 49 | 50 | /** @defgroup WWDG_Exported_Constants 51 | * @{ 52 | */ 53 | 54 | /** @defgroup WWDG_Prescaler 55 | * @{ 56 | */ 57 | 58 | #define WWDG_Prescaler_1 ((uint32_t)0x00000000) 59 | #define WWDG_Prescaler_2 ((uint32_t)0x00000080) 60 | #define WWDG_Prescaler_4 ((uint32_t)0x00000100) 61 | #define WWDG_Prescaler_8 ((uint32_t)0x00000180) 62 | #define IS_WWDG_PRESCALER(PRESCALER) (((PRESCALER) == WWDG_Prescaler_1) || \ 63 | ((PRESCALER) == WWDG_Prescaler_2) || \ 64 | ((PRESCALER) == WWDG_Prescaler_4) || \ 65 | ((PRESCALER) == WWDG_Prescaler_8)) 66 | #define IS_WWDG_WINDOW_VALUE(VALUE) ((VALUE) <= 0x7F) 67 | #define IS_WWDG_COUNTER(COUNTER) (((COUNTER) >= 0x40) && ((COUNTER) <= 0x7F)) 68 | 69 | /** 70 | * @} 71 | */ 72 | 73 | /** 74 | * @} 75 | */ 76 | 77 | /** @defgroup WWDG_Exported_Macros 78 | * @{ 79 | */ 80 | /** 81 | * @} 82 | */ 83 | 84 | /** @defgroup WWDG_Exported_Functions 85 | * @{ 86 | */ 87 | 88 | void WWDG_DeInit(void); 89 | void WWDG_SetPrescaler(uint32_t WWDG_Prescaler); 90 | void WWDG_SetWindowValue(uint8_t WindowValue); 91 | void WWDG_EnableIT(void); 92 | void WWDG_SetCounter(uint8_t Counter); 93 | void WWDG_Enable(uint8_t Counter); 94 | FlagStatus WWDG_GetFlagStatus(void); 95 | void WWDG_ClearFlag(void); 96 | 97 | #ifdef __cplusplus 98 | } 99 | #endif 100 | 101 | #endif /* __STM32F10x_WWDG_H */ 102 | 103 | /** 104 | * @} 105 | */ 106 | 107 | /** 108 | * @} 109 | */ 110 | 111 | /** 112 | * @} 113 | */ 114 | 115 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 116 | -------------------------------------------------------------------------------- /GoKit3ForOpenHamtaro/Hal/Hal_rgb_led/hal_rgb_led.c: -------------------------------------------------------------------------------- 1 | /** 2 | ******************************************************** 3 | * 4 | * @file Hal_rgb_led.c 5 | * @author Gizwtis 6 | * @version V03010100 7 | * @date 2016-07-05 8 | * 9 | * @brief 机智云.只为智能硬件而生 10 | * Gizwits Smart Cloud for Smart Products 11 | * 链接|增值ֵ|开放|中立|安全|自有|自由|生态 12 | * www.gizwits.com 13 | * 14 | *********************************************************/ 15 | #include "Hal_rgb_led/Hal_rgb_led.h" 16 | 17 | void rgbKeyGpioInit(void) 18 | { 19 | GPIO_InitTypeDef GPIO_InitStructure; 20 | RCC_APB2PeriphClockCmd(GPIO_RGB_CLK, ENABLE); 21 | 22 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 23 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; 24 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 25 | GPIO_InitStructure.GPIO_Pin = GPIO_RGB_PIN; 26 | GPIO_Init(GPIO_RGB_PORT, &GPIO_InitStructure); 27 | } 28 | 29 | void ledDelay(unsigned int ms) 30 | { 31 | volatile unsigned int i=0; 32 | for(i=0; i>6; 64 | return tmp; 65 | } 66 | 67 | 68 | /****** send gray data *********/ 69 | void datSend(uint32_t dx) 70 | { 71 | uint8_t i; 72 | 73 | for (i=0; i<32; i++) 74 | { 75 | if ((dx & 0x80000000) != 0) 76 | { 77 | 78 | SDA_HIGH; // SDA=1; 79 | } 80 | else 81 | { 82 | SDA_LOW; // SDA=0; 83 | } 84 | 85 | dx <<= 1; 86 | clkProduce(); 87 | } 88 | } 89 | 90 | /******* data processing ********************/ 91 | void dataDealWithAndSend(uint8_t r, uint8_t g, uint8_t b) 92 | { 93 | uint32_t dx = 0; 94 | 95 | dx |= (uint32_t)0x03 << 30; // The front of the two bits 1 is flag bits 96 | dx |= (uint32_t)takeAntiCode(b) << 28; 97 | dx |= (uint32_t)takeAntiCode(g) << 26; 98 | dx |= (uint32_t)takeAntiCode(r) << 24; 99 | 100 | dx |= (uint32_t)b << 16; 101 | dx |= (uint32_t)g << 8; 102 | dx |= r; 103 | 104 | datSend(dx); 105 | } 106 | 107 | void rgbLedInit(void) 108 | { 109 | 110 | GPIO_InitTypeDef GPIO_InitStruct; 111 | RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOB,ENABLE); 112 | GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP; 113 | GPIO_InitStruct.GPIO_Pin = GPIO_Pin_8|GPIO_Pin_9; 114 | GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz; 115 | GPIO_Init(GPIOB, &GPIO_InitStruct); 116 | send32Zero(); 117 | dataDealWithAndSend(0,0,0); // display red 118 | dataDealWithAndSend(0,0,0); 119 | } 120 | 121 | void ledRgbControl(uint8_t r, uint8_t g, uint8_t b) 122 | { 123 | GPIO_SetBits(GPIO_RGB_PORT,GPIO_RGB_PIN); 124 | send32Zero(); 125 | dataDealWithAndSend(r, g, b); // display red 126 | dataDealWithAndSend(r, g, b); // display red 127 | } 128 | -------------------------------------------------------------------------------- /ISD9160ForOpenHamtaro/NuvotonPlatform_Keil/Include/Driver/DrvDPWM.h: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------*/ 2 | /* */ 3 | /* Copyright(c) 2009 Nuvoton Technology Corp. All rights reserved. */ 4 | /* */ 5 | /*---------------------------------------------------------------------------------------------------------*/ 6 | #ifndef __DRVDPWM_H__ 7 | #define __DRVDPWM_H__ 8 | 9 | 10 | /*---------------------------------------------------------------------------------------------------------*/ 11 | /* Include related headers */ 12 | /*---------------------------------------------------------------------------------------------------------*/ 13 | #include "ISD9xx.h" 14 | #include "System/SysInfra.h" 15 | 16 | /*---------------------------------------------------------------------------------------------------------*/ 17 | /* Macro, type and constant definitions */ 18 | /*---------------------------------------------------------------------------------------------------------*/ 19 | /* version definition with SysInfra */ 20 | #define DRVDPWM_MAJOR_NUM 1 21 | #define DRVDPWM_MINOR_NUM 00 22 | #define DRVDPWM_BUILD_NUM 1 23 | #define DRVDPWM_VERSION_NUM _SYSINFRA_VERSION(DRVDPWM_MAJOR_NUM, DRVDPWM_MINOR_NUM, DRVDPWM_BUILD_NUM) 24 | 25 | /* error code definition */ 26 | #define E_DRVDPWM_ARGUMENT _SYSINFRA_ERRCODE(TRUE, MODULE_ID_DRVDPWM, 1) 27 | 28 | typedef int32_t ERRCODE; 29 | 30 | typedef unsigned char BOOL; 31 | 32 | typedef enum { 33 | eDRVDPWM_FREQ_0, 34 | eDRVDPWM_FREQ_1, 35 | eDRVDPWM_FREQ_2, 36 | eDRVDPWM_FREQ_3, 37 | eDRVDPWM_FREQ_4, 38 | eDRVDPWM_FREQ_5, 39 | eDRVDPWM_FREQ_6, 40 | eDRVDPWM_FREQ_7 41 | }E_DRVDPWM_FREQ; 42 | 43 | typedef enum { 44 | eDRVDPWM_DEADTIME_0FF, 45 | eDRVDPWM_DEADTIME_ON 46 | }E_DRVDPWM_DEADTIME; 47 | 48 | typedef enum { 49 | E_DRVDPWM_DPWMCLK_HCLK, 50 | E_DRVDPWM_DPWMCLK_HCLKX2 51 | }E_DRVDPWM_DPWMCLK; 52 | 53 | typedef enum { 54 | eDRVDPWM_DITHER_NONE=0, 55 | eDRVDPWM_DITHER_ONE=1, 56 | eDRVDPWM_DITHER_TWO=3 57 | }E_DRVDPWM_DITHERTYPE; 58 | 59 | 60 | 61 | 62 | /*---------------------------------------------------------------------------------------------------------*/ 63 | /* Define Function Prototypes */ 64 | /*---------------------------------------------------------------------------------------------------------*/ 65 | void DrvDPWM_Open(void); 66 | void DrvDPWM_Close(void); 67 | void DrvDPWM_AltPins(int32_t Enable); 68 | uint32_t DrvDPWM_SetSampleRate(uint32_t u32SampleRate); 69 | uint32_t DrvDPWM_GetSampleRate(void); 70 | void DrvDPWM_SetDPWMClk(E_DRVDPWM_DPWMCLK eDpwmClk); 71 | void DrvDPWM_SetFrequency(E_DRVDPWM_FREQ eFrequency); 72 | uint32_t DrvDPWM_GetFrequency(void); 73 | void DrvDPWM_SetDeadtime(E_DRVDPWM_DEADTIME eDeadTime); 74 | uint32_t DrvDPWM_GetDeadtime(void); 75 | void DrvDPWM_Dither(E_DRVDPWM_DITHERTYPE eDitherType); 76 | void DrvDPWM_Enable(void); 77 | void DrvDPWM_Disable(void); 78 | BOOL DrvDPWM_IsFIFOFull(void); 79 | BOOL DrvDPWM_IsFIFOEmpty(void); 80 | void DrvDPWM_EnablePDMA(void); 81 | void DrvDPWM_DisablePDMA(void); 82 | int32_t DrvDPWM_WriteFIFO(int32_t *pi32Stream, int32_t i32count); 83 | uint32_t DrvDPWM_GetVersion(void); 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /ISD9160ForOpenHamtaro/NuvotonPlatform_Keil/Include/Lib/LibSiren7.h: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------------------------------------*/ 2 | /* */ 3 | /* Copyright(c) 2011 Nuvoton Technology Corp. All rights reserved. */ 4 | /* */ 5 | /*----------------------------------------------------------------------------------------*/ 6 | #ifndef SIREN7ENDECHDR 7 | #define SIREN7ENDECHDR 8 | 9 | /*---------------------------------------------------------------------------------------------------------*/ 10 | /* Macro, type and constant definitions */ 11 | /*---------------------------------------------------------------------------------------------------------*/ 12 | #ifdef MAX_SAMPLE_RATE 13 | #undef MAX_SAMPLE_RATE 14 | #endif 15 | #define MAX_SAMPLE_RATE 32000 16 | #define MAX_FRAMESIZE (MAX_SAMPLE_RATE/50) 17 | 18 | #ifndef MAX_DCT_LENGTH 19 | #ifndef DCT_LENGTH 20 | #define DCT_LENGTH 320 21 | #endif // DCT_LENGTH 22 | #ifdef SIREN14 23 | #define MAX_DCT_LENGTH 640 24 | #else 25 | #define MAX_DCT_LENGTH DCT_LENGTH 26 | #endif 27 | #endif // MAX_DCT_LENGTH 28 | 29 | #ifndef NUMBER_OF_REGIONS 30 | #define NUMBER_OF_REGIONS 14 31 | #endif 32 | 33 | #ifndef MAX_NUMBER_OF_REGIONS 34 | #ifdef SIREN14 35 | #define MAX_NUMBER_OF_REGIONS 28 36 | #else 37 | #define MAX_NUMBER_OF_REGIONS NUMBER_OF_REGIONS 38 | #endif 39 | #endif 40 | 41 | #pragma pack(4) 42 | 43 | typedef struct tsSiren7_CODEC_CTL 44 | { 45 | signed long bit_rate; 46 | signed short bandwidth; 47 | signed short number_of_bits_per_frame; 48 | signed short number_of_regions; 49 | signed short frame_size; 50 | }sSiren7_CODEC_CTL; 51 | 52 | typedef struct tsSiren7_ENC_CTX 53 | { 54 | signed short history[MAX_FRAMESIZE]; 55 | signed short mlt_coefs[MAX_FRAMESIZE]; // this is not history data 56 | }sSiren7_ENC_CTX; 57 | 58 | #ifndef Rand_Obj_defined 59 | #define Rand_Obj_defined 60 | typedef struct 61 | { 62 | signed short seed0; 63 | signed short seed1; 64 | signed short seed2; 65 | signed short seed3; 66 | }Rand_Obj; 67 | #endif // Rand_Obj_defined 68 | 69 | typedef struct tsSiren7_DEC_CTX 70 | { 71 | signed short old_mag_shift; 72 | #ifndef NO_FRAME_ERROR_CHECK 73 | signed short old_decoder_mlt_coefs[MAX_DCT_LENGTH]; 74 | #endif 75 | signed short old_samples[MAX_DCT_LENGTH>>1]; 76 | Rand_Obj randobj; 77 | signed short decoder_mlt_coefs[MAX_DCT_LENGTH]; // this is not history data 78 | }sSiren7_DEC_CTX; 79 | 80 | #pragma pack() 81 | 82 | /*---------------------------------------------------------------------------------------------------------*/ 83 | /* Define Function Prototypes */ 84 | /*---------------------------------------------------------------------------------------------------------*/ 85 | extern void LibS7EnBufReset(signed short ssFrameSize, sSiren7_ENC_CTX *sS7EncCtx); 86 | 87 | extern void LibS7Encode(const sSiren7_CODEC_CTL *sCctl, sSiren7_ENC_CTX *sS7EncCtx, 88 | signed short *w16InData, signed short *w16OutData); 89 | extern void LibS7DeBufReset(signed short ssFrameSize, sSiren7_DEC_CTX *sS7DecCtx); 90 | extern void LibS7Decode(const sSiren7_CODEC_CTL *sCctl, sSiren7_DEC_CTX *sS7DecCtx, 91 | signed short *w16InData, signed short *w16OutData); 92 | extern void LibS7Init(sSiren7_CODEC_CTL *sCodecCtl, signed long w32BitRate, signed short w16Bandwidth); 93 | 94 | #endif // SIREN7ENDECHDR 95 | -------------------------------------------------------------------------------- /ISD9160ForOpenHamtaro/NuvotonPlatform_Keil/Include/Driver/DrvBODTALARM.H: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------*/ 2 | /* */ 3 | /* Copyright(c) 2011 Nuvoton Technology Corp. All rights reserved. */ 4 | /* */ 5 | /*---------------------------------------------------------------------------------------------------------*/ 6 | #ifndef __DRVBODTALARM_H__ 7 | #define __DRVBODTALARM_H__ 8 | 9 | #include "ISD9xx.h" 10 | 11 | /*---------------------------------------------------------------------------------------------------------*/ 12 | /* Macro, type and constant definitions */ 13 | /*---------------------------------------------------------------------------------------------------------*/ 14 | typedef void (PFN_DRVBODTALARM_CALLBACK)(void); 15 | 16 | #define BODLVL_45V 0x07 17 | #define BODLVL_30V 0x06 18 | #define BODLVL_28V 0x05 19 | #define BODLVL_27V 0x04 20 | #define BODLVL_25V 0x03 21 | #define BODLVL_24V 0x02 22 | #define BODLVL_22V 0x01 23 | #define BODLVL_21V 0x00 24 | 25 | #define TALARM_SEL_145C 0x08 26 | #define TALARM_SEL_135C 0x04 27 | #define TALARM_SEL_125C 0x02 28 | #define TALARM_SEL_115C 0x01 29 | #define TALARM_SEL_105C 0x00 30 | 31 | #define TALARM_EN_ENENABLE 0x01 32 | #define TALARM_EN_ENDISABLE 0x00 33 | #define TALARM_EN_IEENABLE 0x01 34 | #define TALARM_EN_IEDISABLE 0x00 35 | /*---------------------------------------------------------------------------------------------------------*/ 36 | /* Define Version number */ 37 | /*---------------------------------------------------------------------------------------------------------*/ 38 | #define DRVBOD_MAJOR_NUM 1 39 | #define DRVBOD_MINOR_NUM 00 40 | #define DRVBOD_BUILD_NUM 1 41 | 42 | 43 | #define DRVBOD_VERSION_NUM _SYSINFRA_VERSION(DRVBOD_MAJOR_NUM, DRVBOD_MINOR_NUM, DRVBOD_BUILD_NUM) 44 | /*---------------------------------------------------------------------------------------------------------*/ 45 | /* Define Error Code */ 46 | /*---------------------------------------------------------------------------------------------------------*/ 47 | 48 | /*---------------------------------------------------------------------------------------------------------*/ 49 | /* Global interface variables declarations */ 50 | /*---------------------------------------------------------------------------------------------------------*/ 51 | 52 | /*---------------------------------------------------------------------------------------------------------*/ 53 | /* Define Function Prototype */ 54 | /*---------------------------------------------------------------------------------------------------------*/ 55 | void DrvBOD_SelectBODVolt(uint8_t u8Volt); 56 | void DrvBOD_SelectBODHyst(uint8_t u8Hysteresis); 57 | void DrvBOD_EnableBOD(uint32_t u32Enable); 58 | void DrvBOD_SetBODIE(uint32_t u32BODIE); 59 | uint32_t DrvBOD_GetBODout(void); 60 | void DrvBOD_SetTALARMselect(uint32_t u32LVL); 61 | void DrvBOD_EnableTALARM(uint32_t u32Enable); 62 | uint32_t DrvBOD_GetTALARMstatus(void); 63 | void DrvBOD_SetTALARMIE(uint32_t u32TALARMIE); 64 | void DrvBOD_SetDetectionTime(uint32_t u32OnDUR, uint32_t u32OffDUR); 65 | void DrvBOD_InstallISR(PFN_DRVBODTALARM_CALLBACK callback,int32_t i32para); 66 | int32_t DrvBOD_GetVersion(void); 67 | 68 | #endif // __DRVBODTALARM_H__ 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /ISD9160ForOpenHamtaro/NuvotonPlatform_Keil/Include/Driver/DrvALC.H: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------*/ 2 | /* */ 3 | /* Copyright(c) 2011 Nuvoton Technology Corp. All rights reserved. */ 4 | /* */ 5 | /*---------------------------------------------------------------------------------------------------------*/ 6 | #ifndef __DRVALC_H__ 7 | #define __DRVALC_H__ 8 | 9 | #include "ISD9xx.h" 10 | 11 | /*---------------------------------------------------------------------------------------------------------*/ 12 | /* Macro, type and constant definitions */ 13 | /*---------------------------------------------------------------------------------------------------------*/ 14 | typedef void (PFN_DRVALC_CALLBACK)(void); 15 | 16 | 17 | /*---------------------------------------------------------------------------------------------------------*/ 18 | /* Define Version number */ 19 | /*---------------------------------------------------------------------------------------------------------*/ 20 | #define DRVALC_MAJOR_NUM 1 21 | #define DRVALC_MINOR_NUM 00 22 | #define DRVALC_BUILD_NUM 1 23 | 24 | 25 | #define DRVALC_VERSION_NUM _SYSINFRA_VERSION(DRVALC_MAJOR_NUM, DRVALC_MINOR_NUM, DRVALC_BUILD_NUM) 26 | /*---------------------------------------------------------------------------------------------------------*/ 27 | /* Define Error Code */ 28 | /*---------------------------------------------------------------------------------------------------------*/ 29 | 30 | /*---------------------------------------------------------------------------------------------------------*/ 31 | /* Global interface variables declarations */ 32 | /*---------------------------------------------------------------------------------------------------------*/ 33 | #define DrvALC_ENABLE 1 34 | #define DrvALC_DISABLE 0 35 | 36 | #define DRVALC_NORMALMODE 0 37 | #define DRVALC_LIMMODE 1 38 | 39 | #define DRVALC_NGTH_N39dB 7 40 | /*---------------------------------------------------------------------------------------------------------*/ 41 | /* Define Function Prototype */ 42 | /*---------------------------------------------------------------------------------------------------------*/ 43 | void DrvALC_InstallISR(PFN_DRVALC_CALLBACK callback); 44 | void DrvALC_DisableInt(void); 45 | void DrvALC_EnableInt(void); 46 | void DrvALC_EnableNoiseGate(uint8_t u8NGSEL, uint8_t u8NGENval); 47 | uint32_t DrvALC_GetFastDecrement(void); 48 | uint32_t DrvALC_GetNoise(void); 49 | uint32_t DrvALC_GetP2P(void); 50 | uint32_t DrvALC_GetPeak(void); 51 | int32_t DrvALC_GetVersion(void); 52 | void DrvALC_InstallISR(PFN_DRVALC_CALLBACK callback); 53 | void DrvALC_SetALCpeakLimiter(uint8_t u8PKlimiter); 54 | void DrvALC_SetALCselect(uint8_t u8Select); 55 | void DrvALC_SetAttackTime(uint32_t u32ATKstep); 56 | void DrvALC_SetDecayTime(uint32_t u32DCYstep); 57 | void DrvALC_SetHoldTime(uint32_t u32HoldTime); 58 | void DrvALC_SetMaxGain(uint32_t u32MaxGain); 59 | void DrvALC_SetMinGain(uint32_t u32MinGain); 60 | void DrvALC_SetMode(uint8_t u8Mode); 61 | void DrvALC_SetNGEN(uint8_t u8NGEN); 62 | void DrvALC_SetNGTH(uint8_t u8NGTH); 63 | void DrvALC_SetREG(uint32_t u32Value); 64 | void DrvALC_SetTargetLevel(uint32_t u32Level); 65 | void DrvALC_SetZeroCrossing(uint8_t u8ALCZC); 66 | 67 | 68 | #endif // __DRVALC_H__ 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /ISD9160ForOpenHamtaro/NuvotonPlatform_Keil/Include/Driver/DrvPMU.H: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------*/ 2 | /* */ 3 | /* Copyright(c) 2011 Nuvoton Technology Corp. All rights reserved. */ 4 | /* */ 5 | /*---------------------------------------------------------------------------------------------------------*/ 6 | #ifndef __DRVPMU_H__ 7 | #define __DRVPMU_H__ 8 | 9 | #include "ISD9xx.h" 10 | 11 | /* SysTick constants - copied from \Keil\ARM\RV31\INC\core_cm0.h */ 12 | #define SYSTICK_ENABLE 0 /* Config-Bit to start or stop the SysTick Timer */ 13 | #define SYSTICK_TICKINT 1 /* Config-Bit to enable or disable the SysTick interrupt */ 14 | #define SYSTICK_CLKSOURCE 2 /* Clocksource has the offset 2 in SysTick Control and Status Register */ 15 | #define SYSTICK_MAXCOUNT ((1<<24) -1) /* SysTick MaxCount */ 16 | /*--------------------------------------------------------------------------------------------------------- 17 | Macro, type and constant definitions 18 | ---------------------------------------------------------------------------------------------------------*/ 19 | #define DPDWAKEUPMODE_PINOSC10KWAKEUP 0 20 | #define DPDWAKEUPMODE_PINWAKEUP 1 21 | #define DPDWAKEUPMODE_OSC10KWAKEUP 2 22 | #define DPDWAKEUPMODE_ONLYPORWAKEUP 3 23 | 24 | #define DPDWAKETIME_12ms 1 25 | #define DPDWAKETIME_25ms 2 26 | #define DPDWAKETIME_50ms 4 27 | #define DPDWAKETIME_100ms 8 28 | 29 | #define SPDWAKEUPMODE_GPIORTCWAKEUP 0 30 | #define SPDWAKEUPMODE_GPIOWAKEUP 1 31 | #define SPDWAKEUPMODE_OSC10KWAKEUP 2 32 | #define SPDWAKEUPMODE_ONLYPORWAKEUP 3 33 | 34 | #define SCB_SCR_SLEEPDEEP 4 35 | /*---------------------------------------------------------------------------------------------------------*/ 36 | /* Define Version number */ 37 | /*---------------------------------------------------------------------------------------------------------*/ 38 | #define DRVPMU_MAJOR_NUM 1 39 | #define DRVPMU_MINOR_NUM 00 40 | #define DRVPMU_BUILD_NUM 1 41 | 42 | 43 | #define DRVPMU_VERSION_NUM _SYSINFRA_VERSION(DRVPMU_MAJOR_NUM, DRVPMU_MINOR_NUM, DRVPMU_BUILD_NUM) 44 | /*---------------------------------------------------------------------------------------------------------*/ 45 | /* Define Error Code */ 46 | /*---------------------------------------------------------------------------------------------------------*/ 47 | 48 | /*---------------------------------------------------------------------------------------------------------*/ 49 | /* Global interface variables declarations */ 50 | /*---------------------------------------------------------------------------------------------------------*/ 51 | 52 | /*---------------------------------------------------------------------------------------------------------*/ 53 | /* Define Function Prototype */ 54 | /*---------------------------------------------------------------------------------------------------------*/ 55 | extern void DrvPMU_DeepPowerDown(uint32_t u32DPDWakeupMode, uint32_t u32TimerSel); 56 | extern void DrvPMU_StandbyPowerDown(void); 57 | extern void DrvPMU_Stop(void); 58 | extern void DrvPMU_DeepSleep(void); 59 | 60 | #endif // __DRVPMU_H__ 61 | 62 | -------------------------------------------------------------------------------- /GoKit3ForOpenHamtaro/Lib/STM32F10x_StdPeriph_Driver/src/stm32f10x_crc.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_crc.c 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief This file provides all the CRC firmware functions. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2011 STMicroelectronics

19 | ****************************************************************************** 20 | */ 21 | 22 | /* Includes ------------------------------------------------------------------*/ 23 | #include "stm32f10x_crc.h" 24 | 25 | /** @addtogroup STM32F10x_StdPeriph_Driver 26 | * @{ 27 | */ 28 | 29 | /** @defgroup CRC 30 | * @brief CRC driver modules 31 | * @{ 32 | */ 33 | 34 | /** @defgroup CRC_Private_TypesDefinitions 35 | * @{ 36 | */ 37 | 38 | /** 39 | * @} 40 | */ 41 | 42 | /** @defgroup CRC_Private_Defines 43 | * @{ 44 | */ 45 | 46 | /** 47 | * @} 48 | */ 49 | 50 | /** @defgroup CRC_Private_Macros 51 | * @{ 52 | */ 53 | 54 | /** 55 | * @} 56 | */ 57 | 58 | /** @defgroup CRC_Private_Variables 59 | * @{ 60 | */ 61 | 62 | /** 63 | * @} 64 | */ 65 | 66 | /** @defgroup CRC_Private_FunctionPrototypes 67 | * @{ 68 | */ 69 | 70 | /** 71 | * @} 72 | */ 73 | 74 | /** @defgroup CRC_Private_Functions 75 | * @{ 76 | */ 77 | 78 | /** 79 | * @brief Resets the CRC Data register (DR). 80 | * @param None 81 | * @retval None 82 | */ 83 | void CRC_ResetDR(void) 84 | { 85 | /* Reset CRC generator */ 86 | CRC->CR = CRC_CR_RESET; 87 | } 88 | 89 | /** 90 | * @brief Computes the 32-bit CRC of a given data word(32-bit). 91 | * @param Data: data word(32-bit) to compute its CRC 92 | * @retval 32-bit CRC 93 | */ 94 | uint32_t CRC_CalcCRC(uint32_t Data) 95 | { 96 | CRC->DR = Data; 97 | 98 | return (CRC->DR); 99 | } 100 | 101 | /** 102 | * @brief Computes the 32-bit CRC of a given buffer of data word(32-bit). 103 | * @param pBuffer: pointer to the buffer containing the data to be computed 104 | * @param BufferLength: length of the buffer to be computed 105 | * @retval 32-bit CRC 106 | */ 107 | uint32_t CRC_CalcBlockCRC(uint32_t pBuffer[], uint32_t BufferLength) 108 | { 109 | uint32_t index = 0; 110 | 111 | for(index = 0; index < BufferLength; index++) 112 | { 113 | CRC->DR = pBuffer[index]; 114 | } 115 | return (CRC->DR); 116 | } 117 | 118 | /** 119 | * @brief Returns the current CRC value. 120 | * @param None 121 | * @retval 32-bit CRC 122 | */ 123 | uint32_t CRC_GetCRC(void) 124 | { 125 | return (CRC->DR); 126 | } 127 | 128 | /** 129 | * @brief Stores a 8-bit data in the Independent Data(ID) register. 130 | * @param IDValue: 8-bit value to be stored in the ID register 131 | * @retval None 132 | */ 133 | void CRC_SetIDRegister(uint8_t IDValue) 134 | { 135 | CRC->IDR = IDValue; 136 | } 137 | 138 | /** 139 | * @brief Returns the 8-bit data stored in the Independent Data(ID) register 140 | * @param None 141 | * @retval 8-bit value of the ID register 142 | */ 143 | uint8_t CRC_GetIDRegister(void) 144 | { 145 | return (CRC->IDR); 146 | } 147 | 148 | /** 149 | * @} 150 | */ 151 | 152 | /** 153 | * @} 154 | */ 155 | 156 | /** 157 | * @} 158 | */ 159 | 160 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 161 | -------------------------------------------------------------------------------- /GoKit3ForOpenHamtaro/Lib/STM32F10x_StdPeriph_Driver/inc/stm32f10x_dbgmcu.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_dbgmcu.h 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief This file contains all the functions prototypes for the DBGMCU 8 | * firmware library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 13 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 14 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 15 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 16 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 17 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 18 | * 19 | *

© COPYRIGHT 2011 STMicroelectronics

20 | ****************************************************************************** 21 | */ 22 | 23 | /* Define to prevent recursive inclusion -------------------------------------*/ 24 | #ifndef __STM32F10x_DBGMCU_H 25 | #define __STM32F10x_DBGMCU_H 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | /* Includes ------------------------------------------------------------------*/ 32 | #include "stm32f10x.h" 33 | 34 | /** @addtogroup STM32F10x_StdPeriph_Driver 35 | * @{ 36 | */ 37 | 38 | /** @addtogroup DBGMCU 39 | * @{ 40 | */ 41 | 42 | /** @defgroup DBGMCU_Exported_Types 43 | * @{ 44 | */ 45 | 46 | /** 47 | * @} 48 | */ 49 | 50 | /** @defgroup DBGMCU_Exported_Constants 51 | * @{ 52 | */ 53 | 54 | #define DBGMCU_SLEEP ((uint32_t)0x00000001) 55 | #define DBGMCU_STOP ((uint32_t)0x00000002) 56 | #define DBGMCU_STANDBY ((uint32_t)0x00000004) 57 | #define DBGMCU_IWDG_STOP ((uint32_t)0x00000100) 58 | #define DBGMCU_WWDG_STOP ((uint32_t)0x00000200) 59 | #define DBGMCU_TIM1_STOP ((uint32_t)0x00000400) 60 | #define DBGMCU_TIM2_STOP ((uint32_t)0x00000800) 61 | #define DBGMCU_TIM3_STOP ((uint32_t)0x00001000) 62 | #define DBGMCU_TIM4_STOP ((uint32_t)0x00002000) 63 | #define DBGMCU_CAN1_STOP ((uint32_t)0x00004000) 64 | #define DBGMCU_I2C1_SMBUS_TIMEOUT ((uint32_t)0x00008000) 65 | #define DBGMCU_I2C2_SMBUS_TIMEOUT ((uint32_t)0x00010000) 66 | #define DBGMCU_TIM8_STOP ((uint32_t)0x00020000) 67 | #define DBGMCU_TIM5_STOP ((uint32_t)0x00040000) 68 | #define DBGMCU_TIM6_STOP ((uint32_t)0x00080000) 69 | #define DBGMCU_TIM7_STOP ((uint32_t)0x00100000) 70 | #define DBGMCU_CAN2_STOP ((uint32_t)0x00200000) 71 | #define DBGMCU_TIM15_STOP ((uint32_t)0x00400000) 72 | #define DBGMCU_TIM16_STOP ((uint32_t)0x00800000) 73 | #define DBGMCU_TIM17_STOP ((uint32_t)0x01000000) 74 | #define DBGMCU_TIM12_STOP ((uint32_t)0x02000000) 75 | #define DBGMCU_TIM13_STOP ((uint32_t)0x04000000) 76 | #define DBGMCU_TIM14_STOP ((uint32_t)0x08000000) 77 | #define DBGMCU_TIM9_STOP ((uint32_t)0x10000000) 78 | #define DBGMCU_TIM10_STOP ((uint32_t)0x20000000) 79 | #define DBGMCU_TIM11_STOP ((uint32_t)0x40000000) 80 | 81 | #define IS_DBGMCU_PERIPH(PERIPH) ((((PERIPH) & 0x800000F8) == 0x00) && ((PERIPH) != 0x00)) 82 | /** 83 | * @} 84 | */ 85 | 86 | /** @defgroup DBGMCU_Exported_Macros 87 | * @{ 88 | */ 89 | 90 | /** 91 | * @} 92 | */ 93 | 94 | /** @defgroup DBGMCU_Exported_Functions 95 | * @{ 96 | */ 97 | 98 | uint32_t DBGMCU_GetREVID(void); 99 | uint32_t DBGMCU_GetDEVID(void); 100 | void DBGMCU_Config(uint32_t DBGMCU_Periph, FunctionalState NewState); 101 | 102 | #ifdef __cplusplus 103 | } 104 | #endif 105 | 106 | #endif /* __STM32F10x_DBGMCU_H */ 107 | /** 108 | * @} 109 | */ 110 | 111 | /** 112 | * @} 113 | */ 114 | 115 | /** 116 | * @} 117 | */ 118 | 119 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 120 | -------------------------------------------------------------------------------- /ISD9160ForOpenHamtaro/NuvotonPlatform_Keil/Include/System/SysInfra.h: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------*/ 2 | /* */ 3 | /* Copyright (c) Nuvoton Technology Corp. All rights reserved. */ 4 | /* */ 5 | /*---------------------------------------------------------------------------------------------------------*/ 6 | 7 | 8 | #ifndef __SYSINFRA_H__ 9 | #define __SYSINFRA_H__ 10 | 11 | /*---------------------------------------------------------------------------------------------------------*/ 12 | /* Includes of system headers */ 13 | /*---------------------------------------------------------------------------------------------------------*/ 14 | #include "ModuleID.h" 15 | #include "stdint.h" 16 | #include "core_cm0.h" 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | 23 | /*---------------------------------------------------------------------------------------------------------*/ 24 | /* Define Version number */ 25 | /*---------------------------------------------------------------------------------------------------------*/ 26 | 27 | #define SYSINFRA_MAJOR_NUM 1 28 | #define SYSINFRA_MINOR_NUM 00 29 | #define SYSINFRA_BUILD_NUM 1 30 | 31 | /*---------------------------------------------------------------------------------------------------------*/ 32 | /* Macro, type and constant definitions */ 33 | /*---------------------------------------------------------------------------------------------------------*/ 34 | /* Define an error code composed of error bit, module ID, and error ID. */ 35 | #define _SYSINFRA_ERRCODE(IS_ERROR, MODULE_ID_VALUE, ERROR_ID) (((IS_ERROR) ? 0xFFFF0000 : 0x00000000) | ((((MODULE_ID_VALUE) & 0xFF) | ((IS_ERROR) ? 0x100 : 0x00)) << 7) | ((ERROR_ID) & 0x7F)) 36 | #define _SYSINFRA_ERRCODE_DEF(MODULE_ID, ERROR_NAME, IS_ERROR, MODULE_ID_VALUE, ERROR_ID) enum {E_##MODULE_ID##_##ERROR_NAME = ((IS_ERROR) ? 0xFFFF0000 : 0x00000000) | ((((MODULE_ID_VALUE) & 0xFF) | ((IS_ERROR) ? 0x100 : 0x00)) << 7) | ((ERROR_ID) & 0x7F)}; 37 | 38 | /* Define a module version composed of major number, minor number, and build number. */ 39 | #define _SYSINFRA_VERSION(MAJOR_NUM, MINOR_NUM, BUILD_NUM) (((MAJOR_NUM) << 16) | ((MINOR_NUM) << 8) | (BUILD_NUM)) 40 | #define _SYSINFRA_VERSION_DEF(MODULE_ID, MAJOR_NUM, MINOR_NUM, BUILD_NUM) enum {MODULE_ID##_VERSION_NUM = ((MAJOR_NUM) << 16) | ((MINOR_NUM) << 8) | (BUILD_NUM)}; 41 | 42 | /* Test if this error code means an error by seeing its error bit (BIT31). */ 43 | #define _SYSINFRA_ERRCODE_IS_ERROR(ERROR_CODE) ((ERROR_CODE) < 0) 44 | /* Extract module ID part of this error code. */ 45 | #define _SYSINFRA_ERRCODE_EXTRACT_MODULE_ID(ERROR_CODE) (((ERROR_CODE) >> 7) & 0xFF) 46 | /* Extract error ID part of this error code. */ 47 | #define _SYSINFRA_ERRCODE_EXTRACT_ERROR_ID(ERROR_CODE) ((ERROR_CODE) & 0x7F) 48 | 49 | /* Define module version number.*/ 50 | #define SYSINFRA_VERSION_NUM _SYSINFRA_VERSION(SYSINFRA_MAJOR_NUM, SYSINFRA_MINOR_NUM, SYSINFRA_BUILD_NUM) 51 | 52 | #define E_SUCCESS 0 53 | #define S_OK E_SUCCESS 54 | 55 | 56 | /*---------------------------------------------------------------------------------------------------------*/ 57 | /* Define Error Code */ 58 | /*---------------------------------------------------------------------------------------------------------*/ 59 | /* #define Error Code */ 60 | //E_SYSINFRA_NOT_DEFINE Un-defined error code 61 | //E_SYSINFRA_NULL_POINTER A NULL pointer is passed as an argument 62 | //E_SYSINFRA_BUFFER_OVERRUN Buffer size is not enough 63 | 64 | #define E_SYSINFRA_NOT_DEFINE _SYSINFRA_ERRCODE(TRUE, MODULE_ID_SYSINFRA, 0) 65 | #define E_SYSINFRA_NULL_POINTER _SYSINFRA_ERRCODE(TRUE, MODULE_ID_SYSINFRA, 1) 66 | #define E_SYSINFRA_BUFFER_OVERRUN _SYSINFRA_ERRCODE(TRUE, MODULE_ID_SYSINFRA, 2) 67 | 68 | #ifdef __cplusplus 69 | } 70 | #endif 71 | 72 | #endif // __SYSINFRA_H__ 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /ISD9160ForOpenHamtaro/NuvotonPlatform_Keil/Sample/CSpotter_OpenHamtaro/CSpotterSDKApi.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __CSPOTTERSDK_API_H 3 | #define __CSPOTTERSDK_API_H 4 | 5 | #if defined(_WIN32) 6 | #ifdef CSpotterDll_EXPORTS 7 | #define CSPDLL_API __declspec(dllexport) 8 | #endif 9 | #endif 10 | 11 | #ifndef CSPDLL_API 12 | #define CSPDLL_API 13 | #endif 14 | 15 | #include "base_types.h" 16 | #include "CSpotterSDKApi_Const.h" 17 | 18 | #ifdef __cplusplus 19 | extern "C"{ 20 | #endif 21 | 22 | // Purpose: Create a recognizer 23 | // lpbyModel(IN): the VR model 24 | // lpbyMemPool(IN/OUT): memory buffer for recognizer 25 | // nMemSize(IN): memory buffer size 26 | // pnErr(OUT): CSPOTTER_SUCCESS indicates success, else error code. it can be NULL. 27 | // Return: a recognizer handle or NULL 28 | CSPDLL_API HANDLE CSpotter_Init(BYTE *lpbyModel, BYTE *lpbyMemPool, INT nMemSize, INT *pnErr); 29 | 30 | // lpbyBaseModel(IN): the base VR model 31 | // lppbyModel(IN): the VR model 32 | // lpbyMemPool(IN/OUT): memory buffer for recognizer 33 | // nMemSize(IN): memory buffer size 34 | // pnErr(OUT): CSPOTTER_SUCCESS indicates success, else error code. it can be NULL. 35 | // Return: a recognizer handle or NULL 36 | CSPDLL_API HANDLE CSpotter_Init_Sep(BYTE *lpbyBaseModel, BYTE *lpbyModel, BYTE *lpbyMemPool, INT nMemSize, INT *pnErr); 37 | CSPDLL_API HANDLE CSpotter_Init_Multi(BYTE *lpbyBaseModel, BYTE *lppbyModel[], INT nNumModel, BYTE *lpbyMemPool, INT nMemSize, INT *pnErr); 38 | 39 | // Purpose: Destroy a recognizer (free resources) 40 | // hCSpotter(IN): a handle of the recognizer 41 | // Return: Success or error code 42 | CSPDLL_API INT CSpotter_Release(HANDLE hCSpotter); 43 | 44 | // Purpose: Reset recognizer 45 | // hCSpotter(IN): a handle of the recognizer 46 | // Return: Success or error code 47 | CSPDLL_API INT CSpotter_Reset(HANDLE hCSpotter); 48 | 49 | // Purpose: Transfer voice samples to the recognizer for recognizing. 50 | // hCSpotter(IN): a handle of the recognizer 51 | // lpsSample(IN): the pointer of voice data buffer 52 | // nNumSample(IN): the number of voice data (a unit is a short, we prefer to add 160 samples per call) 53 | // Return: "CSPOTTER_ERR_NeedMoreSample" indicates call this function again, else call CSpotter_GetResult(...) 54 | CSPDLL_API INT CSpotter_AddSample(HANDLE hCSpotter, SHORT *lpsSample, INT nNumSample); 55 | 56 | // Purpose: Get recognition results. 57 | // hCSpotter(IN): a handle of the recognizer 58 | // Return: the command ID. It is 0 based 59 | CSPDLL_API INT CSpotter_GetResult(HANDLE hCSpotter); 60 | CSPDLL_API INT CSpotter_GetResultEPD(HANDLE hCSpotter, INT *pnWordDura, INT *pnEndDelay); 61 | 62 | CSPDLL_API INT CSpotter_GetNumWord(BYTE *lpbyModel); 63 | 64 | CSPDLL_API INT CSpotter_GetMemoryUsage(BYTE *lpbyModel); 65 | CSPDLL_API INT CSpotter_GetMemoryUsage_Sep(BYTE *lpbyBaseModel, BYTE *lpbyModel); 66 | CSPDLL_API INT CSpotter_GetMemoryUsage_Multi(BYTE *lpbyBaseModel, BYTE *lppbyModel[], INT nNumModel); 67 | 68 | /************************************************************************/ 69 | // Threshold Adjust API 70 | /************************************************************************/ 71 | // Purpose: Set model rejection level 72 | // hCSpotter(IN): a handle of the recognizer 73 | // nRejectionLevel(IN): rejection level 74 | // Return: Success or error code 75 | CSPDLL_API INT CSpotter_SetRejectionLevel(HANDLE hCSpotter, INT nRejectionLevel); 76 | 77 | // Purpose: Set engine response time 78 | // hCSpotter(IN): a handle of the recognizer 79 | // nResponseTime(IN): response time 80 | // Return: Success or error code 81 | CSPDLL_API INT CSpotter_SetResponseTime(HANDLE hCSpotter, INT nResponseTime); 82 | 83 | // Purpose: Set Cmd reward 84 | // hCSpotter(IN): a handle of the recognizer 85 | // nCmdIdx(IN): the command ID. It is 0 based 86 | // nReward(IN): the reward 87 | // Return: Success or error code 88 | CSPDLL_API INT CSpotter_SetCmdReward(HANDLE hCSpotter, INT nCmdIdx, INT nReward); 89 | 90 | // Purpose: Set Cmd response reward 91 | // hCSpotter(IN): a handle of the recognizer 92 | // nCmdIdx(IN): the command ID. It is 0 based 93 | // nReward(IN): the reward 94 | // Return: Success or error code 95 | CSPDLL_API INT CSpotter_SetCmdResponseReward(HANDLE hCSpotter, INT nCmdIdx, INT nReward); 96 | 97 | #ifdef __cplusplus 98 | } 99 | #endif 100 | 101 | #endif // __CSPOTTERSDK_API_H 102 | -------------------------------------------------------------------------------- /GoKit3ForOpenHamtaro/Lib/STM32F10x_StdPeriph_Driver/inc/stm32f10x_iwdg.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_iwdg.h 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief This file contains all the functions prototypes for the IWDG 8 | * firmware library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 13 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 14 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 15 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 16 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 17 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 18 | * 19 | *

© COPYRIGHT 2011 STMicroelectronics

20 | ****************************************************************************** 21 | */ 22 | 23 | /* Define to prevent recursive inclusion -------------------------------------*/ 24 | #ifndef __STM32F10x_IWDG_H 25 | #define __STM32F10x_IWDG_H 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | /* Includes ------------------------------------------------------------------*/ 32 | #include "stm32f10x.h" 33 | 34 | /** @addtogroup STM32F10x_StdPeriph_Driver 35 | * @{ 36 | */ 37 | 38 | /** @addtogroup IWDG 39 | * @{ 40 | */ 41 | 42 | /** @defgroup IWDG_Exported_Types 43 | * @{ 44 | */ 45 | 46 | /** 47 | * @} 48 | */ 49 | 50 | /** @defgroup IWDG_Exported_Constants 51 | * @{ 52 | */ 53 | 54 | /** @defgroup IWDG_WriteAccess 55 | * @{ 56 | */ 57 | 58 | #define IWDG_WriteAccess_Enable ((uint16_t)0x5555) 59 | #define IWDG_WriteAccess_Disable ((uint16_t)0x0000) 60 | #define IS_IWDG_WRITE_ACCESS(ACCESS) (((ACCESS) == IWDG_WriteAccess_Enable) || \ 61 | ((ACCESS) == IWDG_WriteAccess_Disable)) 62 | /** 63 | * @} 64 | */ 65 | 66 | /** @defgroup IWDG_prescaler 67 | * @{ 68 | */ 69 | 70 | #define IWDG_Prescaler_4 ((uint8_t)0x00) 71 | #define IWDG_Prescaler_8 ((uint8_t)0x01) 72 | #define IWDG_Prescaler_16 ((uint8_t)0x02) 73 | #define IWDG_Prescaler_32 ((uint8_t)0x03) 74 | #define IWDG_Prescaler_64 ((uint8_t)0x04) 75 | #define IWDG_Prescaler_128 ((uint8_t)0x05) 76 | #define IWDG_Prescaler_256 ((uint8_t)0x06) 77 | #define IS_IWDG_PRESCALER(PRESCALER) (((PRESCALER) == IWDG_Prescaler_4) || \ 78 | ((PRESCALER) == IWDG_Prescaler_8) || \ 79 | ((PRESCALER) == IWDG_Prescaler_16) || \ 80 | ((PRESCALER) == IWDG_Prescaler_32) || \ 81 | ((PRESCALER) == IWDG_Prescaler_64) || \ 82 | ((PRESCALER) == IWDG_Prescaler_128)|| \ 83 | ((PRESCALER) == IWDG_Prescaler_256)) 84 | /** 85 | * @} 86 | */ 87 | 88 | /** @defgroup IWDG_Flag 89 | * @{ 90 | */ 91 | 92 | #define IWDG_FLAG_PVU ((uint16_t)0x0001) 93 | #define IWDG_FLAG_RVU ((uint16_t)0x0002) 94 | #define IS_IWDG_FLAG(FLAG) (((FLAG) == IWDG_FLAG_PVU) || ((FLAG) == IWDG_FLAG_RVU)) 95 | #define IS_IWDG_RELOAD(RELOAD) ((RELOAD) <= 0xFFF) 96 | /** 97 | * @} 98 | */ 99 | 100 | /** 101 | * @} 102 | */ 103 | 104 | /** @defgroup IWDG_Exported_Macros 105 | * @{ 106 | */ 107 | 108 | /** 109 | * @} 110 | */ 111 | 112 | /** @defgroup IWDG_Exported_Functions 113 | * @{ 114 | */ 115 | 116 | void IWDG_WriteAccessCmd(uint16_t IWDG_WriteAccess); 117 | void IWDG_SetPrescaler(uint8_t IWDG_Prescaler); 118 | void IWDG_SetReload(uint16_t Reload); 119 | void IWDG_ReloadCounter(void); 120 | void IWDG_Enable(void); 121 | FlagStatus IWDG_GetFlagStatus(uint16_t IWDG_FLAG); 122 | 123 | #ifdef __cplusplus 124 | } 125 | #endif 126 | 127 | #endif /* __STM32F10x_IWDG_H */ 128 | /** 129 | * @} 130 | */ 131 | 132 | /** 133 | * @} 134 | */ 135 | 136 | /** 137 | * @} 138 | */ 139 | 140 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 141 | -------------------------------------------------------------------------------- /GoKit3ForOpenHamtaro/Lib/STM32F10x_StdPeriph_Driver/inc/stm32f10x_rtc.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_rtc.h 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief This file contains all the functions prototypes for the RTC firmware 8 | * library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 13 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 14 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 15 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 16 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 17 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 18 | * 19 | *

© COPYRIGHT 2011 STMicroelectronics

20 | ****************************************************************************** 21 | */ 22 | 23 | /* Define to prevent recursive inclusion -------------------------------------*/ 24 | #ifndef __STM32F10x_RTC_H 25 | #define __STM32F10x_RTC_H 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | /* Includes ------------------------------------------------------------------*/ 32 | #include "stm32f10x.h" 33 | 34 | /** @addtogroup STM32F10x_StdPeriph_Driver 35 | * @{ 36 | */ 37 | 38 | /** @addtogroup RTC 39 | * @{ 40 | */ 41 | 42 | /** @defgroup RTC_Exported_Types 43 | * @{ 44 | */ 45 | 46 | /** 47 | * @} 48 | */ 49 | 50 | /** @defgroup RTC_Exported_Constants 51 | * @{ 52 | */ 53 | 54 | /** @defgroup RTC_interrupts_define 55 | * @{ 56 | */ 57 | 58 | #define RTC_IT_OW ((uint16_t)0x0004) /*!< Overflow interrupt */ 59 | #define RTC_IT_ALR ((uint16_t)0x0002) /*!< Alarm interrupt */ 60 | #define RTC_IT_SEC ((uint16_t)0x0001) /*!< Second interrupt */ 61 | #define IS_RTC_IT(IT) ((((IT) & (uint16_t)0xFFF8) == 0x00) && ((IT) != 0x00)) 62 | #define IS_RTC_GET_IT(IT) (((IT) == RTC_IT_OW) || ((IT) == RTC_IT_ALR) || \ 63 | ((IT) == RTC_IT_SEC)) 64 | /** 65 | * @} 66 | */ 67 | 68 | /** @defgroup RTC_interrupts_flags 69 | * @{ 70 | */ 71 | 72 | #define RTC_FLAG_RTOFF ((uint16_t)0x0020) /*!< RTC Operation OFF flag */ 73 | #define RTC_FLAG_RSF ((uint16_t)0x0008) /*!< Registers Synchronized flag */ 74 | #define RTC_FLAG_OW ((uint16_t)0x0004) /*!< Overflow flag */ 75 | #define RTC_FLAG_ALR ((uint16_t)0x0002) /*!< Alarm flag */ 76 | #define RTC_FLAG_SEC ((uint16_t)0x0001) /*!< Second flag */ 77 | #define IS_RTC_CLEAR_FLAG(FLAG) ((((FLAG) & (uint16_t)0xFFF0) == 0x00) && ((FLAG) != 0x00)) 78 | #define IS_RTC_GET_FLAG(FLAG) (((FLAG) == RTC_FLAG_RTOFF) || ((FLAG) == RTC_FLAG_RSF) || \ 79 | ((FLAG) == RTC_FLAG_OW) || ((FLAG) == RTC_FLAG_ALR) || \ 80 | ((FLAG) == RTC_FLAG_SEC)) 81 | #define IS_RTC_PRESCALER(PRESCALER) ((PRESCALER) <= 0xFFFFF) 82 | 83 | /** 84 | * @} 85 | */ 86 | 87 | /** 88 | * @} 89 | */ 90 | 91 | /** @defgroup RTC_Exported_Macros 92 | * @{ 93 | */ 94 | 95 | /** 96 | * @} 97 | */ 98 | 99 | /** @defgroup RTC_Exported_Functions 100 | * @{ 101 | */ 102 | 103 | void RTC_ITConfig(uint16_t RTC_IT, FunctionalState NewState); 104 | void RTC_EnterConfigMode(void); 105 | void RTC_ExitConfigMode(void); 106 | uint32_t RTC_GetCounter(void); 107 | void RTC_SetCounter(uint32_t CounterValue); 108 | void RTC_SetPrescaler(uint32_t PrescalerValue); 109 | void RTC_SetAlarm(uint32_t AlarmValue); 110 | uint32_t RTC_GetDivider(void); 111 | void RTC_WaitForLastTask(void); 112 | void RTC_WaitForSynchro(void); 113 | FlagStatus RTC_GetFlagStatus(uint16_t RTC_FLAG); 114 | void RTC_ClearFlag(uint16_t RTC_FLAG); 115 | ITStatus RTC_GetITStatus(uint16_t RTC_IT); 116 | void RTC_ClearITPendingBit(uint16_t RTC_IT); 117 | 118 | #ifdef __cplusplus 119 | } 120 | #endif 121 | 122 | #endif /* __STM32F10x_RTC_H */ 123 | /** 124 | * @} 125 | */ 126 | 127 | /** 128 | * @} 129 | */ 130 | 131 | /** 132 | * @} 133 | */ 134 | 135 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 136 | -------------------------------------------------------------------------------- /GoKit3ForOpenHamtaro/Hal/hal_motor/hal_motor.c: -------------------------------------------------------------------------------- 1 | /** 2 | ******************************************************** 3 | * 4 | * @file Hal_motor.c 5 | * @author Gizwtis 6 | * @version V03010100 7 | * @date 2016-07-05 8 | * 9 | * @brief 机智云.只为智能硬件而生 10 | * Gizwits Smart Cloud for Smart Products 11 | * 链接|增值ֵ|开放|中立|安全|自有|自由|生态 12 | * www.gizwits.com 13 | * 14 | *********************************************************/ 15 | #include 16 | #include "Hal_motor/Hal_motor.h" 17 | 18 | 19 | /******************************************************************************* 20 | * Function Name : tim3GpioConfig 21 | * Description : 配置TIM3复用输出PWM的IO 22 | * Input : 无 23 | * Output : None 24 | * Return : None 25 | * Attention : None 26 | *******************************************************************************/ 27 | void tim3GpioConfig(void) 28 | { 29 | GPIO_InitTypeDef GPIO_InitStructure; 30 | 31 | /* GPIOA and GPIOB clock enable */ 32 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB | RCC_APB2Periph_AFIO, ENABLE); 33 | RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3 , ENABLE); 34 | 35 | GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable,ENABLE); 36 | GPIO_PinRemapConfig(GPIO_PartialRemap_TIM3,ENABLE); 37 | 38 | /*GPIOB Configuration: TIM3 channel 3 and 4 as alternate function push-pull */ 39 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_5; 40 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; // 复用推挽输出 41 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 42 | GPIO_Init(GPIOB, &GPIO_InitStructure); 43 | } 44 | 45 | /******************************************************************************* 46 | * Function Name : tim3ModeConfig 47 | * Description : 配置TIM3输出时的PWM信号的模式,如周期、极性、占空比 48 | * Input : 无 49 | * Output : None 50 | * Return : None 51 | * Attention : None 52 | *******************************************************************************/ 53 | 54 | void tim3ModeConfig(void) 55 | { 56 | // TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; 57 | TIM_OCInitTypeDef TIM_OCInitStructure; 58 | 59 | /* PWM信号电平跳变值 */ 60 | u16 ccr1Val = 500; 61 | u16 ccr2Val = 500; 62 | 63 | /* ----------------------------------------------------------------------- 64 | TIM3 Configuration: generate 4 PWM signals with 4 different duty cycles: 65 | TIM3CLK = 72 MHz, Prescaler = 0x0, TIM3 counter clock = 72 MHz 66 | TIM3 ARR Register = 999 => TIM3 Frequency = TIM3 counter clock/(ARR + 1) 67 | TIM3 Frequency = 72 KHz. 68 | TIM3 Channel1 duty cycle = (TIM3_CCR1/ TIM3_ARR)* 100 = 50% 69 | TIM3 Channel2 duty cycle = (TIM3_CCR2/ TIM3_ARR)* 100 = 37.5% 70 | TIM3 Channel3 duty cycle = (TIM3_CCR3/ TIM3_ARR)* 100 = 25% 71 | TIM3 Channel4 duty cycle = (TIM3_CCR4/ TIM3_ARR)* 100 = 12.5% 72 | ----------------------------------------------------------------------- */ 73 | 74 | // TIM_TimeBaseInit(TIM3, &TIM_TimeBaseStructure); 75 | TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1; //配置PWM模式1 76 | TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable; 77 | TIM_OCInitStructure.TIM_Pulse = ccr1Val; //设置跳变值,当计数器计数到这个值时,电平发生跳变 78 | TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High; //当计数器计数值小于ccr1Val时为高电平 79 | TIM_OC1Init(TIM3, &TIM_OCInitStructure); //使能通道1 80 | TIM_OC1PreloadConfig(TIM3, TIM_OCPreload_Enable); 81 | 82 | /* PWM1 Mode configuration: Channel2 */ 83 | TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable; 84 | TIM_OCInitStructure.TIM_Pulse = ccr2Val; //设置通道2的电平跳变值,输出另外一个占空比的PWM 85 | TIM_OC2Init(TIM3, &TIM_OCInitStructure); //使能通道2 86 | TIM_OC2PreloadConfig(TIM3, TIM_OCPreload_Enable); 87 | 88 | /* TIM3 enable counter */ 89 | TIM_Cmd(TIM3, ENABLE); //使能定时器3 90 | } 91 | 92 | void motorInit(void) 93 | { 94 | tim3GpioConfig(); 95 | tim3ModeConfig(); 96 | motorStatus(0); 97 | } 98 | 99 | // 7199 100 100 | // x M 101 | void motorControl(uint8_t m1,uint8_t m2) 102 | { 103 | u16 temp = 7200/100;//(MOTOR_ARR+1) / MOTOR_MAX; 104 | 105 | TIM_SetCompare1(TIM3,m1*temp); //m1 106 | TIM_SetCompare2(TIM3,m2*temp); //m4 107 | 108 | } 109 | 110 | void motorStatus(motor_t status) 111 | { 112 | if(0 == status) 113 | { 114 | motorControl(0,0); 115 | } 116 | else 117 | { 118 | if(status > 0) 119 | { 120 | motorControl((abs(status)+5)*10, 0); 121 | } 122 | else 123 | { 124 | motorControl(0, (abs(status)+5)*10); 125 | } 126 | } 127 | } 128 | 129 | 130 | -------------------------------------------------------------------------------- /GoKit3ForOpenHamtaro/Dal/dal_rb.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "dal_rb.h" 5 | #include "gizwits_protocol.h" 6 | 7 | 8 | #define min(a, b) (a)<(b)?(a):(b) 9 | 10 | 11 | void DalRbCreate(dal_rb_t* rb) 12 | { 13 | if(NULL == rb) 14 | { 15 | #if EN_DEBUG > 0 16 | GIZWITS_LOG("ERROR: input rb is NULL\r\n"); 17 | #endif 18 | return; 19 | } 20 | 21 | rb->rbHead = rb->rbBuff; 22 | rb->rbTail = rb->rbBuff; 23 | } 24 | 25 | void DalRbDelete(dal_rb_t* rb) 26 | { 27 | if(NULL == rb) 28 | { 29 | #if EN_DEBUG > 0 30 | GIZWITS_LOG("ERROR: input rb is NULL\r\n"); 31 | #endif 32 | return; 33 | } 34 | 35 | rb->rbBuff = NULL; 36 | rb->rbHead = NULL; 37 | rb->rbTail = NULL; 38 | rb->rbCapacity = 0; 39 | } 40 | 41 | size_t DalRbCapacity(dal_rb_t *rb) 42 | { 43 | if(NULL == rb) 44 | { 45 | #if EN_DEBUG > 0 46 | GIZWITS_LOG("ERROR: input rb is NULL\r\n"); 47 | #endif 48 | return -1; 49 | } 50 | 51 | return rb->rbCapacity; 52 | } 53 | 54 | size_t DalRbCanRead(dal_rb_t *rb) 55 | { 56 | if(NULL == rb) 57 | { 58 | #if EN_DEBUG > 0 59 | GIZWITS_LOG("ERROR: input rb is NULL\r\n"); 60 | #endif 61 | return -1; 62 | } 63 | 64 | if (rb->rbHead == rb->rbTail) 65 | { 66 | return 0; 67 | } 68 | 69 | if (rb->rbHead < rb->rbTail) 70 | { 71 | return rb->rbTail - rb->rbHead; 72 | } 73 | 74 | return DalRbCapacity(rb) - (rb->rbHead - rb->rbTail); 75 | } 76 | 77 | size_t DalRbCanWrite(dal_rb_t *rb) 78 | { 79 | if(NULL == rb) 80 | { 81 | #if EN_DEBUG > 0 82 | GIZWITS_LOG("ERROR: input rb is NULL\r\n"); 83 | #endif 84 | return -1; 85 | } 86 | 87 | return DalRbCapacity(rb) - DalRbCanRead(rb); 88 | } 89 | 90 | size_t DalRbRead(dal_rb_t *rb, void *data, size_t count) 91 | { 92 | int copySz = 0; 93 | 94 | if(NULL == rb) 95 | { 96 | #if EN_DEBUG > 0 97 | GIZWITS_LOG("ERROR: input rb is NULL\r\n"); 98 | #endif 99 | return -1; 100 | } 101 | 102 | if(NULL == data) 103 | { 104 | #if EN_DEBUG > 0 105 | GIZWITS_LOG("ERROR: input data is NULL\r\n"); 106 | #endif 107 | return -1; 108 | } 109 | 110 | if (rb->rbHead < rb->rbTail) 111 | { 112 | copySz = min(count, DalRbCanRead(rb)); 113 | memcpy(data, rb->rbHead, copySz); 114 | rb->rbHead += copySz; 115 | return copySz; 116 | } 117 | else 118 | { 119 | if (count < DalRbCapacity(rb)-(rb->rbHead - rb->rbBuff)) 120 | { 121 | copySz = count; 122 | memcpy(data, rb->rbHead, copySz); 123 | rb->rbHead += copySz; 124 | return copySz; 125 | } 126 | else 127 | { 128 | copySz = DalRbCapacity(rb) - (rb->rbHead - rb->rbBuff); 129 | memcpy(data, rb->rbHead, copySz); 130 | rb->rbHead = rb->rbBuff; 131 | copySz += DalRbRead(rb, (char*)data+copySz, count-copySz); 132 | return copySz; 133 | } 134 | } 135 | } 136 | 137 | size_t DalRbWrite(dal_rb_t *rb, const void *data, size_t count) 138 | { 139 | int tailAvailSz = 0; 140 | 141 | if(NULL == rb) 142 | { 143 | #if EN_DEBUG > 0 144 | GIZWITS_LOG("ERROR: rb is empty \r\n"); 145 | #endif 146 | return -1; 147 | } 148 | 149 | if(NULL == data) 150 | { 151 | #if EN_DEBUG > 0 152 | GIZWITS_LOG("ERROR: data is empty \r\n"); 153 | #endif 154 | return -1; 155 | } 156 | 157 | if (count >= DalRbCanWrite(rb)) 158 | { 159 | #if EN_DEBUG > 0 160 | GIZWITS_LOG("ERROR: no memory %d \r\n", DalRbCanWrite(rb)); 161 | #endif 162 | return -1; 163 | } 164 | 165 | if (rb->rbHead <= rb->rbTail) 166 | { 167 | tailAvailSz = DalRbCapacity(rb) - (rb->rbTail - rb->rbBuff); 168 | if (count <= tailAvailSz) 169 | { 170 | memcpy(rb->rbTail, data, count); 171 | rb->rbTail += count; 172 | if (rb->rbTail == rb->rbBuff+DalRbCapacity(rb)) 173 | { 174 | rb->rbTail = rb->rbBuff; 175 | } 176 | return count; 177 | } 178 | else 179 | { 180 | memcpy(rb->rbTail, data, tailAvailSz); 181 | rb->rbTail = rb->rbBuff; 182 | 183 | return tailAvailSz + DalRbWrite(rb, (char*)data+tailAvailSz, count-tailAvailSz); 184 | } 185 | } 186 | else 187 | { 188 | memcpy(rb->rbTail, data, count); 189 | rb->rbTail += count; 190 | return count; 191 | } 192 | } 193 | 194 | -------------------------------------------------------------------------------- /GoKit3ForOpenHamtaro/Lib/STM32F10x_StdPeriph_Driver/inc/stm32f10x_pwr.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_pwr.h 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief This file contains all the functions prototypes for the PWR firmware 8 | * library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 13 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 14 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 15 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 16 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 17 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 18 | * 19 | *

© COPYRIGHT 2011 STMicroelectronics

20 | ****************************************************************************** 21 | */ 22 | 23 | /* Define to prevent recursive inclusion -------------------------------------*/ 24 | #ifndef __STM32F10x_PWR_H 25 | #define __STM32F10x_PWR_H 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | /* Includes ------------------------------------------------------------------*/ 32 | #include "stm32f10x.h" 33 | 34 | /** @addtogroup STM32F10x_StdPeriph_Driver 35 | * @{ 36 | */ 37 | 38 | /** @addtogroup PWR 39 | * @{ 40 | */ 41 | 42 | /** @defgroup PWR_Exported_Types 43 | * @{ 44 | */ 45 | 46 | /** 47 | * @} 48 | */ 49 | 50 | /** @defgroup PWR_Exported_Constants 51 | * @{ 52 | */ 53 | 54 | /** @defgroup PVD_detection_level 55 | * @{ 56 | */ 57 | 58 | #define PWR_PVDLevel_2V2 ((uint32_t)0x00000000) 59 | #define PWR_PVDLevel_2V3 ((uint32_t)0x00000020) 60 | #define PWR_PVDLevel_2V4 ((uint32_t)0x00000040) 61 | #define PWR_PVDLevel_2V5 ((uint32_t)0x00000060) 62 | #define PWR_PVDLevel_2V6 ((uint32_t)0x00000080) 63 | #define PWR_PVDLevel_2V7 ((uint32_t)0x000000A0) 64 | #define PWR_PVDLevel_2V8 ((uint32_t)0x000000C0) 65 | #define PWR_PVDLevel_2V9 ((uint32_t)0x000000E0) 66 | #define IS_PWR_PVD_LEVEL(LEVEL) (((LEVEL) == PWR_PVDLevel_2V2) || ((LEVEL) == PWR_PVDLevel_2V3)|| \ 67 | ((LEVEL) == PWR_PVDLevel_2V4) || ((LEVEL) == PWR_PVDLevel_2V5)|| \ 68 | ((LEVEL) == PWR_PVDLevel_2V6) || ((LEVEL) == PWR_PVDLevel_2V7)|| \ 69 | ((LEVEL) == PWR_PVDLevel_2V8) || ((LEVEL) == PWR_PVDLevel_2V9)) 70 | /** 71 | * @} 72 | */ 73 | 74 | /** @defgroup Regulator_state_is_STOP_mode 75 | * @{ 76 | */ 77 | 78 | #define PWR_Regulator_ON ((uint32_t)0x00000000) 79 | #define PWR_Regulator_LowPower ((uint32_t)0x00000001) 80 | #define IS_PWR_REGULATOR(REGULATOR) (((REGULATOR) == PWR_Regulator_ON) || \ 81 | ((REGULATOR) == PWR_Regulator_LowPower)) 82 | /** 83 | * @} 84 | */ 85 | 86 | /** @defgroup STOP_mode_entry 87 | * @{ 88 | */ 89 | 90 | #define PWR_STOPEntry_WFI ((uint8_t)0x01) 91 | #define PWR_STOPEntry_WFE ((uint8_t)0x02) 92 | #define IS_PWR_STOP_ENTRY(ENTRY) (((ENTRY) == PWR_STOPEntry_WFI) || ((ENTRY) == PWR_STOPEntry_WFE)) 93 | 94 | /** 95 | * @} 96 | */ 97 | 98 | /** @defgroup PWR_Flag 99 | * @{ 100 | */ 101 | 102 | #define PWR_FLAG_WU ((uint32_t)0x00000001) 103 | #define PWR_FLAG_SB ((uint32_t)0x00000002) 104 | #define PWR_FLAG_PVDO ((uint32_t)0x00000004) 105 | #define IS_PWR_GET_FLAG(FLAG) (((FLAG) == PWR_FLAG_WU) || ((FLAG) == PWR_FLAG_SB) || \ 106 | ((FLAG) == PWR_FLAG_PVDO)) 107 | 108 | #define IS_PWR_CLEAR_FLAG(FLAG) (((FLAG) == PWR_FLAG_WU) || ((FLAG) == PWR_FLAG_SB)) 109 | /** 110 | * @} 111 | */ 112 | 113 | /** 114 | * @} 115 | */ 116 | 117 | /** @defgroup PWR_Exported_Macros 118 | * @{ 119 | */ 120 | 121 | /** 122 | * @} 123 | */ 124 | 125 | /** @defgroup PWR_Exported_Functions 126 | * @{ 127 | */ 128 | 129 | void PWR_DeInit(void); 130 | void PWR_BackupAccessCmd(FunctionalState NewState); 131 | void PWR_PVDCmd(FunctionalState NewState); 132 | void PWR_PVDLevelConfig(uint32_t PWR_PVDLevel); 133 | void PWR_WakeUpPinCmd(FunctionalState NewState); 134 | void PWR_EnterSTOPMode(uint32_t PWR_Regulator, uint8_t PWR_STOPEntry); 135 | void PWR_EnterSTANDBYMode(void); 136 | FlagStatus PWR_GetFlagStatus(uint32_t PWR_FLAG); 137 | void PWR_ClearFlag(uint32_t PWR_FLAG); 138 | 139 | #ifdef __cplusplus 140 | } 141 | #endif 142 | 143 | #endif /* __STM32F10x_PWR_H */ 144 | /** 145 | * @} 146 | */ 147 | 148 | /** 149 | * @} 150 | */ 151 | 152 | /** 153 | * @} 154 | */ 155 | 156 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 157 | -------------------------------------------------------------------------------- /ISD9160ForOpenHamtaro/NuvotonPlatform_Keil/Include/Driver/DrvI2C.h: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------*/ 2 | /* */ 3 | /* Copyright(c) 2011 Nuvoton Technology Corp. All rights reserved. */ 4 | /* */ 5 | /*---------------------------------------------------------------------------------------------------------*/ 6 | #ifndef _DRVI2C_H 7 | #define _DRVI2C_H 8 | 9 | #include "ISD9xx.h" 10 | 11 | /*---------------------------------------------------------------------------------------------------------*/ 12 | /* Define Version number */ 13 | /*---------------------------------------------------------------------------------------------------------*/ 14 | #define DRVI2C_MAJOR_NUM 1 15 | #define DRVI2C_MINOR_NUM 00 16 | #define DRVI2C_BUILD_NUM 1 17 | 18 | /*---------------------------------------------------------------------------------------------------------*/ 19 | /* Version define with SysInfra */ 20 | /*---------------------------------------------------------------------------------------------------------*/ 21 | #define DRVI2C_VERSION_NUM _SYSINFRA_VERSION(DRVI2C_MAJOR_NUM, DRVI2C_MINOR_NUM, DRVI2C_BUILD_NUM) 22 | 23 | /*---------------------------------------------------------------------------------------------------------*/ 24 | /* Define Error Code */ 25 | /*---------------------------------------------------------------------------------------------------------*/ 26 | // E_DRVI2C_ERR_ARGUMENT Wrong Argument 27 | #define E_DRVI2C_ERR_ARGUMENT _SYSINFRA_ERRCODE(TRUE, MODULE_ID_DRVI2C, 1) 28 | 29 | /*---------------------------------------------------------------------------------------------------------*/ 30 | /* I2C port */ 31 | /*---------------------------------------------------------------------------------------------------------*/ 32 | typedef enum {I2C_PORT0 = 0} E_I2C_PORT; 33 | 34 | typedef void (*I2C_CALLBACK)(uint32_t status); 35 | 36 | /*---------------------------------------------------------------------------------------------------------*/ 37 | /* Define I2C Call back function type */ 38 | /*---------------------------------------------------------------------------------------------------------*/ 39 | typedef enum 40 | { 41 | I2CFUNC = 0, 42 | ARBITLOSS = 1, 43 | BUSERROR = 2, 44 | TIMEOUT = 3 45 | } E_I2C_CALLBACK_TYPE; 46 | 47 | /*---------------------------------------------------------------------------------------------------------*/ 48 | /* Define I2C Call back function Data Struct */ 49 | /*---------------------------------------------------------------------------------------------------------*/ 50 | typedef struct 51 | { 52 | I2C_CALLBACK I2CCallBackFn; 53 | I2C_CALLBACK ArbitLossCallBackFn; 54 | I2C_CALLBACK BusErrCallBackFn; 55 | I2C_CALLBACK TimeoutCallBackFn; 56 | 57 | } I2C_CALLBACK_T; 58 | 59 | 60 | /*---------------------------------------------------------------------------------------------------------*/ 61 | /* Define I2C functions prototype */ 62 | /*---------------------------------------------------------------------------------------------------------*/ 63 | void DrvI2C_ClearIntFlag(E_I2C_PORT port); 64 | void DrvI2C_ClearTimeoutFlag(E_I2C_PORT port); 65 | int32_t DrvI2C_Close(E_I2C_PORT port); 66 | void DrvI2C_Ctrl(E_I2C_PORT port, uint8_t u8start, uint8_t u8stop, uint8_t u8intFlag, uint8_t u8ack); 67 | int32_t DrvI2C_DisableInt(E_I2C_PORT port); 68 | int32_t DrvI2C_EnableInt(E_I2C_PORT port); 69 | int32_t DrvI2C_EnableTimeoutCount(E_I2C_PORT port, int32_t i32enable, uint8_t u8div4); 70 | uint32_t DrvI2C_GetClock(E_I2C_PORT port, uint32_t u32clock); 71 | uint8_t DrvI2C_GetIntFlag(E_I2C_PORT port); 72 | uint32_t DrvI2C_GetStatus(E_I2C_PORT port); 73 | uint32_t DrvI2C_GetVersion(void); 74 | int32_t DrvI2C_InstallCallback(E_I2C_PORT port, E_I2C_CALLBACK_TYPE Type, I2C_CALLBACK callbackfn); 75 | int32_t DrvI2C_Open(E_I2C_PORT port, uint32_t u32clock_Hz, uint32_t u32baudrate_Hz); 76 | uint8_t DrvI2C_ReadData(E_I2C_PORT port); 77 | int32_t DrvI2C_SetAddress(E_I2C_PORT port, uint8_t u8slaveNo, uint8_t u8slave_addr, uint8_t u8GC_Flag); 78 | int32_t DrvI2C_SetAddressMask(E_I2C_PORT port, uint8_t u8slaveNo, uint8_t u8slaveAddrMask); 79 | int32_t DrvI2C_SetClock(E_I2C_PORT port, uint32_t u32clock_Hz, uint32_t u32baudrate_Hz); 80 | int32_t DrvI2C_UninstallCallBack(E_I2C_PORT port, E_I2C_CALLBACK_TYPE Type); 81 | void DrvI2C_WriteData(E_I2C_PORT port, uint8_t u8data); 82 | 83 | #endif 84 | 85 | -------------------------------------------------------------------------------- /ISD9160ForOpenHamtaro/NuvotonPlatform_Keil/Src/Driver/retarget.c: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------*/ 2 | /* */ 3 | /* Copyright(c) 2009 Nuvoton Technology Corp. All rights reserved. */ 4 | /* */ 5 | /*---------------------------------------------------------------------------------------------------------*/ 6 | #include 7 | #include "ISD9xx.h" 8 | 9 | #if defined ( __CC_ARM ) 10 | #if (__ARMCC_VERSION < 400000) 11 | #else 12 | /* Insist on keeping widthprec, to avoid X propagation by benign code in C-lib */ 13 | #pragma import _printf_widthprec 14 | #endif 15 | #endif 16 | 17 | /*---------------------------------------------------------------------------------------------------------*/ 18 | /* Macro Definition */ 19 | /*---------------------------------------------------------------------------------------------------------*/ 20 | /* Using UART0 or UART1 */ 21 | #define DEBUG_PORT 0 /*0:UART0 1:UART1 2:UART2 */ 22 | 23 | /*---------------------------------------------------------------------------------------------------------*/ 24 | /* Global variables */ 25 | /*---------------------------------------------------------------------------------------------------------*/ 26 | #ifndef SEMIHOST 27 | struct __FILE { int handle; /* Add whatever you need here */ }; 28 | FILE __stdout; 29 | FILE __stdin; 30 | 31 | typedef union 32 | { 33 | __IO uint32_t WORD; 34 | __IO uint16_t HALFWORD[2]; 35 | __IO uint8_t BYTE[4]; 36 | } GPIO_Data_TypeDef; 37 | 38 | typedef struct 39 | { 40 | GPIO_Data_TypeDef DATA [256]; 41 | GPIO_Data_TypeDef DIR; 42 | uint32_t RESERVED[3]; 43 | GPIO_Data_TypeDef IE; 44 | } GPIO_TypeDef; 45 | 46 | 47 | #define GPIO0 ((GPIO_TypeDef *) ((uint32_t)0x60000000)) 48 | #define GPIO1 ((GPIO_TypeDef *) ((uint32_t)0x60000800)) 49 | #define GPIO2 ((GPIO_TypeDef *) ((uint32_t)0x60001000)) 50 | 51 | 52 | #define PRINT_BYTE 1 53 | #define PRINT_STROBE (1 << 7) 54 | #define PRINT_CHAR 0x7F 55 | 56 | #ifdef VERILOG_VALIDATION 57 | void Enable_GPIO_PRINT(void) 58 | { 59 | GPIO0->DIR.BYTE[PRINT_BYTE] = 0xff; 60 | } 61 | #endif 62 | 63 | /*---------------------------------------------------------------------------------------------------------*/ 64 | /* Routine to write a char */ 65 | /*---------------------------------------------------------------------------------------------------------*/ 66 | void SendChar(int ch) 67 | { 68 | #ifdef VERILOG_VALIDATION 69 | GPIO0->DATA[PRINT_CHAR].BYTE[PRINT_BYTE] = ch; // Write whole char to 2nd byte 70 | GPIO0->DATA[PRINT_STROBE].BYTE[PRINT_BYTE] = PRINT_STROBE; // Write strobe 71 | GPIO0->DATA[PRINT_STROBE].BYTE[PRINT_BYTE] = 0; // Clear Strobe 72 | #else 73 | while(UART0->FSR.TX_FULL == 1); 74 | UART0->DATA = ch; 75 | if(ch == '\n'){ 76 | while(UART0->FSR.TX_FULL == 1); 77 | UART0->DATA = '\r'; 78 | } 79 | #endif 80 | 81 | } 82 | 83 | /*---------------------------------------------------------------------------------------------------------*/ 84 | /* Routine to get a char */ 85 | /*---------------------------------------------------------------------------------------------------------*/ 86 | char GetChar() 87 | { 88 | #ifdef VERILOG_VALIDATION 89 | return 0; 90 | #else 91 | while (UART0->FSR.RX_EMPTY == 1); 92 | return (UART0->DATA); 93 | #endif 94 | 95 | } 96 | 97 | 98 | /*---------------------------------------------------------------------------------------------------------*/ 99 | /* C library retargetting */ 100 | /*---------------------------------------------------------------------------------------------------------*/ 101 | 102 | void _ttywrch(int ch) 103 | { 104 | SendChar(ch); 105 | return; 106 | } 107 | 108 | int fputc(int ch, FILE *f) 109 | { 110 | SendChar(ch); 111 | return 0; 112 | } 113 | 114 | int fgetc(FILE *f) { 115 | return (GetChar()); 116 | } 117 | 118 | 119 | int ferror(FILE *f) { 120 | return EOF; 121 | } 122 | 123 | //---------------------------------- 124 | // Specific to this test program 125 | //---------------------------------- 126 | /* target-specific gotachar(): 127 | * Return 0 if no char is avaialable at UART rcv fifo; else 1. 128 | * Do NOT pull character out of fifo, just return status. 129 | */ 130 | int 131 | gotachar(void) 132 | { 133 | return (UART0->FSR.RX_EMPTY==0); 134 | 135 | } 136 | #else 137 | 138 | int 139 | gotachar(void) 140 | { 141 | return(1); 142 | } 143 | 144 | 145 | #endif 146 | 147 | -------------------------------------------------------------------------------- /ISD9160ForOpenHamtaro/NuvotonPlatform_Keil/Include/Driver/DrvFMC_20120320.h: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------*/ 2 | /* */ 3 | /* Copyright(c) 2009 Nuvoton Technology Corp. All rights reserved. */ 4 | /* */ 5 | /*---------------------------------------------------------------------------------------------------------*/ 6 | #ifndef _DRVFMC_H 7 | #define _DRVFMC_H 8 | 9 | #include "ISD9xx.h" 10 | 11 | /*---------------------------------------------------------------------------------------------------------*/ 12 | /* Define Version number */ 13 | /*---------------------------------------------------------------------------------------------------------*/ 14 | #define DRVFMC_MAJOR_NUM 1 15 | #define DRVFMC_MINOR_NUM 00 16 | #define DRVFMC_BUILD_NUM 1 17 | /*---------------------------------------------------------------------------------------------------------*/ 18 | /* Version define with SysInfra */ 19 | /*---------------------------------------------------------------------------------------------------------*/ 20 | #define DRVFMC_VERSION_NUM _SYSINFRA_VERSION(DRVFMC_MAJOR_NUM, DRVFMC_MINOR_NUM, DRVFMC_BUILD_NUM) 21 | /*---------------------------------------------------------------------------------------------------------*/ 22 | /* Define Error Code */ 23 | /*---------------------------------------------------------------------------------------------------------*/ 24 | // E_DRVFMC_ERR_ISP_FAIL ISP Failed when illegal condition occurs 25 | #define E_DRVFMC_ERR_ISP_FAIL _SYSINFRA_ERRCODE(TRUE, MODULE_ID_DRVFMC, 1) 26 | 27 | /*---------------------------------------------------------------------------------------------------------*/ 28 | /* Define parameter */ 29 | /*---------------------------------------------------------------------------------------------------------*/ 30 | #define CONFIG_BASE 0x00300000 31 | #define CONFIG0 0x00300000 32 | #define CONFIG1 0x00300004 33 | #define LDROM_BASE 0x00100000 34 | #define PAGE_SIZE 1024 35 | /*---------------------------------------------------------------------------------------------------------*/ 36 | /* ISPGO Trigger ISP and ensure M0 pipeline cleared with Instruction Sync Barrier */ 37 | /*---------------------------------------------------------------------------------------------------------*/ 38 | 39 | static __INLINE void ISPGO(void) 40 | { 41 | // Trigger ISP command 42 | FMC->ISPTRG = 1; 43 | 44 | while ( 0x01 == (FMC->ISPTRG & 0x01) ); 45 | 46 | // Flush M0 pipeline. 47 | __ISB(); 48 | 49 | } 50 | 51 | /*---------------------------------------------------------------------------------------------------------*/ 52 | /* Flash Boot Selector */ 53 | /*---------------------------------------------------------------------------------------------------------*/ 54 | typedef enum {APROM = 0, LDROM = 1} E_FMC_BOOTSELECT; 55 | /*---------------------------------------------------------------------------------------------------------*/ 56 | /* FMC Funciton Command Set */ 57 | /*---------------------------------------------------------------------------------------------------------*/ 58 | 59 | typedef enum{ 60 | E_DRVFMC_FUNC_READ =0x00, 61 | E_DRVFMC_FUNC_CID =0x0B, 62 | E_DRVFMC_FUNC_DID =0x0C, 63 | E_DRVFMC_FUNC_PROG =0x21, 64 | E_DRVFMC_FUNC_ERASE=0x22, 65 | E_DRVFMC_FUNC_IDLE =0x30 66 | } E_DRVFMC_ISPCMD; 67 | 68 | /*---------------------------------------------------------------------------------------------------------*/ 69 | /* Define FMC functions prototype */ 70 | /*---------------------------------------------------------------------------------------------------------*/ 71 | void DrvFMC_EnableISP(int32_t i32Enable); 72 | void DrvFMC_BootSelect(E_FMC_BOOTSELECT boot); 73 | void DrvFMC_EnableLDUpdate(int32_t i32Enable); 74 | void DrvFMC_EnableConfigUpdate(int32_t i32Enable); 75 | int32_t DrvFMC_ReadCID(uint32_t * u32data); 76 | int32_t DrvFMC_ReadDID(uint32_t * u32data); 77 | int32_t DrvFMC_ReadPID(uint32_t * u32data); 78 | int32_t DrvFMC_Write(uint32_t u32addr, uint32_t u32data); 79 | int32_t DrvFMC_Read(uint32_t u32addr, uint32_t * u32data); 80 | int32_t DrvFMC_Erase(uint32_t u32addr); 81 | int32_t DrvFMC_WriteConfig(uint32_t u32data0, uint32_t u32data1); 82 | uint32_t DrvFMC_ReadDataFlashBaseAddr(void); 83 | E_FMC_BOOTSELECT DrvFMC_GetBootSelect(void); 84 | int32_t DrvFMC_ReadBuffer(uint32_t u32addr, uint32_t * u32data,uint32_t u32buffersize); 85 | int32_t DrvFMC_WriteBuffer(uint32_t u32addr, uint32_t *u32data,uint32_t u32buffersize); 86 | #endif 87 | -------------------------------------------------------------------------------- /ISD9160ForOpenHamtaro/NuvotonPlatform_Keil/Src/retarget.c: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------*/ 2 | /* */ 3 | /* Copyright(c) 2009 Nuvoton Technology Corp. All rights reserved. */ 4 | /* */ 5 | /*---------------------------------------------------------------------------------------------------------*/ 6 | 7 | #include 8 | #include "ISD9xx.h" 9 | 10 | #if defined ( __CC_ARM ) 11 | #if (__ARMCC_VERSION < 400000) 12 | #else 13 | /* Insist on keeping widthprec, to avoid X propagation by benign code in C-lib */ 14 | #pragma import _printf_widthprec 15 | #endif 16 | #endif 17 | 18 | /*---------------------------------------------------------------------------------------------------------*/ 19 | /* Macro Definition */ 20 | /*---------------------------------------------------------------------------------------------------------*/ 21 | /* Using UART0 or UART1 */ 22 | #define DEBUG_PORT 0 /*0:UART0 1:UART1 2:UART2 */ 23 | 24 | /*---------------------------------------------------------------------------------------------------------*/ 25 | /* Global variables */ 26 | /*---------------------------------------------------------------------------------------------------------*/ 27 | #ifndef SEMIHOST 28 | struct __FILE { int handle; /* Add whatever you need here */ }; 29 | FILE __stdout; 30 | FILE __stdin; 31 | 32 | #ifndef __GPIO_TYPEDEF 33 | #define __GPIO_TYPEDEF 34 | typedef union 35 | { 36 | __IO uint32_t WORD; 37 | __IO uint16_t HALFWORD[2]; 38 | __IO uint8_t BYTE[4]; 39 | } GPIO_Data_TypeDef; 40 | 41 | typedef struct 42 | { 43 | GPIO_Data_TypeDef DATA [256]; 44 | GPIO_Data_TypeDef DIR; 45 | uint32_t RESERVED[3]; 46 | GPIO_Data_TypeDef IE; 47 | } GPIO_TypeDef; 48 | 49 | #define GPIO0 ((GPIO_TypeDef *) ((uint32_t)0x60000000)) 50 | #define GPIO1 ((GPIO_TypeDef *) ((uint32_t)0x60000800)) 51 | #define GPIO2 ((GPIO_TypeDef *) ((uint32_t)0x60001000)) 52 | #endif 53 | 54 | #define PRINT_BYTE 1 55 | #define PRINT_STROBE (1 << 7) 56 | #define PRINT_CHAR 0x7F 57 | 58 | /*---------------------------------------------------------------------------------------------------------*/ 59 | /* Routine to write a char */ 60 | /*---------------------------------------------------------------------------------------------------------*/ 61 | #ifdef VERILOG_VALIDATION 62 | void Enable_GPIO_PRINT(void) 63 | { 64 | GPIO0->DIR.BYTE[PRINT_BYTE] = 0xff; 65 | } 66 | #endif 67 | 68 | void SendChar(int ch) 69 | { 70 | #ifdef VERILOG_VALIDATION 71 | GPIO0->DATA[PRINT_CHAR].BYTE[PRINT_BYTE] = ch; // Write whole char to 2nd byte 72 | GPIO0->DATA[PRINT_STROBE].BYTE[PRINT_BYTE] = PRINT_STROBE; // Write strobe 73 | GPIO0->DATA[PRINT_STROBE].BYTE[PRINT_BYTE] = 0; // Clear Strobe 74 | #else 75 | while(UART0->FSR.TX_FULL == 1); 76 | UART0->DATA = ch; 77 | if(ch == '\n'){ 78 | while(UART0->FSR.TX_FULL == 1); 79 | UART0->DATA = '\r'; 80 | } 81 | #endif 82 | 83 | } 84 | 85 | /*---------------------------------------------------------------------------------------------------------*/ 86 | /* Routine to get a char */ 87 | /*---------------------------------------------------------------------------------------------------------*/ 88 | char GetChar() 89 | { 90 | #ifdef VERILOG_VALIDATION 91 | return 0; 92 | #else 93 | while (UART0->FSR.RX_EMPTY == 1); 94 | return (UART0->DATA); 95 | #endif 96 | 97 | } 98 | 99 | 100 | /*---------------------------------------------------------------------------------------------------------*/ 101 | /* C library retargetting */ 102 | /*---------------------------------------------------------------------------------------------------------*/ 103 | 104 | void _ttywrch(int ch) 105 | { 106 | SendChar(ch); 107 | return; 108 | } 109 | 110 | int fputc(int ch, FILE *f) 111 | { 112 | SendChar(ch); 113 | return 0; 114 | } 115 | 116 | int fgetc(FILE *f) { 117 | return (GetChar()); 118 | } 119 | 120 | 121 | int ferror(FILE *f) { 122 | return EOF; 123 | } 124 | 125 | //---------------------------------- 126 | // Specific to this test program 127 | //---------------------------------- 128 | /* target-specific gotachar(): 129 | * Return 0 if no char is avaialable at UART rcv fifo; else 1. 130 | * Do NOT pull character out of fifo, just return status. 131 | */ 132 | int 133 | gotachar(void) 134 | { 135 | return (UART0->FSR.RX_EMPTY==0); 136 | 137 | } 138 | #else 139 | 140 | int 141 | gotachar(void) 142 | { 143 | return(1); 144 | } 145 | #endif 146 | -------------------------------------------------------------------------------- /ISD9160ForOpenHamtaro/NuvotonPlatform_Keil/Include/Driver/DrvFMC.h: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------*/ 2 | /* */ 3 | /* Copyright(c) 2009 Nuvoton Technology Corp. All rights reserved. */ 4 | /* */ 5 | /*---------------------------------------------------------------------------------------------------------*/ 6 | #ifndef _DRVFMC_H 7 | #define _DRVFMC_H 8 | 9 | #include "ISD9xx.h" 10 | 11 | /*---------------------------------------------------------------------------------------------------------*/ 12 | /* Define Version number */ 13 | /*---------------------------------------------------------------------------------------------------------*/ 14 | #define DRVFMC_MAJOR_NUM 1 15 | #define DRVFMC_MINOR_NUM 00 16 | #define DRVFMC_BUILD_NUM 1 17 | /*---------------------------------------------------------------------------------------------------------*/ 18 | /* Version define with SysInfra */ 19 | /*---------------------------------------------------------------------------------------------------------*/ 20 | #define DRVFMC_VERSION_NUM _SYSINFRA_VERSION(DRVFMC_MAJOR_NUM, DRVFMC_MINOR_NUM, DRVFMC_BUILD_NUM) 21 | /*---------------------------------------------------------------------------------------------------------*/ 22 | /* Define Error Code */ 23 | /*---------------------------------------------------------------------------------------------------------*/ 24 | // E_DRVFMC_ERR_ISP_FAIL ISP Failed when illegal condition occurs 25 | #define E_DRVFMC_ERR_ISP_FAIL _SYSINFRA_ERRCODE(TRUE, MODULE_ID_DRVFMC, 1) 26 | 27 | /*---------------------------------------------------------------------------------------------------------*/ 28 | /* Define parameter */ 29 | /*---------------------------------------------------------------------------------------------------------*/ 30 | #define CONFIG_BASE 0x00300000 31 | #define CONFIG0 0x00300000 32 | #define CONFIG1 0x00300004 33 | #define LDROM_BASE 0x00100000 34 | #define PAGE_SIZE 1024 35 | /*---------------------------------------------------------------------------------------------------------*/ 36 | /* ISPGO Trigger ISP and ensure M0 pipeline cleared with Instruction Sync Barrier */ 37 | /*---------------------------------------------------------------------------------------------------------*/ 38 | 39 | static __INLINE void ISPGO(void) 40 | { 41 | // Trigger ISP command 42 | FMC->ISPTRG = 1; 43 | // Flush M0 pipeline. 44 | __ISB(); 45 | } 46 | 47 | static __INLINE void ISPGO_ISR(void) 48 | { 49 | __disable_irq(); 50 | // Trigger ISP command 51 | FMC->ISPTRG = 1; 52 | // Flush M0 pipeline. 53 | __ISB(); 54 | __enable_irq(); 55 | } 56 | 57 | /*---------------------------------------------------------------------------------------------------------*/ 58 | /* Flash Boot Selector */ 59 | /*---------------------------------------------------------------------------------------------------------*/ 60 | typedef enum {APROM = 0, LDROM = 1} E_FMC_BOOTSELECT; 61 | /*---------------------------------------------------------------------------------------------------------*/ 62 | /* FMC Funciton Command Set */ 63 | /*---------------------------------------------------------------------------------------------------------*/ 64 | 65 | typedef enum{ 66 | E_DRVFMC_FUNC_READ =0x00, 67 | E_DRVFMC_FUNC_CID =0x0B, 68 | E_DRVFMC_FUNC_DID =0x0C, 69 | E_DRVFMC_FUNC_PROG =0x21, 70 | E_DRVFMC_FUNC_ERASE=0x22, 71 | E_DRVFMC_FUNC_IDLE =0x30 72 | } E_DRVFMC_ISPCMD; 73 | 74 | /*---------------------------------------------------------------------------------------------------------*/ 75 | /* Define FMC functions prototype */ 76 | /*---------------------------------------------------------------------------------------------------------*/ 77 | void DrvFMC_EnableISP(int32_t i32Enable); 78 | void DrvFMC_BootSelect(E_FMC_BOOTSELECT boot); 79 | void DrvFMC_EnableLDUpdate(int32_t i32Enable); 80 | void DrvFMC_EnableConfigUpdate(int32_t i32Enable); 81 | int32_t DrvFMC_ReadCID(uint32_t * u32data); 82 | int32_t DrvFMC_ReadDID(uint32_t * u32data); 83 | int32_t DrvFMC_ReadPID(uint32_t * u32data); 84 | int32_t DrvFMC_Write(uint32_t u32addr, uint32_t u32data); 85 | int32_t DrvFMC_Read(uint32_t u32addr, uint32_t * u32data); 86 | int32_t DrvFMC_Erase(uint32_t u32addr); 87 | int32_t DrvFMC_WriteConfig(uint32_t u32data0, uint32_t u32data1); 88 | uint32_t DrvFMC_ReadDataFlashBaseAddr(void); 89 | E_FMC_BOOTSELECT DrvFMC_GetBootSelect(void); 90 | int32_t DrvFMC_ReadBuffer(uint32_t u32addr, uint32_t * u32data,uint32_t u32buffersize); 91 | int32_t DrvFMC_WriteBuffer(uint32_t u32addr, uint32_t *u32data,uint32_t u32buffersize); 92 | #endif 93 | -------------------------------------------------------------------------------- /GoKit3ForOpenHamtaro/Lib/STM32F10x_StdPeriph_Driver/src/stm32f10x_iwdg.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_iwdg.c 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief This file provides all the IWDG firmware functions. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2011 STMicroelectronics

19 | ****************************************************************************** 20 | */ 21 | 22 | /* Includes ------------------------------------------------------------------*/ 23 | #include "stm32f10x_iwdg.h" 24 | 25 | /** @addtogroup STM32F10x_StdPeriph_Driver 26 | * @{ 27 | */ 28 | 29 | /** @defgroup IWDG 30 | * @brief IWDG driver modules 31 | * @{ 32 | */ 33 | 34 | /** @defgroup IWDG_Private_TypesDefinitions 35 | * @{ 36 | */ 37 | 38 | /** 39 | * @} 40 | */ 41 | 42 | /** @defgroup IWDG_Private_Defines 43 | * @{ 44 | */ 45 | 46 | /* ---------------------- IWDG registers bit mask ----------------------------*/ 47 | 48 | /* KR register bit mask */ 49 | #define KR_KEY_Reload ((uint16_t)0xAAAA) 50 | #define KR_KEY_Enable ((uint16_t)0xCCCC) 51 | 52 | /** 53 | * @} 54 | */ 55 | 56 | /** @defgroup IWDG_Private_Macros 57 | * @{ 58 | */ 59 | 60 | /** 61 | * @} 62 | */ 63 | 64 | /** @defgroup IWDG_Private_Variables 65 | * @{ 66 | */ 67 | 68 | /** 69 | * @} 70 | */ 71 | 72 | /** @defgroup IWDG_Private_FunctionPrototypes 73 | * @{ 74 | */ 75 | 76 | /** 77 | * @} 78 | */ 79 | 80 | /** @defgroup IWDG_Private_Functions 81 | * @{ 82 | */ 83 | 84 | /** 85 | * @brief Enables or disables write access to IWDG_PR and IWDG_RLR registers. 86 | * @param IWDG_WriteAccess: new state of write access to IWDG_PR and IWDG_RLR registers. 87 | * This parameter can be one of the following values: 88 | * @arg IWDG_WriteAccess_Enable: Enable write access to IWDG_PR and IWDG_RLR registers 89 | * @arg IWDG_WriteAccess_Disable: Disable write access to IWDG_PR and IWDG_RLR registers 90 | * @retval None 91 | */ 92 | void IWDG_WriteAccessCmd(uint16_t IWDG_WriteAccess) 93 | { 94 | /* Check the parameters */ 95 | assert_param(IS_IWDG_WRITE_ACCESS(IWDG_WriteAccess)); 96 | IWDG->KR = IWDG_WriteAccess; 97 | } 98 | 99 | /** 100 | * @brief Sets IWDG Prescaler value. 101 | * @param IWDG_Prescaler: specifies the IWDG Prescaler value. 102 | * This parameter can be one of the following values: 103 | * @arg IWDG_Prescaler_4: IWDG prescaler set to 4 104 | * @arg IWDG_Prescaler_8: IWDG prescaler set to 8 105 | * @arg IWDG_Prescaler_16: IWDG prescaler set to 16 106 | * @arg IWDG_Prescaler_32: IWDG prescaler set to 32 107 | * @arg IWDG_Prescaler_64: IWDG prescaler set to 64 108 | * @arg IWDG_Prescaler_128: IWDG prescaler set to 128 109 | * @arg IWDG_Prescaler_256: IWDG prescaler set to 256 110 | * @retval None 111 | */ 112 | void IWDG_SetPrescaler(uint8_t IWDG_Prescaler) 113 | { 114 | /* Check the parameters */ 115 | assert_param(IS_IWDG_PRESCALER(IWDG_Prescaler)); 116 | IWDG->PR = IWDG_Prescaler; 117 | } 118 | 119 | /** 120 | * @brief Sets IWDG Reload value. 121 | * @param Reload: specifies the IWDG Reload value. 122 | * This parameter must be a number between 0 and 0x0FFF. 123 | * @retval None 124 | */ 125 | void IWDG_SetReload(uint16_t Reload) 126 | { 127 | /* Check the parameters */ 128 | assert_param(IS_IWDG_RELOAD(Reload)); 129 | IWDG->RLR = Reload; 130 | } 131 | 132 | /** 133 | * @brief Reloads IWDG counter with value defined in the reload register 134 | * (write access to IWDG_PR and IWDG_RLR registers disabled). 135 | * @param None 136 | * @retval None 137 | */ 138 | void IWDG_ReloadCounter(void) 139 | { 140 | IWDG->KR = KR_KEY_Reload; 141 | } 142 | 143 | /** 144 | * @brief Enables IWDG (write access to IWDG_PR and IWDG_RLR registers disabled). 145 | * @param None 146 | * @retval None 147 | */ 148 | void IWDG_Enable(void) 149 | { 150 | IWDG->KR = KR_KEY_Enable; 151 | } 152 | 153 | /** 154 | * @brief Checks whether the specified IWDG flag is set or not. 155 | * @param IWDG_FLAG: specifies the flag to check. 156 | * This parameter can be one of the following values: 157 | * @arg IWDG_FLAG_PVU: Prescaler Value Update on going 158 | * @arg IWDG_FLAG_RVU: Reload Value Update on going 159 | * @retval The new state of IWDG_FLAG (SET or RESET). 160 | */ 161 | FlagStatus IWDG_GetFlagStatus(uint16_t IWDG_FLAG) 162 | { 163 | FlagStatus bitstatus = RESET; 164 | /* Check the parameters */ 165 | assert_param(IS_IWDG_FLAG(IWDG_FLAG)); 166 | if ((IWDG->SR & IWDG_FLAG) != (uint32_t)RESET) 167 | { 168 | bitstatus = SET; 169 | } 170 | else 171 | { 172 | bitstatus = RESET; 173 | } 174 | /* Return the flag status */ 175 | return bitstatus; 176 | } 177 | 178 | /** 179 | * @} 180 | */ 181 | 182 | /** 183 | * @} 184 | */ 185 | 186 | /** 187 | * @} 188 | */ 189 | 190 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 191 | -------------------------------------------------------------------------------- /ISD9160ForOpenHamtaro/NuvotonPlatform_Keil/Include/Driver/DrvSDCard.h: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------------*/ 2 | /* */ 3 | /* Copyright(c) 2011 Nuvoton Technology Corp. All rights reserved. */ 4 | /* */ 5 | /*--------------------------------------------------------------------------------*/ 6 | 7 | #ifndef __DRVSDCARD_H__ 8 | #define __DRVSDCARD_H__ 9 | 10 | // Include header file 11 | #include "ISD9xx.h" 12 | 13 | 14 | /*--------------------------------------------------------------------------------*/ 15 | /* Macro, type and constant definitions */ 16 | /*--------------------------------------------------------------------------------*/ 17 | // Command Table Index Constants: 18 | // Definitions for each table entry in the command table. 19 | // These allow the MMC_Command_Exec function to be called with a 20 | // meaningful parameter rather than a number. 21 | #define SDv1 1<<1 22 | #define SDv2 1<<2 23 | #define MMCv3 1<<3 24 | #define SDBlock 1<<4 25 | 26 | 27 | 28 | #define GO_IDLE_STATE 0//CMD0 29 | #define SEND_OP_COND 1//CMD1 30 | #define SEND_IF_COND 2//CMD8 31 | #define SEND_CSD 3//CMD9 32 | #define SEND_CID 4//CMD10 33 | #define STOP_TRANSMISSION 5//CMD12 34 | #define SEND_STATUS 6//CMD13 35 | #define SET_BLOCKLEN 7//CMD16 36 | #define READ_SINGLE_BLOCK 8//CMD17 37 | #define READ_MULTIPLE_BLOCK 9//CMD18 38 | #define SET_BLOCK_COUNT 10//CMD23 39 | #define WRITE_BLOCK 11//CMD24 40 | #define WRITE_MULTIPLE_BLOCK 12//CMD25 41 | #define PROGRAM_CSD 13//CMD27 42 | #define SET_WRITE_PROT 14//CMD28 43 | #define CLR_WRITE_PROT 15//CMD29 44 | #define SEND_WRITE_PROT 16//CMD30 45 | #define TAG_SECTOR_START 17//CMD32 46 | #define TAG_SECTOR_END 18//CMD33 47 | #define UNTAG_SECTOR 19//CMD34 48 | #define TAG_ERASE_GROUP_START 20//CMD35 49 | #define TAG_ERASE_GROUP_END 21//CMD36 50 | #define UNTAG_ERASE_GROUP 22//CMD37 51 | #define ERASE 23//CMD38 52 | #define LOCK_UNLOCK 24//CMD42 53 | #define APP_CMD 25//CMD55 54 | #define READ_OCR 26//CMD58 55 | #define CRC_ON_OFF 27//CMD59 56 | #define SD_SEND_STATUS 28//ACMD13 57 | #define SD_SET_WR_BLK_ERASE_COUNT 29//ACMD23 58 | #define SD_SEND_OP_COND 30//ACMD41 59 | 60 | 61 | /*--------------------------------------------------------------------------------*/ 62 | /* Define Version number */ 63 | /*--------------------------------------------------------------------------------*/ 64 | #define DRVSDCARD_MAJOR_NUM 1 65 | #define DRVSDCARD_MINOR_NUM 00 66 | #define DRVSDCARD_BUILD_NUM 1 67 | #define DRVSDCARD_VERSION_NUM _SYSINFRA_VERSION(DRVSDCARD_MAJOR_NUM, DRVSDCARD_MINOR_NUM, DRVSDCARD_BUILD_NUM) 68 | 69 | 70 | /*--------------------------------------------------------------------------------*/ 71 | /* Define Error Code */ 72 | /*--------------------------------------------------------------------------------*/ 73 | #define E_DRVSDCARD_PIN_UNAVAILABLE _SYSINFRA_ERRCODE(true, MODULE_ID_DRVSDCARD, 0) 74 | #define E_DRVSDCARD_INITIAL_FAIL _SYSINFRA_ERRCODE(TRUE, MODULE_ID_DRVSDCARD, 1) 75 | #define E_DRVSDCARD_SD_BUSY _SYSINFRA_ERRCODE(TRUE, MODULE_ID_DRVSDCARD, 2) 76 | #define E_DRVSDCARD_CARD_REMOVED _SYSINFRA_ERRCODE(TRUE, MODULE_ID_DRVSDCARD, 3) 77 | #define E_DRVSDCARD_RESPONSE_TIMEOUT _SYSINFRA_ERRCODE(TRUE, MODULE_ID_DRVSDCARD, 4) 78 | #define E_DRVSDCARD_CRC_ERROR _SYSINFRA_ERRCODE(TRUE, MODULE_ID_DRVSDCARD, 5) 79 | #define E_DRVSDCARD_MULT_READ _SYSINFRA_ERRCODE(TRUE, MODULE_ID_DRVSDCARD, 6) 80 | #define E_DRVSDCARD_TRANSFER_TIMEOUT _SYSINFRA_ERRCODE(TRUE, MODULE_ID_DRVSDCARD, 7) 81 | #define E_DRVSDCARD_COMMAND_STOP _SYSINFRA_ERRCODE(TRUE, MODULE_ID_DRVSDCARD, 8) 82 | #define E_DRVSDCARD_MULT_WRITE _SYSINFRA_ERRCODE(TRUE, MODULE_ID_DRVSDCARD, 9) 83 | #define E_DRVSDCARD_READ_ERROR _SYSINFRA_ERRCODE(TRUE, MODULE_ID_DRVSDCARD, 10) 84 | #define E_DRVSDCARD_WRITE_ERROR _SYSINFRA_ERRCODE(TRUE, MODULE_ID_DRVSDCARD, 11) 85 | #define E_DRVSDCARD_CLOCK_LIMIT _SYSINFRA_ERRCODE(TRUE, MODULE_ID_DRVSDCARD, 12) 86 | #define E_DRVSDCARD_SET_GPIO_ERROR _SYSINFRA_ERRCODE(TRUE, MODULE_ID_DRVSDCARD, 13) 87 | #define E_DRVSDCARD_GPIO_ERROR _SYSINFRA_ERRCODE(TRUE, MODULE_ID_DRVSDCARD, 14) 88 | 89 | /*--------------------------------------------------------------------------------*/ 90 | /* Define Function Prototype */ 91 | /*--------------------------------------------------------------------------------*/ 92 | uint32_t DrvSDCARD_Open(void); 93 | void DrvSDCARD_Close(void); 94 | uint32_t DrvSDCARD_GetVersion(void); 95 | uint32_t DrvSDCARD_MMCcmdExec (uint8_t cmd_loc, uint32_t argument,uint8_t *pchar, uint32_t* response); 96 | uint32_t DrvSDCARD_GetLogicSector(void); 97 | uint32_t DrvSDCARD_GetCardSize(uint32_t* pu32TotSecCnt); 98 | void DrvSDCARD_SpiRead(uint32_t addr, uint32_t size, uint8_t* buffer); 99 | void DrvSDCARD_SpiWrite(uint32_t addr, uint32_t size, uint8_t* buffer); 100 | #endif //__DRVSDCARD_H__ 101 | 102 | 103 | 104 | 105 | -------------------------------------------------------------------------------- /GoKit3ForOpenHamtaro/Lib/STM32F10x_StdPeriph_Driver/src/stm32f10x_dbgmcu.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_dbgmcu.c 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief This file provides all the DBGMCU firmware functions. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2011 STMicroelectronics

19 | ****************************************************************************** 20 | */ 21 | 22 | /* Includes ------------------------------------------------------------------*/ 23 | #include "stm32f10x_dbgmcu.h" 24 | 25 | /** @addtogroup STM32F10x_StdPeriph_Driver 26 | * @{ 27 | */ 28 | 29 | /** @defgroup DBGMCU 30 | * @brief DBGMCU driver modules 31 | * @{ 32 | */ 33 | 34 | /** @defgroup DBGMCU_Private_TypesDefinitions 35 | * @{ 36 | */ 37 | 38 | /** 39 | * @} 40 | */ 41 | 42 | /** @defgroup DBGMCU_Private_Defines 43 | * @{ 44 | */ 45 | 46 | #define IDCODE_DEVID_MASK ((uint32_t)0x00000FFF) 47 | /** 48 | * @} 49 | */ 50 | 51 | /** @defgroup DBGMCU_Private_Macros 52 | * @{ 53 | */ 54 | 55 | /** 56 | * @} 57 | */ 58 | 59 | /** @defgroup DBGMCU_Private_Variables 60 | * @{ 61 | */ 62 | 63 | /** 64 | * @} 65 | */ 66 | 67 | /** @defgroup DBGMCU_Private_FunctionPrototypes 68 | * @{ 69 | */ 70 | 71 | /** 72 | * @} 73 | */ 74 | 75 | /** @defgroup DBGMCU_Private_Functions 76 | * @{ 77 | */ 78 | 79 | /** 80 | * @brief Returns the device revision identifier. 81 | * @param None 82 | * @retval Device revision identifier 83 | */ 84 | uint32_t DBGMCU_GetREVID(void) 85 | { 86 | return(DBGMCU->IDCODE >> 16); 87 | } 88 | 89 | /** 90 | * @brief Returns the device identifier. 91 | * @param None 92 | * @retval Device identifier 93 | */ 94 | uint32_t DBGMCU_GetDEVID(void) 95 | { 96 | return(DBGMCU->IDCODE & IDCODE_DEVID_MASK); 97 | } 98 | 99 | /** 100 | * @brief Configures the specified peripheral and low power mode behavior 101 | * when the MCU under Debug mode. 102 | * @param DBGMCU_Periph: specifies the peripheral and low power mode. 103 | * This parameter can be any combination of the following values: 104 | * @arg DBGMCU_SLEEP: Keep debugger connection during SLEEP mode 105 | * @arg DBGMCU_STOP: Keep debugger connection during STOP mode 106 | * @arg DBGMCU_STANDBY: Keep debugger connection during STANDBY mode 107 | * @arg DBGMCU_IWDG_STOP: Debug IWDG stopped when Core is halted 108 | * @arg DBGMCU_WWDG_STOP: Debug WWDG stopped when Core is halted 109 | * @arg DBGMCU_TIM1_STOP: TIM1 counter stopped when Core is halted 110 | * @arg DBGMCU_TIM2_STOP: TIM2 counter stopped when Core is halted 111 | * @arg DBGMCU_TIM3_STOP: TIM3 counter stopped when Core is halted 112 | * @arg DBGMCU_TIM4_STOP: TIM4 counter stopped when Core is halted 113 | * @arg DBGMCU_CAN1_STOP: Debug CAN2 stopped when Core is halted 114 | * @arg DBGMCU_I2C1_SMBUS_TIMEOUT: I2C1 SMBUS timeout mode stopped when Core is halted 115 | * @arg DBGMCU_I2C2_SMBUS_TIMEOUT: I2C2 SMBUS timeout mode stopped when Core is halted 116 | * @arg DBGMCU_TIM5_STOP: TIM5 counter stopped when Core is halted 117 | * @arg DBGMCU_TIM6_STOP: TIM6 counter stopped when Core is halted 118 | * @arg DBGMCU_TIM7_STOP: TIM7 counter stopped when Core is halted 119 | * @arg DBGMCU_TIM8_STOP: TIM8 counter stopped when Core is halted 120 | * @arg DBGMCU_CAN2_STOP: Debug CAN2 stopped when Core is halted 121 | * @arg DBGMCU_TIM15_STOP: TIM15 counter stopped when Core is halted 122 | * @arg DBGMCU_TIM16_STOP: TIM16 counter stopped when Core is halted 123 | * @arg DBGMCU_TIM17_STOP: TIM17 counter stopped when Core is halted 124 | * @arg DBGMCU_TIM9_STOP: TIM9 counter stopped when Core is halted 125 | * @arg DBGMCU_TIM10_STOP: TIM10 counter stopped when Core is halted 126 | * @arg DBGMCU_TIM11_STOP: TIM11 counter stopped when Core is halted 127 | * @arg DBGMCU_TIM12_STOP: TIM12 counter stopped when Core is halted 128 | * @arg DBGMCU_TIM13_STOP: TIM13 counter stopped when Core is halted 129 | * @arg DBGMCU_TIM14_STOP: TIM14 counter stopped when Core is halted 130 | * @param NewState: new state of the specified peripheral in Debug mode. 131 | * This parameter can be: ENABLE or DISABLE. 132 | * @retval None 133 | */ 134 | void DBGMCU_Config(uint32_t DBGMCU_Periph, FunctionalState NewState) 135 | { 136 | /* Check the parameters */ 137 | assert_param(IS_DBGMCU_PERIPH(DBGMCU_Periph)); 138 | assert_param(IS_FUNCTIONAL_STATE(NewState)); 139 | 140 | if (NewState != DISABLE) 141 | { 142 | DBGMCU->CR |= DBGMCU_Periph; 143 | } 144 | else 145 | { 146 | DBGMCU->CR &= ~DBGMCU_Periph; 147 | } 148 | } 149 | 150 | /** 151 | * @} 152 | */ 153 | 154 | /** 155 | * @} 156 | */ 157 | 158 | /** 159 | * @} 160 | */ 161 | 162 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 163 | -------------------------------------------------------------------------------- /GoKit3ForOpenHamtaro/Hal/hal_temp_hum/hal_temp_hum.c: -------------------------------------------------------------------------------- 1 | /** 2 | ******************************************************** 3 | * 4 | * @file Hal_temp_hum.c 5 | * @author Gizwtis 6 | * @version V03010100 7 | * @date 2016-07-05 8 | * 9 | * @brief 机智云.只为智能硬件而生 10 | * Gizwits Smart Cloud for Smart Products 11 | * 链接|增值ֵ|开放|中立|安全|自有|自由|生态 12 | * www.gizwits.com 13 | * 14 | *********************************************************/ 15 | #include "Hal_temp_hum/Hal_temp_hum.h" 16 | #include 17 | 18 | thTypedef_t temphumTypedef; 19 | 20 | 21 | //Reset DHT11 22 | static void dht11Rst(void) 23 | { 24 | DHT11_IO_OUT(); //SET OUTPUT 25 | DHT11_DQ_OUT=0; //GPIOA.0=0 26 | delayMs(20); //Pull down Least 18ms 27 | DHT11_DQ_OUT=1; //GPIOA.0=1 28 | delayUs(30); //Pull up 20~40us 29 | } 30 | 31 | static uint8_t dht11Check(void) 32 | { 33 | uint8_t retry=0; 34 | DHT11_IO_IN(); //SET INPUT 35 | while (DHT11_DQ_IN && (retry<100)) //DHT11 Pull down 40~80us 36 | { 37 | retry++; 38 | delayUs(1); 39 | } 40 | 41 | if(retry >= 100) 42 | { 43 | return 1; 44 | } 45 | else 46 | { 47 | retry=0; 48 | } 49 | 50 | while (!DHT11_DQ_IN&& (retry < 100)) //DHT11 Pull up 40~80us 51 | { 52 | retry++; 53 | delayUs(1); 54 | } 55 | 56 | if(retry >= 100) 57 | { 58 | return 1; //check error 59 | } 60 | 61 | return 0; 62 | } 63 | 64 | static uint8_t dht11ReadBit(void) 65 | { 66 | uint8_t retry=0; 67 | while(DHT11_DQ_IN && (retry<100)) //wait become Low level 68 | { 69 | retry++; 70 | delayUs(1); 71 | } 72 | 73 | retry = 0; 74 | while(!DHT11_DQ_IN && (retry < 100)) //wait become High level 75 | { 76 | retry++; 77 | delayUs(1); 78 | } 79 | 80 | delayUs(30);//wait 40us 81 | 82 | if(DHT11_DQ_IN) 83 | { 84 | return 1; 85 | } 86 | else 87 | { 88 | return 0; 89 | } 90 | } 91 | 92 | static uint8_t dht11ReadByte(void) 93 | { 94 | uint8_t i,dat; 95 | dat=0; 96 | for (i=0; i<8; i++) 97 | { 98 | dat<<=1; 99 | dat |= dht11ReadBit(); 100 | } 101 | 102 | return dat; 103 | } 104 | 105 | static uint8_t dht11ReadData(uint8_t *temperature, uint8_t *humidity) 106 | { 107 | uint8_t buf[5]; 108 | uint8_t i; 109 | dht11Rst(); 110 | if(0 == dht11Check()) 111 | { 112 | for(i=0; i<5; i++) 113 | { 114 | buf[i] = dht11ReadByte(); 115 | } 116 | if(buf[4] == (buf[0]+buf[1]+buf[2]+buf[3])) 117 | { 118 | *humidity = buf[0]; 119 | *temperature = buf[2]; 120 | } 121 | } 122 | else 123 | { 124 | return 1; 125 | } 126 | 127 | return 0; 128 | } 129 | 130 | uint8_t dht11Read(uint8_t *temperature, uint8_t *humidity) 131 | { 132 | uint8_t curTem = 0, curHum = 0; 133 | uint16_t temMeans = 0, humMeans = 0; 134 | uint8_t curI = 0; 135 | uint8_t ret = 0; 136 | 137 | ret = dht11ReadData(&curTem, &curHum); 138 | 139 | if(1 != ret) 140 | { 141 | //Cycle store ten times stronghold 142 | if(MEAN_NUM > temphumTypedef.curI) 143 | { 144 | temphumTypedef.thBufs[temphumTypedef.curI][0] = curTem; 145 | temphumTypedef.thBufs[temphumTypedef.curI][1] = curHum; 146 | 147 | temphumTypedef.curI++; 148 | } 149 | else 150 | { 151 | temphumTypedef.curI = 0; 152 | 153 | temphumTypedef.thBufs[temphumTypedef.curI][0] = curTem; 154 | temphumTypedef.thBufs[temphumTypedef.curI][1] = curHum; 155 | 156 | temphumTypedef.curI++; 157 | } 158 | } 159 | else 160 | { 161 | return (1); 162 | } 163 | 164 | if(MEAN_NUM <= temphumTypedef.curI) 165 | { 166 | temphumTypedef.thAmount = MEAN_NUM; 167 | } 168 | 169 | if(0 == temphumTypedef.thAmount) 170 | { 171 | //Calculate Before ten the mean 172 | for(curI = 0; curI < temphumTypedef.curI; curI++) 173 | { 174 | temMeans += temphumTypedef.thBufs[curI][0]; 175 | humMeans += temphumTypedef.thBufs[curI][1]; 176 | } 177 | 178 | temMeans = temMeans / temphumTypedef.curI; 179 | humMeans = humMeans / temphumTypedef.curI; 180 | 181 | *temperature = temMeans; 182 | *humidity = humMeans; 183 | } 184 | else if(MEAN_NUM == temphumTypedef.thAmount) 185 | { 186 | //Calculate After ten times the mean 187 | for(curI = 0; curI < temphumTypedef.thAmount; curI++) 188 | { 189 | temMeans += temphumTypedef.thBufs[curI][0]; 190 | humMeans += temphumTypedef.thBufs[curI][1]; 191 | } 192 | 193 | temMeans = temMeans / temphumTypedef.thAmount; 194 | humMeans = humMeans / temphumTypedef.thAmount; 195 | 196 | *temperature = (uint8_t)temMeans; 197 | *humidity = (uint8_t)humMeans; 198 | } 199 | 200 | return (0); 201 | } 202 | 203 | uint8_t dht11Init(void) 204 | { 205 | /* Migrate your driver code */ 206 | GPIO_InitTypeDef GPIO_InitStructure; 207 | 208 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE); 209 | GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable,ENABLE); 210 | 211 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3; 212 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; 213 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 214 | GPIO_Init(GPIOB, &GPIO_InitStructure); 215 | GPIO_SetBits(GPIOB,GPIO_Pin_3); 216 | 217 | dht11Rst(); 218 | 219 | memset((uint8_t *)&temphumTypedef, 0, sizeof(thTypedef_t)); 220 | #if EN_DEBUG > 0 221 | printf("dh11Init \r\n"); 222 | #endif 223 | return dht11Check(); 224 | } 225 | -------------------------------------------------------------------------------- /GoKit3ForOpenHamtaro/User/stm32f10x_it.c: -------------------------------------------------------------------------------- 1 | /** 2 | ******************************************************** 3 | * 4 | * @file stm32f10x_it.c 5 | * @author Gizwtis 6 | * @version V03010100 7 | * @date 2016-07-05 8 | * 9 | * @brief 机智云.只为智能硬件而生 10 | * Gizwits Smart Cloud for Smart Products 11 | * 链接|增值ֵ|开放|中立|安全|自有|自由|生态 12 | * www.gizwits.com 13 | * 14 | *********************************************************/ 15 | 16 | /* Includes ------------------------------------------------------------------*/ 17 | #include "stm32f10x_it.h" 18 | #include "stm32f10x_gpio.h" 19 | #include "Hal_infrared/Hal_infrared.h" 20 | 21 | /** @addtogroup STM32F10x_StdPeriph_Examples 22 | * @{ 23 | */ 24 | 25 | /** @addtogroup GPIO_IOToggle 26 | * @{ 27 | */ 28 | 29 | /* Private typedef -----------------------------------------------------------*/ 30 | /* Private define ------------------------------------------------------------*/ 31 | /* Private macro -------------------------------------------------------------*/ 32 | /* Private variables ---------------------------------------------------------*/ 33 | /* Private function prototypes -----------------------------------------------*/ 34 | /* Private functions ---------------------------------------------------------*/ 35 | 36 | /******************************************************************************/ 37 | /* Cortex-M3 Processor Exceptions Handlers */ 38 | /******************************************************************************/ 39 | 40 | /** 41 | * @brief This function handles NMI exception. 42 | * @param None 43 | * @retval None 44 | */ 45 | void NMI_Handler(void) 46 | { 47 | } 48 | 49 | /** 50 | * @brief This function handles Hard Fault exception. 51 | * @param None 52 | * @retval None 53 | */ 54 | void HardFault_Handler(void) 55 | { 56 | // uint32_t r_sp ; 57 | 58 | // r_sp = __get_PSP(); //??SP?? 59 | //// PERROR(ERROR,Memory Access Error!); 60 | //// Panic(r_sp); 61 | // printf("r_sp = 0x%x",r_sp); 62 | 63 | while (1); 64 | } 65 | 66 | /** 67 | * @brief This function handles Memory Manage exception. 68 | * @param None 69 | * @retval None 70 | */ 71 | void MemManage_Handler(void) 72 | { 73 | /* Go to infinite loop when Memory Manage exception occurs */ 74 | while (1) 75 | { 76 | } 77 | } 78 | 79 | /** 80 | * @brief This function handles Bus Fault exception. 81 | * @param None 82 | * @retval None 83 | */ 84 | void BusFault_Handler(void) 85 | { 86 | /* Go to infinite loop when Bus Fault exception occurs */ 87 | while (1) 88 | { 89 | } 90 | } 91 | 92 | /** 93 | * @brief This function handles Usage Fault exception. 94 | * @param None 95 | * @retval None 96 | */ 97 | void UsageFault_Handler(void) 98 | { 99 | /* Go to infinite loop when Usage Fault exception occurs */ 100 | while (1) 101 | { 102 | } 103 | } 104 | 105 | /** 106 | * @brief This function handles SVCall exception. 107 | * @param None 108 | * @retval None 109 | */ 110 | void SVC_Handler(void) 111 | { 112 | } 113 | 114 | /** 115 | * @brief This function handles Debug Monitor exception. 116 | * @param None 117 | * @retval None 118 | */ 119 | void DebugMon_Handler(void) 120 | { 121 | } 122 | 123 | /** 124 | * @brief This function handles PendSV_Handler exception. 125 | * @param None 126 | * @retval None 127 | */ 128 | void PendSV_Handler(void) 129 | { 130 | } 131 | 132 | /** 133 | * @brief This function handles SysTick Handler. 134 | * @param None 135 | * @retval None 136 | */ 137 | void SysTick_Handler(void) 138 | { 139 | SysTick->VAL =0X00; 140 | } 141 | 142 | /******************************************************************************/ 143 | /* STM32F10x Peripherals Interrupt Handlers */ 144 | /* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */ 145 | /* available peripheral interrupt handler's name please refer to the startup */ 146 | /* file (startup_stm32f10x_xx.s). */ 147 | /******************************************************************************/ 148 | 149 | /** 150 | * @brief This function handles PPP interrupt request. 151 | * @param None 152 | * @retval None 153 | */ 154 | /*void PPP_IRQHandler(void) 155 | { 156 | }*/ 157 | 158 | /** 159 | * @} 160 | */ 161 | 162 | void USART3_IRQHandler(void) 163 | { 164 | if(USART_GetITStatus(USART3, USART_IT_RXNE) != RESET) 165 | { 166 | USART_ClearITPendingBit(USART3,USART_IT_RXNE); 167 | USART_SendData(USART3,USART_ReceiveData(USART3)); 168 | //Loop until the end of transmission 169 | while (USART_GetFlagStatus(USART3, USART_FLAG_TXE) == RESET); 170 | } 171 | } 172 | 173 | /******************************************************************************/ 174 | /* STM32F10x Peripherals Interrupt Handlers */ 175 | /* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */ 176 | /* available peripheral interrupt handler's name please refer to the startup */ 177 | /* file (startup_stm32f10x_xx.s). */ 178 | /******************************************************************************/ 179 | 180 | void RTC_IRQHandler(void) 181 | { 182 | if (RTC_GetITStatus(RTC_IT_SEC) != RESET) 183 | { 184 | /* Clear the RTC Second interrupt */ 185 | RTC_ClearITPendingBit(RTC_IT_SEC); 186 | } 187 | } 188 | 189 | 190 | #define Infrared_EXTI_IRQHandler EXTI9_5_IRQHandler 191 | void Infrared_EXTI_IRQHandler (void) 192 | { 193 | EXTI->EMR &= (uint32_t)~(1<<1); 194 | 195 | while(EXTI_GetITStatus(Infrared_EXTI_LineX)!= RESET ) 196 | { 197 | // printf("Infrared_EXTI...\r\n"); 198 | if(GPIO_ReadInputDataBit(Infrared_GPIO_PORT, Infrared_GPIO_PIN)) 199 | { 200 | //Device_ReadStruct.Infrared = FALSE; 201 | } 202 | else 203 | { 204 | //Device_ReadStruct.Infrared = TRUE; 205 | } 206 | // Pro_D2W_ReportDevStatusHandle(); 207 | EXTI_ClearITPendingBit(Infrared_EXTI_LineX); 208 | } 209 | 210 | EXTI->EMR |= (uint32_t)(1<<1); 211 | } 212 | /** 213 | * @} 214 | */ 215 | 216 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 217 | -------------------------------------------------------------------------------- /GoKit3ForOpenHamtaro/Lib/STM32F10x_StdPeriph_Driver/src/stm32f10x_wwdg.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_wwdg.c 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief This file provides all the WWDG firmware functions. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2011 STMicroelectronics

19 | ****************************************************************************** 20 | */ 21 | 22 | /* Includes ------------------------------------------------------------------*/ 23 | #include "stm32f10x_wwdg.h" 24 | #include "stm32f10x_rcc.h" 25 | 26 | /** @addtogroup STM32F10x_StdPeriph_Driver 27 | * @{ 28 | */ 29 | 30 | /** @defgroup WWDG 31 | * @brief WWDG driver modules 32 | * @{ 33 | */ 34 | 35 | /** @defgroup WWDG_Private_TypesDefinitions 36 | * @{ 37 | */ 38 | 39 | /** 40 | * @} 41 | */ 42 | 43 | /** @defgroup WWDG_Private_Defines 44 | * @{ 45 | */ 46 | 47 | /* ----------- WWDG registers bit address in the alias region ----------- */ 48 | #define WWDG_OFFSET (WWDG_BASE - PERIPH_BASE) 49 | 50 | /* Alias word address of EWI bit */ 51 | #define CFR_OFFSET (WWDG_OFFSET + 0x04) 52 | #define EWI_BitNumber 0x09 53 | #define CFR_EWI_BB (PERIPH_BB_BASE + (CFR_OFFSET * 32) + (EWI_BitNumber * 4)) 54 | 55 | /* --------------------- WWDG registers bit mask ------------------------ */ 56 | 57 | /* CR register bit mask */ 58 | #define CR_WDGA_Set ((uint32_t)0x00000080) 59 | 60 | /* CFR register bit mask */ 61 | #define CFR_WDGTB_Mask ((uint32_t)0xFFFFFE7F) 62 | #define CFR_W_Mask ((uint32_t)0xFFFFFF80) 63 | #define BIT_Mask ((uint8_t)0x7F) 64 | 65 | /** 66 | * @} 67 | */ 68 | 69 | /** @defgroup WWDG_Private_Macros 70 | * @{ 71 | */ 72 | 73 | /** 74 | * @} 75 | */ 76 | 77 | /** @defgroup WWDG_Private_Variables 78 | * @{ 79 | */ 80 | 81 | /** 82 | * @} 83 | */ 84 | 85 | /** @defgroup WWDG_Private_FunctionPrototypes 86 | * @{ 87 | */ 88 | 89 | /** 90 | * @} 91 | */ 92 | 93 | /** @defgroup WWDG_Private_Functions 94 | * @{ 95 | */ 96 | 97 | /** 98 | * @brief Deinitializes the WWDG peripheral registers to their default reset values. 99 | * @param None 100 | * @retval None 101 | */ 102 | void WWDG_DeInit(void) 103 | { 104 | RCC_APB1PeriphResetCmd(RCC_APB1Periph_WWDG, ENABLE); 105 | RCC_APB1PeriphResetCmd(RCC_APB1Periph_WWDG, DISABLE); 106 | } 107 | 108 | /** 109 | * @brief Sets the WWDG Prescaler. 110 | * @param WWDG_Prescaler: specifies the WWDG Prescaler. 111 | * This parameter can be one of the following values: 112 | * @arg WWDG_Prescaler_1: WWDG counter clock = (PCLK1/4096)/1 113 | * @arg WWDG_Prescaler_2: WWDG counter clock = (PCLK1/4096)/2 114 | * @arg WWDG_Prescaler_4: WWDG counter clock = (PCLK1/4096)/4 115 | * @arg WWDG_Prescaler_8: WWDG counter clock = (PCLK1/4096)/8 116 | * @retval None 117 | */ 118 | void WWDG_SetPrescaler(uint32_t WWDG_Prescaler) 119 | { 120 | uint32_t tmpreg = 0; 121 | /* Check the parameters */ 122 | assert_param(IS_WWDG_PRESCALER(WWDG_Prescaler)); 123 | /* Clear WDGTB[1:0] bits */ 124 | tmpreg = WWDG->CFR & CFR_WDGTB_Mask; 125 | /* Set WDGTB[1:0] bits according to WWDG_Prescaler value */ 126 | tmpreg |= WWDG_Prescaler; 127 | /* Store the new value */ 128 | WWDG->CFR = tmpreg; 129 | } 130 | 131 | /** 132 | * @brief Sets the WWDG window value. 133 | * @param WindowValue: specifies the window value to be compared to the downcounter. 134 | * This parameter value must be lower than 0x80. 135 | * @retval None 136 | */ 137 | void WWDG_SetWindowValue(uint8_t WindowValue) 138 | { 139 | __IO uint32_t tmpreg = 0; 140 | 141 | /* Check the parameters */ 142 | assert_param(IS_WWDG_WINDOW_VALUE(WindowValue)); 143 | /* Clear W[6:0] bits */ 144 | 145 | tmpreg = WWDG->CFR & CFR_W_Mask; 146 | 147 | /* Set W[6:0] bits according to WindowValue value */ 148 | tmpreg |= WindowValue & (uint32_t) BIT_Mask; 149 | 150 | /* Store the new value */ 151 | WWDG->CFR = tmpreg; 152 | } 153 | 154 | /** 155 | * @brief Enables the WWDG Early Wakeup interrupt(EWI). 156 | * @param None 157 | * @retval None 158 | */ 159 | void WWDG_EnableIT(void) 160 | { 161 | *(__IO uint32_t *) CFR_EWI_BB = (uint32_t)ENABLE; 162 | } 163 | 164 | /** 165 | * @brief Sets the WWDG counter value. 166 | * @param Counter: specifies the watchdog counter value. 167 | * This parameter must be a number between 0x40 and 0x7F. 168 | * @retval None 169 | */ 170 | void WWDG_SetCounter(uint8_t Counter) 171 | { 172 | /* Check the parameters */ 173 | assert_param(IS_WWDG_COUNTER(Counter)); 174 | /* Write to T[6:0] bits to configure the counter value, no need to do 175 | a read-modify-write; writing a 0 to WDGA bit does nothing */ 176 | WWDG->CR = Counter & BIT_Mask; 177 | } 178 | 179 | /** 180 | * @brief Enables WWDG and load the counter value. 181 | * @param Counter: specifies the watchdog counter value. 182 | * This parameter must be a number between 0x40 and 0x7F. 183 | * @retval None 184 | */ 185 | void WWDG_Enable(uint8_t Counter) 186 | { 187 | /* Check the parameters */ 188 | assert_param(IS_WWDG_COUNTER(Counter)); 189 | WWDG->CR = CR_WDGA_Set | Counter; 190 | } 191 | 192 | /** 193 | * @brief Checks whether the Early Wakeup interrupt flag is set or not. 194 | * @param None 195 | * @retval The new state of the Early Wakeup interrupt flag (SET or RESET) 196 | */ 197 | FlagStatus WWDG_GetFlagStatus(void) 198 | { 199 | return (FlagStatus)(WWDG->SR); 200 | } 201 | 202 | /** 203 | * @brief Clears Early Wakeup interrupt flag. 204 | * @param None 205 | * @retval None 206 | */ 207 | void WWDG_ClearFlag(void) 208 | { 209 | WWDG->SR = (uint32_t)RESET; 210 | } 211 | 212 | /** 213 | * @} 214 | */ 215 | 216 | /** 217 | * @} 218 | */ 219 | 220 | /** 221 | * @} 222 | */ 223 | 224 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 225 | -------------------------------------------------------------------------------- /ISD9160ForOpenHamtaro/CMSIS/CM0/DeviceSupport/Nuvoton/ISD91xx/boot_ISD9xx.c: -------------------------------------------------------------------------------- 1 | /* 2 | *----------------------------------------------------------------------------- 3 | * The confidential and proprietary information contained in this file may 4 | * only be used by a person authorised under and to the extent permitted 5 | * by a subsisting licensing agreement from ARM Limited. 6 | * 7 | * (C) COPYRIGHT 2009 ARM Limited. 8 | * ALL RIGHTS RESERVED 9 | * 10 | * This entire notice must be reproduced on all copies of this file 11 | * and copies of this file may only be made by a person if such person is 12 | * permitted to do so under the terms of a subsisting license agreement 13 | * from ARM Limited. 14 | * 15 | * SVN Information 16 | * 17 | * Checked In : $Date: Thu Jul 2 18:34:07 2009 $ 18 | * 19 | * Revision : $Revision: 1.1 $ 20 | * 21 | * Release Information : Cortex-M0-AT510-r0p0-01rel0 22 | *----------------------------------------------------------------------------- 23 | */ 24 | 25 | // 26 | // Boot (vectors) file for Cortex-M0 Integration Kit 27 | // 28 | 29 | //#include 30 | #include 31 | #include "ISD9xx.h" 32 | //#include 33 | 34 | 35 | // 36 | // Build a stand-alone image 37 | // 38 | 39 | #pragma import(__use_no_semihosting) 40 | 41 | 42 | // 43 | // Dummy Interrupt Handlers 44 | // 45 | // The following functions are defined weakly to allow the user 46 | // to override them at link time simply by declaring their own 47 | // function of the same name. 48 | // 49 | // If no user function is provided, the weak function is used. 50 | // 51 | 52 | __weak void NMI_Handler(void) 53 | { 54 | while(1); 55 | } 56 | 57 | __weak void HardFault_Handler(void) 58 | { 59 | while(1); 60 | } 61 | 62 | __weak void SVC_Handler(void) 63 | { 64 | while(1); 65 | } 66 | 67 | __weak void PendSV_Handler(void) 68 | { 69 | while(1); 70 | } 71 | 72 | __weak void SysTick_Handler(void) 73 | { 74 | while(1); 75 | } 76 | 77 | __weak void GPIO_IRQHandler(void) 78 | { 79 | while(1); 80 | } 81 | 82 | __weak void Default_IRQHandler(void) 83 | { 84 | while(1); 85 | } 86 | 87 | __weak void BOD_IRQHandler(void) 88 | { 89 | while(1); 90 | } 91 | __weak void WDT_IRQHandler(void) 92 | { 93 | while(1); 94 | } 95 | __weak void EINT0_IRQHandler(void) 96 | { 97 | while(1); 98 | } 99 | __weak void EINT1_IRQHandler(void) 100 | { 101 | while(1); 102 | } 103 | __weak void GPAB_IRQHandler(void) 104 | { 105 | while(1); 106 | } 107 | __weak void PWMA_IRQHandler(void) 108 | { 109 | while(1); 110 | } 111 | __weak void TMR0_IRQHandler(void) 112 | { 113 | while(1); 114 | } 115 | __weak void TMR1_IRQHandler(void) 116 | { 117 | while(1); 118 | } 119 | __weak void UART02_IRQHandler(void) 120 | { 121 | while(1); 122 | } 123 | __weak void SPI0_IRQHandler(void) 124 | { 125 | while(1); 126 | } 127 | __weak void DPWM_IRQHandler(void) 128 | { 129 | while(1); 130 | } 131 | __weak void I2C0_IRQHandler(void) 132 | { 133 | while(1); 134 | } 135 | __weak void ACMP_IRQHandler(void) 136 | { 137 | while(1); 138 | } 139 | __weak void PDMA_IRQHandler(void) 140 | { 141 | while(1); 142 | } 143 | __weak void I2S_IRQHandler(void) 144 | { 145 | while(1); 146 | } 147 | __weak void ADC_IRQHandler(void) 148 | { 149 | while(1); 150 | } 151 | __weak void CAPS_IRQHandler(void) 152 | { 153 | while(1); 154 | } 155 | __weak void RTC_IRQHandler(void) 156 | { 157 | while(1); 158 | } 159 | __weak void ALC_IRQHandler(void) 160 | { 161 | while(1); 162 | } 163 | __weak void TALARM_IRQHandler(void) 164 | { 165 | while(1); 166 | } 167 | 168 | 169 | 170 | 171 | // 172 | // Reset Handler 173 | // 174 | 175 | extern void __main(void); 176 | 177 | 178 | void Reset_Handler(void) 179 | { 180 | /* check ICE_CLK and ICE_DAT to disable power down to the chip */ 181 | if (SYSCLK->DBGPD.ICE_CLK == 0 && SYSCLK->DBGPD.ICE_DAT == 0) 182 | SYSCLK->DBGPD.DISABLE_PD = 1; 183 | __main(); 184 | } 185 | 186 | 187 | // 188 | // Set up Vector Table 189 | // 190 | 191 | typedef void (*const vect_t)(void) __irq; 192 | 193 | vect_t __Vectors[] 194 | __attribute__ ((section("vectors"))) = { 195 | (vect_t)(0x20003000), // Top of Stack 196 | (vect_t)Reset_Handler, // Reset Handler 197 | (vect_t)NMI_Handler, // NMI Handler 198 | (vect_t)HardFault_Handler,// Hard Fault Handler 199 | 0, // Reserved 200 | 0, // Reserved 201 | 0, // Reserved 202 | 0, // Reserved 203 | 0, // Reserved 204 | 0, // Reserved 205 | 0, // Reserved 206 | (vect_t)SVC_Handler, // SVCall Handler 207 | 0, // Reserved 208 | 0, // Reserved 209 | (vect_t)PendSV_Handler, // PendSV Handler 210 | (vect_t)SysTick_Handler, // SysTick Handler 211 | 212 | // External Interrupts 213 | //0-3 214 | (vect_t)BOD_IRQHandler, 215 | (vect_t)WDT_IRQHandler, 216 | (vect_t)EINT0_IRQHandler, 217 | (vect_t)EINT1_IRQHandler, 218 | //4-7 219 | (vect_t)GPAB_IRQHandler, 220 | (vect_t)ALC_IRQHandler, 221 | (vect_t)PWMA_IRQHandler, 222 | (vect_t)Default_IRQHandler, 223 | //8-11 224 | (vect_t)TMR0_IRQHandler, 225 | (vect_t)TMR1_IRQHandler, 226 | (vect_t)Default_IRQHandler, 227 | (vect_t)Default_IRQHandler, 228 | //12-15 229 | (vect_t)UART02_IRQHandler, 230 | (vect_t)Default_IRQHandler, 231 | (vect_t)SPI0_IRQHandler, 232 | (vect_t)DPWM_IRQHandler, 233 | //16-19 234 | (vect_t)Default_IRQHandler, 235 | (vect_t)Default_IRQHandler, 236 | (vect_t)I2C0_IRQHandler, 237 | (vect_t)Default_IRQHandler, 238 | //20-23 239 | (vect_t)GPIO_IRQHandler , 240 | (vect_t)TALARM_IRQHandler, 241 | (vect_t)Default_IRQHandler, 242 | (vect_t)Default_IRQHandler, 243 | //24-27 244 | (vect_t)Default_IRQHandler, 245 | (vect_t)ACMP_IRQHandler, 246 | (vect_t)PDMA_IRQHandler, 247 | (vect_t)I2S_IRQHandler, 248 | //28-31 249 | (vect_t)CAPS_IRQHandler, 250 | (vect_t)ADC_IRQHandler, 251 | (vect_t)Default_IRQHandler, 252 | (vect_t)RTC_IRQHandler 253 | }; 254 | 255 | 256 | // 257 | // Set up initial stack and heap 258 | // 259 | 260 | __value_in_regs struct __initial_stackheap 261 | __user_initial_stackheap(unsigned hb, unsigned sb, unsigned hl, unsigned sl) 262 | { 263 | struct __initial_stackheap s; 264 | 265 | s.heap_base = hb; 266 | s.stack_base = sb; 267 | s.heap_limit = s.stack_base; 268 | s.stack_limit = s.heap_base; 269 | return s; 270 | } 271 | 272 | 273 | // 274 | // Set test status bits in testbench when main() exits 275 | // 276 | 277 | void _sys_exit(int return_code) 278 | { 279 | while(1); 280 | } 281 | 282 | -------------------------------------------------------------------------------- /ISD9160ForOpenHamtaro/NuvotonPlatform_Keil/Include/Driver/DrvGPIO.h: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------*/ 2 | /* */ 3 | /* Copyright(c) 2011 Nuvoton Technology Corp. All rights reserved. */ 4 | /* */ 5 | /*---------------------------------------------------------------------------------------------------------*/ 6 | #ifndef DRVUART_H 7 | #define DRVUART_H 8 | 9 | #include "ISD9xx.h" 10 | /*---------------------------------------------------------------------------------------------------------*/ 11 | /* Define Version number */ 12 | /*---------------------------------------------------------------------------------------------------------*/ 13 | #define DRVGPIO_MAJOR_NUM 1 14 | #define DRVGPIO_MINOR_NUM 00 15 | #define DRVGPIO_BUILD_NUM 1 16 | 17 | /*---------------------------------------------------------------------------------------------------------*/ 18 | /* Version define with SysInfra */ 19 | /*---------------------------------------------------------------------------------------------------------*/ 20 | #define DRVGPIO_VERSION_NUM _SYSINFRA_VERSION(DRVGPIO_MAJOR_NUM, DRVGPIO_MINOR_NUM, DRVGPIO_BUILD_NUM) 21 | 22 | /*---------------------------------------------------------------------------------------------------------*/ 23 | /* Define Error Code */ 24 | /*---------------------------------------------------------------------------------------------------------*/ 25 | /* Error code */ 26 | //E_DRVGPIO_ARGUMENT Argument error 27 | //E_DRVGPIO_GROUP_PIN Can't set bit function when it can't be set individually 28 | //E_DRVGPIO_BUSY GPIO is in useing 29 | #define E_DRVGPIO_ARGUMENT _SYSINFRA_ERRCODE(TRUE, MODULE_ID_DRVGPIO, 1) 30 | #define E_DRVGPIO_GROUP_PIN _SYSINFRA_ERRCODE(TRUE, MODULE_ID_DRVGPIO, 2) 31 | #define E_DRVGPIO_BUSY _SYSINFRA_ERRCODE(TRUE, MODULE_ID_DRVGPIO, 3) 32 | 33 | 34 | typedef enum 35 | { 36 | GPA = 0, 37 | GPB = 1 38 | } DRVGPIO_PORT; 39 | 40 | typedef void (*GPIO_GPAB_CALLBACK)(uint32_t u32GpaStatus, uint32_t u32GpbStatus); 41 | typedef void (*GPIO_EINT0_CALLBACK)(void); 42 | typedef void (*GPIO_EINT1_CALLBACK)(void); 43 | 44 | 45 | /* Define GPIO PIN number */ 46 | #define DRVGPIO_PIN15 BIT15 47 | #define DRVGPIO_PIN14 BIT14 48 | #define DRVGPIO_PIN13 BIT13 49 | #define DRVGPIO_PIN12 BIT12 50 | #define DRVGPIO_PIN11 BIT11 51 | #define DRVGPIO_PIN10 BIT10 52 | #define DRVGPIO_PIN9 BIT9 53 | #define DRVGPIO_PIN8 BIT8 54 | #define DRVGPIO_PIN7 BIT7 55 | #define DRVGPIO_PIN6 BIT6 56 | #define DRVGPIO_PIN5 BIT5 57 | #define DRVGPIO_PIN4 BIT4 58 | #define DRVGPIO_PIN3 BIT3 59 | #define DRVGPIO_PIN2 BIT2 60 | #define DRVGPIO_PIN1 BIT1 61 | #define DRVGPIO_PIN0 BIT0 62 | 63 | /* 64 | typedef enum {DRVGPIO_BIT0 = 0, DRVGPIO_BIT1, DRVGPIO_BIT2, DRVGPIO_BIT3, DRVGPIO_BIT4, DRVGPIO_BIT5 65 | , DRVGPIO_BIT6, DRVGPIO_BIT7, DRVGPIO_BIT8, DRVGPIO_BIT9, DRVGPIO_BIT10, DRVGPIO_BIT11 66 | , DRVGPIO_BIT12, DRVGPIO_BIT13, DRVGPIO_BIT14, DRVGPIO_BIT15} DRVGPIO_BIT; 67 | */ 68 | /*---------------------------------------------------------------------------------------------------------*/ 69 | /* SYS IP Clcok Selector */ 70 | /*---------------------------------------------------------------------------------------------------------*/ 71 | typedef enum 72 | { 73 | FUNC_GPIO , 74 | FUNC_PWM01 , FUNC_PWM01B , 75 | FUNC_I2C0 , FUNC_I2C1 , FUNC_I2C2 , 76 | FUNC_I2S0 , FUNC_I2S1 , 77 | FUNC_SPI0 , FUNC_SPI1 , 78 | FUNC_ACMP0 , FUNC_ACMP1 , 79 | FUNC_UART0 , FUNC_UART0_FLOW, 80 | FUNC_TMR0 , FUNC_TMR1 , 81 | FUNC_MCLK0 , FUNC_MCLK1 , 82 | FUNC_DMIC0 , FUNC_DMIC1 , 83 | FUNC_SPK , 84 | FUNC_NONE 85 | } DRVGPIO_FUNC; 86 | 87 | 88 | typedef enum {IO_INPUT , IO_OUTPUT, IO_OPENDRAIN , IO_QUASI} DRVGPIO_IO; 89 | //typedef enum {IO_LOWDRV, IO_HIGHDRV} DRVGPIO_DRIVE; 90 | //typedef enum {IO_NO_PULL_UP, IO_PULL_UP} DRVGPIO_PULL_UP; 91 | //typedef enum {IO_INT0, IO_INT1, IO_INT2, IO_INT3} DRVGPIO_INT_NUM; 92 | typedef enum {IO_RISING, IO_FALLING, IO_BOTH_EDGE} DRVGPIO_INT_TYPE; 93 | typedef enum {MODE_EDGE, MODE_LEVEL} DRVGPIO_INT_MODE; 94 | typedef enum {DBCLKSRC_HCLK = 0 ,DBCLKSRC_10K =1} DRVGPIO_DBCLKSRC; 95 | 96 | /*---------------------------------------------------------------------------------------------------------*/ 97 | /* Define GPIO functions prototype */ 98 | /*---------------------------------------------------------------------------------------------------------*/ 99 | int32_t DrvGPIO_Close(DRVGPIO_PORT port,int32_t i32Bit); 100 | int32_t DrvGPIO_ClrBit(DRVGPIO_PORT port,int32_t i32Bit); 101 | int32_t DrvGPIO_ClrBitMask(DRVGPIO_PORT port, uint32_t u32Bit); 102 | int32_t DrvGPIO_DisableDebounce(DRVGPIO_PORT port, uint32_t u32Bit); 103 | void DrvGPIO_DisableEINT0(void); 104 | void DrvGPIO_DisableEINT1(void); 105 | int32_t DrvGPIO_DisableInt(DRVGPIO_PORT port,uint32_t u32Bit); 106 | int32_t DrvGPIO_EnableDebounce(DRVGPIO_PORT port,uint32_t u32Bit); 107 | void DrvGPIO_EnableEINT0(DRVGPIO_INT_TYPE tiggerType, DRVGPIO_INT_MODE mode, GPIO_EINT0_CALLBACK pfEINT0Callback); 108 | void DrvGPIO_EnableEINT1(DRVGPIO_INT_TYPE tiggerType, DRVGPIO_INT_MODE mode, GPIO_EINT1_CALLBACK pfEINT1Callback); 109 | int32_t DrvGPIO_EnableInt(DRVGPIO_PORT port, uint32_t u32Bit, DRVGPIO_INT_TYPE tiggerType, DRVGPIO_INT_MODE mode); 110 | int32_t DrvGPIO_GetBit(DRVGPIO_PORT port, int32_t i32Bit); 111 | int32_t DrvGPIO_GetDebounceTime(void); 112 | int32_t DrvGPIO_GetDoutBit(DRVGPIO_PORT port, int32_t i32Bit); 113 | uint32_t DrvGPIO_GetIntStatus(DRVGPIO_PORT port); 114 | int32_t DrvGPIO_GetPortBits(DRVGPIO_PORT port); 115 | int32_t DrvGPIO_GetPortDoutBits(DRVGPIO_PORT port); 116 | int32_t DrvGPIO_GetVersion (void); 117 | int32_t DrvGPIO_InitFunction(DRVGPIO_FUNC function); 118 | int32_t DrvGPIO_Open(DRVGPIO_PORT port,int32_t i32Bit,DRVGPIO_IO mode); 119 | int32_t DrvGPIO_ReadPortMask(DRVGPIO_PORT port); 120 | int32_t DrvGPIO_SetBit(DRVGPIO_PORT port,int32_t i32Bit); 121 | int32_t DrvGPIO_SetBitMask(DRVGPIO_PORT port, int32_t i32Bit); 122 | int32_t DrvGPIO_SetDebounceTime(uint32_t u32DebounceClk,DRVGPIO_DBCLKSRC clockSource); 123 | void DrvGPIO_SetIntCallback(GPIO_GPAB_CALLBACK pfGPABCallback); 124 | int32_t DrvGPIO_SetPortBits(DRVGPIO_PORT port,int32_t i32Data); 125 | int32_t DrvGPIO_SetPortMask(DRVGPIO_PORT port, uint32_t u32Mask); 126 | 127 | #endif 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | -------------------------------------------------------------------------------- /ISD9160ForOpenHamtaro/CMSIS/CM0/DeviceSupport/Nuvoton/ISD91xx/startup_ISD9xx.c: -------------------------------------------------------------------------------- 1 | /* 2 | *----------------------------------------------------------------------------- 3 | * The confidential and proprietary information contained in this file may 4 | * only be used by a person authorised under and to the extent permitted 5 | * by a subsisting licensing agreement from ARM Limited. 6 | * 7 | * (C) COPYRIGHT 2009 ARM Limited. 8 | * ALL RIGHTS RESERVED 9 | * 10 | * This entire notice must be reproduced on all copies of this file 11 | * and copies of this file may only be made by a person if such person is 12 | * permitted to do so under the terms of a subsisting license agreement 13 | * from ARM Limited. 14 | * 15 | * SVN Information 16 | * 17 | * Checked In : $Date: Thu Jul 2 18:34:07 2009 $ 18 | * 19 | * Revision : $Revision: 1.1 $ 20 | * 21 | * Release Information : Cortex-M0-AT510-r0p0-01rel0 22 | *----------------------------------------------------------------------------- 23 | */ 24 | 25 | // 26 | // Boot (vectors) file for Cortex-M0 Integration Kit 27 | // 28 | 29 | //#include 30 | #include 31 | #include "ISD9xx.h" 32 | //#include 33 | 34 | 35 | // 36 | // Build a stand-alone image 37 | // 38 | 39 | //#pragma import(__use_no_semihosting) 40 | #pragma import(__use_no_heap) 41 | 42 | #define _TOP_OF_SP_ 0x20003000 43 | 44 | 45 | // 46 | // Dummy Interrupt Handlers 47 | // 48 | // The following functions are defined weakly to allow the user 49 | // to override them at link time simply by declaring their own 50 | // function of the same name. 51 | // 52 | // If no user function is provided, the weak function is used. 53 | // 54 | 55 | __weak void NMI_Handler(void) 56 | { 57 | while(1); 58 | } 59 | 60 | __weak void HardFault_Handler(void) 61 | { 62 | while(1); 63 | } 64 | 65 | __weak void SVC_Handler(void) 66 | { 67 | while(1); 68 | } 69 | 70 | __weak void PendSV_Handler(void) 71 | { 72 | while(1); 73 | } 74 | 75 | __weak void SysTick_Handler(void) 76 | { 77 | while(1); 78 | } 79 | 80 | __weak void GPIO_IRQHandler(void) 81 | { 82 | while(1); 83 | } 84 | 85 | __weak void Default_IRQHandler(void) 86 | { 87 | while(1); 88 | } 89 | 90 | __weak void BOD_IRQHandler(void) 91 | { 92 | while(1); 93 | } 94 | __weak void WDT_IRQHandler(void) 95 | { 96 | while(1); 97 | } 98 | __weak void EINT0_IRQHandler(void) 99 | { 100 | while(1); 101 | } 102 | __weak void EINT1_IRQHandler(void) 103 | { 104 | while(1); 105 | } 106 | __weak void GPAB_IRQHandler(void) 107 | { 108 | while(1); 109 | } 110 | __weak void PWMA_IRQHandler(void) 111 | { 112 | while(1); 113 | } 114 | __weak void TMR0_IRQHandler(void) 115 | { 116 | while(1); 117 | } 118 | __weak void TMR1_IRQHandler(void) 119 | { 120 | while(1); 121 | } 122 | __weak void UART02_IRQHandler(void) 123 | { 124 | while(1); 125 | } 126 | __weak void SPI0_IRQHandler(void) 127 | { 128 | while(1); 129 | } 130 | __weak void DPWM_IRQHandler(void) 131 | { 132 | while(1); 133 | } 134 | __weak void I2C0_IRQHandler(void) 135 | { 136 | while(1); 137 | } 138 | __weak void ACMP_IRQHandler(void) 139 | { 140 | while(1); 141 | } 142 | __weak void PDMA_IRQHandler(void) 143 | { 144 | while(1); 145 | } 146 | __weak void I2S_IRQHandler(void) 147 | { 148 | while(1); 149 | } 150 | __weak void ADC_IRQHandler(void) 151 | { 152 | while(1); 153 | } 154 | __weak void CAPS_IRQHandler(void) 155 | { 156 | while(1); 157 | } 158 | __weak void RTC_IRQHandler(void) 159 | { 160 | while(1); 161 | } 162 | __weak void ALC_IRQHandler(void) 163 | { 164 | while(1); 165 | } 166 | __weak void TALARM_IRQHandler(void) 167 | { 168 | while(1); 169 | } 170 | 171 | 172 | 173 | 174 | // 175 | // Reset Handler 176 | // 177 | 178 | extern void __main(void); 179 | 180 | 181 | void Reset_Handler(void) 182 | { 183 | /* check ICE_CLK and ICE_DAT to disable power down to the chip */ 184 | if (SYSCLK->DBGPD.ICE_CLK == 0 && SYSCLK->DBGPD.ICE_DAT == 0) 185 | SYSCLK->DBGPD.DISABLE_PD = 1; 186 | __main(); 187 | } 188 | 189 | 190 | // 191 | // Set up Vector Table 192 | // 193 | 194 | typedef void (*const vect_t)(void) __irq; 195 | 196 | vect_t __Vectors[] 197 | __attribute__ ((section("vectors"))) = { 198 | (vect_t)(_TOP_OF_SP_), // Top of Stack 199 | (vect_t)Reset_Handler, // Reset Handler 200 | (vect_t)NMI_Handler, // NMI Handler 201 | (vect_t)HardFault_Handler,// Hard Fault Handler 202 | 0, // Reserved 203 | 0, // Reserved 204 | 0, // Reserved 205 | 0, // Reserved 206 | 0, // Reserved 207 | 0, // Reserved 208 | 0, // Reserved 209 | (vect_t)SVC_Handler, // SVCall Handler 210 | 0, // Reserved 211 | 0, // Reserved 212 | (vect_t)PendSV_Handler, // PendSV Handler 213 | (vect_t)SysTick_Handler, // SysTick Handler 214 | 215 | // External Interrupts 216 | //0-3 217 | (vect_t)BOD_IRQHandler, 218 | (vect_t)WDT_IRQHandler, 219 | (vect_t)EINT0_IRQHandler, 220 | (vect_t)EINT1_IRQHandler, 221 | //4-7 222 | (vect_t)GPAB_IRQHandler, 223 | (vect_t)ALC_IRQHandler, 224 | (vect_t)PWMA_IRQHandler, 225 | (vect_t)Default_IRQHandler, 226 | //8-11 227 | (vect_t)TMR0_IRQHandler, 228 | (vect_t)TMR1_IRQHandler, 229 | (vect_t)Default_IRQHandler, 230 | (vect_t)Default_IRQHandler, 231 | //12-15 232 | (vect_t)UART02_IRQHandler, 233 | (vect_t)Default_IRQHandler, 234 | (vect_t)SPI0_IRQHandler, 235 | (vect_t)DPWM_IRQHandler, 236 | //16-19 237 | (vect_t)Default_IRQHandler, 238 | (vect_t)Default_IRQHandler, 239 | (vect_t)I2C0_IRQHandler, 240 | (vect_t)Default_IRQHandler, 241 | //20-23 242 | (vect_t)GPIO_IRQHandler , 243 | (vect_t)TALARM_IRQHandler, 244 | (vect_t)Default_IRQHandler, 245 | (vect_t)Default_IRQHandler, 246 | //24-27 247 | (vect_t)Default_IRQHandler, 248 | (vect_t)ACMP_IRQHandler, 249 | (vect_t)PDMA_IRQHandler, 250 | (vect_t)I2S_IRQHandler, 251 | //28-31 252 | (vect_t)CAPS_IRQHandler, 253 | (vect_t)ADC_IRQHandler, 254 | (vect_t)Default_IRQHandler, 255 | (vect_t)RTC_IRQHandler 256 | }; 257 | 258 | 259 | // 260 | // Set up initial stack and heap 261 | // 262 | 263 | __value_in_regs struct __initial_stackheap 264 | __user_initial_stackheap(unsigned hb, unsigned sb, unsigned hl, unsigned sl) 265 | { 266 | struct __initial_stackheap s; 267 | 268 | s.heap_base = hb; 269 | s.stack_base = sb; 270 | s.heap_limit = s.stack_base; 271 | s.stack_limit = s.heap_base; 272 | return s; 273 | } 274 | 275 | 276 | __asm void define_the_sp(void) 277 | { 278 | EXPORT __initial_sp 279 | __initial_sp EQU _TOP_OF_SP_ ; top of the stack 280 | } 281 | 282 | // 283 | // Set test status bits in testbench when main() exits 284 | // 285 | 286 | void _sys_exit(int return_code) 287 | { 288 | while(1); 289 | } 290 | 291 | --------------------------------------------------------------------------------