├── .gitignore ├── LICENSE ├── Quick Start Guide.md ├── README.md ├── firmware ├── .config ├── Kconfig ├── Libraries │ ├── SConscript │ ├── driverlib │ │ ├── SConscript │ │ ├── fh_gpio.c │ │ ├── fh_i2c.c │ │ ├── fh_ictl.c │ │ ├── fh_mmc.c │ │ ├── fh_pwm.c │ │ ├── fh_sdio.c │ │ ├── fh_spi.c │ │ ├── fh_timer.c │ │ ├── fh_uart.c │ │ └── fh_wdt.c │ ├── extlib │ │ ├── SConscript │ │ ├── inc │ │ │ ├── advapi │ │ │ │ ├── FHAdv_Isp_mpi.h │ │ │ │ ├── FHAdv_MD_mpi.h │ │ │ │ ├── FHAdv_audio_cap.h │ │ │ │ ├── FHAdv_audio_play.h │ │ │ │ ├── FHAdv_video_cap.h │ │ │ │ └── FH_typedef.h │ │ │ ├── di │ │ │ │ └── debug_interface.h │ │ │ ├── dsp │ │ │ │ ├── fh_common.h │ │ │ │ ├── fh_jpeg_mpi.h │ │ │ │ ├── fh_jpeg_mpipara.h │ │ │ │ ├── fh_system_mpi.h │ │ │ │ ├── fh_venc_mpi.h │ │ │ │ ├── fh_venc_mpipara.h │ │ │ │ ├── fh_vou_mpi.h │ │ │ │ ├── fh_vou_mpipara.h │ │ │ │ ├── fh_vpu_mpi.h │ │ │ │ └── fh_vpu_mpipara.h │ │ │ ├── isp │ │ │ │ ├── dci_api.h │ │ │ │ ├── isp_api.h │ │ │ │ ├── isp_common.h │ │ │ │ ├── isp_enum.h │ │ │ │ ├── isp_func_def.h │ │ │ │ ├── isp_sensor_if.h │ │ │ │ └── isp_strategy_if.h │ │ │ └── types │ │ │ │ ├── bufCtrl.h │ │ │ │ └── type_def.h │ │ ├── libadvapi.a │ │ ├── libadvapi_isp.a │ │ ├── libadvapi_md.a │ │ ├── libdbi_rtt.a │ │ ├── libdci_rtt.a │ │ ├── libdsp_rtt.a │ │ ├── libenc_rtt.a │ │ ├── libisp_rtt.a │ │ ├── libispcore_rtt.a │ │ ├── libjpeg_rtt.a │ │ ├── libmedia_process_rtt.a │ │ ├── librtt_driver_isp.a │ │ ├── libvmm_rtt.a │ │ ├── libvou_rtt.a │ │ ├── libvpu_rtt.a │ │ ├── sensors │ │ │ ├── libgc1024_ir_rtt.a │ │ │ └── libgc1024_rtt.a │ │ └── src │ │ │ └── media_proc.c │ ├── inc │ │ ├── fh_driverlib.h │ │ ├── fh_gpio.h │ │ ├── fh_i2c.h │ │ ├── fh_ictl.h │ │ ├── fh_mmc.h │ │ ├── fh_pwm.h │ │ ├── fh_sdio.h │ │ ├── fh_spi.h │ │ ├── fh_timer.h │ │ ├── fh_uart.h │ │ └── fh_wdt.h │ └── startup │ │ ├── SConscript │ │ └── gcc │ │ ├── delay.S │ │ ├── delay.h │ │ └── start_gcc.S ├── Makefile ├── README.md ├── SConscript ├── SConstruct ├── applications │ ├── SConscript │ ├── audio_video_demo │ │ ├── SConscript │ │ ├── audio_main.c │ │ ├── jpeg.c │ │ ├── logo_64x64.h │ │ ├── video_main.c │ │ └── vlc.c │ ├── gpio_demo │ │ ├── SConscript │ │ ├── gpio_demo.c │ │ └── gpio_demo.h │ ├── main.c │ ├── sadc_demo │ │ ├── SConscript │ │ ├── sadc_demo.c │ │ └── sadc_demo.h │ ├── sensor_param │ │ ├── SConscript │ │ ├── multi_sensor.c │ │ ├── multi_sensor.h │ │ └── sensorParam_gc1024.c │ ├── symbols.c │ └── wave │ │ ├── SConscript │ │ ├── wave.c │ │ └── wave.h ├── armv6 │ ├── SConscript │ ├── arm_entry_gcc.S │ ├── armv6.h │ ├── context_gcc.S │ ├── cpuport.c │ ├── mmu.c │ ├── mmu.h │ ├── stack.c │ ├── vfp.c │ └── vfp.h ├── drivers │ ├── SConscript │ ├── acw.c │ ├── acw.h │ ├── dma.c │ ├── dma.h │ ├── dma_mem.c │ ├── dma_mem.h │ ├── drv_mmc.c │ ├── drv_mmc.h │ ├── fh81_gmac_dma.h │ ├── fh81_gmac_phyt.h │ ├── fh_audio_mpi.c │ ├── fh_audio_mpi.h │ ├── fh_audio_mpipar.h │ ├── fh_dma.c │ ├── fh_dma.h │ ├── fh_gmac.c │ ├── fh_gmac.h │ ├── gpio.c │ ├── gpio.h │ ├── i2c.c │ ├── i2c.h │ ├── interrupt.c │ ├── interrupt.h │ ├── pwm.c │ ├── pwm.h │ ├── sadc.c │ ├── sadc.h │ ├── ssi.c │ ├── ssi.h │ ├── trap.c │ ├── uart.c │ ├── uart.h │ ├── wdt.c │ └── wdt.h ├── link.ld ├── packages │ ├── SConscript │ ├── dbi │ │ ├── SConscript │ │ ├── dbi_over_tcp.c │ │ ├── dbi_over_tcp.h │ │ ├── dbi_over_udp.c │ │ └── dbi_over_udp.h │ ├── partition │ │ ├── SConscript │ │ ├── partition.c │ │ └── partition.h │ ├── stream_pack │ │ ├── SConscript │ │ ├── pes │ │ │ ├── PSMuxLib.c │ │ │ ├── PSMuxLib.h │ │ │ ├── SConscript │ │ │ ├── pes_pack.c │ │ │ └── pes_pack.h │ │ └── rtsp │ │ │ ├── SConscript │ │ │ ├── rtsp.c │ │ │ └── rtsp.h │ └── wget │ │ ├── SConscript │ │ ├── webclient.c │ │ └── webclient.h ├── platform │ ├── SConscript │ ├── board.h │ ├── board_info.h │ ├── common │ │ ├── SConscript │ │ ├── board_info.c │ │ └── chkenv.c │ ├── fh8620 │ │ ├── SConscript │ │ ├── arch.h │ │ └── iot_cam │ │ │ ├── SConscript │ │ │ ├── board.c │ │ │ ├── board_def.h │ │ │ ├── iomux.c │ │ │ ├── readme │ │ │ └── startup.c │ ├── fh_arch.h │ ├── fh_def.h │ ├── plat-v2 │ │ ├── SConscript │ │ ├── arch.h │ │ ├── calibrate.c │ │ ├── calibrate.h │ │ ├── clock.c │ │ ├── clock.h │ │ ├── fh_pmu.c │ │ ├── fh_pmu.h │ │ ├── iomux.c │ │ ├── iomux.h │ │ ├── reset.c │ │ ├── timer.c │ │ └── timer.h │ └── platform_def.h ├── rtconfig.h └── rtconfig.py ├── hardware └── README.md └── icons ├── copy_rtt.png ├── fb.png ├── menuconfig_add_wifi.gif └── scons.gif /.gitignore: -------------------------------------------------------------------------------- 1 | # Object files 2 | *.o 3 | *.ko 4 | *.obj 5 | *.elf 6 | 7 | # Precompiled Headers 8 | *.gch 9 | *.pch 10 | 11 | # Libraries 12 | *.la 13 | *.lo 14 | 15 | # Shared objects (inc. Windows DLLs) 16 | *.dll 17 | *.so 18 | *.so.* 19 | *.dylib 20 | 21 | # Executables 22 | *.exe 23 | *.out 24 | *.app 25 | *.i*86 26 | *.x86_64 27 | *.hex 28 | 29 | # Debug files 30 | *.dSYM/ 31 | -------------------------------------------------------------------------------- /Quick Start Guide.md: -------------------------------------------------------------------------------- 1 | # Iot Camera 快速入门手册 2 | 本手册说明如何使用env工具对Iot Camera进行开发。env工具可以去官网下载最新的版本使用。下载地址: 3 | 4 | `http://www.rt-thread.org/page/download.html` 5 | 6 | 如果没有使用过env工具,请先参考rtt说明文档,对env的使用有一个简单的了解,env工具自带的ppt也是入门env很好的教程。 7 | 8 | `https://github.com/RT-Thread/rtthread-manual-doc/blob/master/zh/5chapters/01-chapter_env_manual.md` 9 | 10 | ## 1.将rt-thread拷贝到IoT_Camera\firmware目录下 11 | 12 | 可以使用git工具将rt-thread源代码clone到IoT_Camera\firmware目录下,也可以从别处拷贝一份rt-thread到IoT_Camera\firmware目录下。 13 | 14 | ![image](./icons/copy_rtt.png) 15 | 16 | ## 2.使用env工具切换到IoT_Camera\firmware目录并编译 17 | 18 | ![image](./icons/scons.gif) 19 | 20 | 接下来就可以将获得的rtthread.bin来进行烧录运行了。 21 | 22 | ## 3.开启wifi功能 23 | 24 | wifi功能默认是没有开启的,可以使用env来下载相关的组件包来使用wifi功能。 25 | 26 | ![image](./icons/menuconfig_add_wifi.gif) 27 | 28 | 更新好在线组件包之后,重新编译下载即可。 29 | 30 | ## 4.查看命令帮助的方法 31 | 32 | 如果想查看某个命令的使用帮助,可以在msh命令行中输入命令+help查询。 33 | 例如输入`wifi help`查看wifi指令的帮助信息。可以看到wifi的帮助指令: 34 | 35 | wifi wlan_dev scan 36 | wifi wlan_dev join SSID PASSWORD 37 | wifi wlan_dev ap SSID [PASSWORD] 38 | wifi wlan_dev up 39 | wifi wlan_dev down 40 | wifi wlan_dev rssi 41 | wifi wlan_dev status 42 | 43 | 在iot camera的3.0版本中中如果wifi正常初始化,则wlan_dev为w0,可以使用`wifi w0 join SSID PASSWORD`命令来加入wifi。 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # IoT_Camera 2 | 3 | [![fb](icons/fb.png)](https://www.facebook.com/groups/309729986071484) 4 | 5 | IoT Camera is a camera with Wi-Fi wireless network. 6 | 7 | ## Hardware 8 | 9 | * FH8620, ARM1176, up to 450MHz, Builtin 16MB DRAM 10 | * AP6181 (bcm43362) Wi-Fi 11 | * 8MB SPI Nor Flash 12 | * GC1024 sensor 13 | * Hardware encoder for H.264, 1280x720 @ 30FPS 14 | * Hardware encoder for MJPEG 15 | 16 | ## Software 17 | 18 | The software in IoT Camera is based on RT-Thread RTOS. 19 | 20 | * RTSP 21 | * mjpeg streaming 22 | * RT-Thread POSIX edition. 23 | -------------------------------------------------------------------------------- /firmware/Kconfig: -------------------------------------------------------------------------------- 1 | mainmenu "RT-Thread Project Configuration" 2 | 3 | config $BSP_DIR 4 | string 5 | option env="BSP_ROOT" 6 | default "." 7 | 8 | config $RTT_DIR 9 | string 10 | option env="RTT_ROOT" 11 | default "rt-thread" 12 | 13 | config $PKGS_DIR 14 | string 15 | option env="PKGS_ROOT" 16 | default "packages" 17 | 18 | source "$RTT_DIR/KConfig" 19 | source "$PKGS_DIR/KConfig" 20 | 21 | config RT_USING_UART1 22 | bool "Enable UART1" 23 | default y 24 | 25 | config RT_USING_UART2 26 | bool "Enable UART2" 27 | default y 28 | 29 | config RT_USING_GC1024 30 | bool "Enable GC1024 sensor" 31 | default y 32 | 33 | config RT_USING_FH_DMA 34 | bool "Enable Fullhan DMA" 35 | default y 36 | 37 | config RT_USING_DMA_MEM 38 | bool "Enable DMA memory management" 39 | default y 40 | 41 | config RT_USING_FH_ACW 42 | bool "Enable Fullhan ACW driver" 43 | default y 44 | 45 | config CONFIG_CHIP_FH8620 46 | bool "Enable Fullhan FH8620 chip" 47 | default y 48 | 49 | config CONFIG_BOARD_IOTCAM 50 | bool "Enable IoT Camera board" 51 | default y 52 | 53 | config CONFIG_PLAT_V2 54 | bool "Enable Platform V2" 55 | default y 56 | 57 | config RT_USING_DSP 58 | bool "Enable DSP" 59 | default y 60 | 61 | config RT_USING_ISP 62 | bool "Enable ISP" 63 | default y 64 | 65 | if RT_USING_SFUD 66 | 67 | config RT_SFUD_USING_SFDP 68 | bool "Enable SFUD SFDP" 69 | default y 70 | 71 | config RT_SFUD_USING_FLASH_INFO_TABLE 72 | bool "Enable Flash Information Table" 73 | default y 74 | 75 | endif 76 | 77 | config RT_USING_SADC 78 | bool "Enable SADC driver" 79 | default y 80 | 81 | config RT_USING_PWM 82 | bool "Enable PWM driver" 83 | default y 84 | 85 | if RT_USING_WIFI 86 | config SOC_FH8620 87 | bool "Enable SOC_FH8620" 88 | default y 89 | help 90 | please use online packages iot/wifi/wiced also 91 | endif 92 | 93 | 94 | config FH_USING_ADVAPI_MD 95 | bool "Enable Advance MD API" 96 | default y 97 | 98 | config FH_USING_ADVAPI_ISP 99 | bool "Enable Advance ISP API" 100 | default y 101 | 102 | config FH_USING_RTSP 103 | bool "Enable RTSP protocol" 104 | default y 105 | 106 | if FH_USING_RTSP 107 | config FH_USING_RTSP_RTP_TCP 108 | int "RTSP/RTP on TCP" 109 | default 1 110 | 111 | config FH_USING_RTSP_RTP_UDP 112 | int "RTSP/RTP on UDP" 113 | default 0 114 | endif 115 | 116 | config RT_APP_THREAD_PRIORITY 117 | int "default priority level of application thread" 118 | default 20 119 | 120 | config RT_USING_GPIO 121 | bool "Enable FH8620 GPIO Config" 122 | default y 123 | 124 | config RT_USING_INTERRUPT_INFO 125 | bool "Enable FH8620 Interrupt Info" 126 | default y 127 | 128 | 129 | 130 | -------------------------------------------------------------------------------- /firmware/Libraries/SConscript: -------------------------------------------------------------------------------- 1 | # for module compiling 2 | import os 3 | from building import * 4 | 5 | objs = [] 6 | cwd = GetCurrentDir() 7 | list = os.listdir(cwd) 8 | 9 | for item in list: 10 | 11 | if os.path.isfile(os.path.join(cwd, item, 'SConscript')): 12 | objs = objs + SConscript(os.path.join(item, 'SConscript')) 13 | 14 | Return('objs') 15 | -------------------------------------------------------------------------------- /firmware/Libraries/driverlib/SConscript: -------------------------------------------------------------------------------- 1 | from building import * 2 | 3 | cwd = GetCurrentDir() 4 | src = Glob('*.c') 5 | path = [cwd + '/..'] 6 | 7 | group = DefineGroup('Libraries', src, depend = [''], CPPPATH = path) 8 | 9 | Return('group') 10 | -------------------------------------------------------------------------------- /firmware/Libraries/driverlib/fh_gpio.c: -------------------------------------------------------------------------------- 1 | /* 2 | * File : fh_gpio.c 3 | * This file is part of FH8620 BSP for RT-Thread distribution. 4 | * 5 | * Copyright (c) 2016 Shanghai Fullhan Microelectronics Co., Ltd. 6 | * All rights reserved 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License along 19 | * with this program; if not, write to the Free Software Foundation, Inc., 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | * 22 | * Visit http://www.fullhan.com to get contact with Fullhan. 23 | * 24 | * Change Logs: 25 | * Date Author Notes 26 | */ -------------------------------------------------------------------------------- /firmware/Libraries/driverlib/fh_ictl.c: -------------------------------------------------------------------------------- 1 | /* 2 | * File : fh_ictl.c 3 | * This file is part of FH8620 BSP for RT-Thread distribution. 4 | * 5 | * Copyright (c) 2016 Shanghai Fullhan Microelectronics Co., Ltd. 6 | * All rights reserved 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License along 19 | * with this program; if not, write to the Free Software Foundation, Inc., 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | * 22 | * Visit http://www.fullhan.com to get contact with Fullhan. 23 | * 24 | * Change Logs: 25 | * Date Author Notes 26 | */ 27 | 28 | #include "inc/fh_driverlib.h" 29 | 30 | void ictl_close_all_isr(fh_intc *p) 31 | { 32 | if (p) 33 | { 34 | // enable all interrupts 35 | p->IRQ_EN_L = 0xffffffff; 36 | p->IRQ_EN_H = 0xffffffff; 37 | // mask all interrupts 38 | p->IRQ_MASK_L = 0xffffffff; 39 | p->IRQ_MASK_H = 0xffffffff; 40 | } 41 | } 42 | 43 | void ictl_mask_isr(fh_intc *p, int irq) 44 | { 45 | if (p) 46 | { 47 | if (irq < 32) 48 | p->IRQ_MASK_L |= (1 << irq); 49 | else 50 | p->IRQ_MASK_H |= (1 << (irq - 32)); 51 | } 52 | } 53 | 54 | void ictl_unmask_isr(fh_intc *p, int irq) 55 | { 56 | if (p) 57 | { 58 | if (irq < 32) 59 | p->IRQ_MASK_L &= ~(1 << irq); 60 | else 61 | p->IRQ_MASK_H &= ~(1 << (irq - 32)); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /firmware/Libraries/driverlib/fh_pwm.c: -------------------------------------------------------------------------------- 1 | /* 2 | * File : fh_pwm.c 3 | * This file is part of FH8620 BSP for RT-Thread distribution. 4 | * 5 | * Copyright (c) 2016 Shanghai Fullhan Microelectronics Co., Ltd. 6 | * All rights reserved 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License along 19 | * with this program; if not, write to the Free Software Foundation, Inc., 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | * 22 | * Visit http://www.fullhan.com to get contact with Fullhan. 23 | * 24 | * Change Logs: 25 | * Date Author Notes 26 | */ 27 | 28 | #include "inc/fh_driverlib.h" 29 | 30 | void PWM_Enable(struct fh_pwm_obj *pwm_obj, int enable) 31 | { 32 | SET_REG(pwm_obj->base + OFFSET_PWM_CTRL, enable); 33 | } 34 | 35 | unsigned int PWM_GetPwmCmd(struct fh_pwm_obj *pwm_obj, int device_id) 36 | { 37 | return GET_REG(pwm_obj->base + OFFSET_PWM_CMD(device_id)); 38 | } 39 | 40 | void PWM_SetPwmCmd(struct fh_pwm_obj *pwm_obj, int device_id, unsigned int reg) 41 | { 42 | SET_REG(pwm_obj->base + OFFSET_PWM_CMD(device_id), reg); 43 | } 44 | -------------------------------------------------------------------------------- /firmware/Libraries/driverlib/fh_timer.c: -------------------------------------------------------------------------------- 1 | /* 2 | * File : fh_timer.c 3 | * This file is part of FH8620 BSP for RT-Thread distribution. 4 | * 5 | * Copyright (c) 2016 Shanghai Fullhan Microelectronics Co., Ltd. 6 | * All rights reserved 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License along 19 | * with this program; if not, write to the Free Software Foundation, Inc., 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | * 22 | * Visit http://www.fullhan.com to get contact with Fullhan. 23 | * 24 | * Change Logs: 25 | * Date Author Notes 26 | */ 27 | 28 | /***************************************************************************** 29 | * Include Section 30 | * add all #include here 31 | *****************************************************************************/ 32 | #include "inc/fh_driverlib.h" 33 | /***************************************************************************** 34 | * Define section 35 | * add all #define here 36 | *****************************************************************************/ 37 | 38 | /**************************************************************************** 39 | * ADT section 40 | * add definition of user defined Data Type that only be used in this file here 41 | ***************************************************************************/ 42 | 43 | /****************************************************************************** 44 | * Function prototype section 45 | * add prototypes for all functions called by this file,execepting those 46 | * declared in header file 47 | *****************************************************************************/ 48 | 49 | /***************************************************************************** 50 | * Global variables section - Exported 51 | * add declaration of global variables that will be exported here 52 | * e.g. 53 | * int8_t foo; 54 | ****************************************************************************/ 55 | 56 | /***************************************************************************** 57 | * Global variables section - Local 58 | * define global variables(will be refered only in this file) here, 59 | * static keyword should be used to limit scope of local variable to this file 60 | * e.g. 61 | * static uint8_t ufoo; 62 | *****************************************************************************/ 63 | 64 | /* function body */ 65 | 66 | /***************************************************************************** 67 | * Description: 68 | * add funtion description here 69 | * Parameters: 70 | * description for each argument, new argument starts at new line 71 | * Return: 72 | * what does this function returned? 73 | *****************************************************************************/ 74 | int timer_init(timer *tim) 75 | { 76 | tim->TIMER_CTRL_REG = 0; 77 | return 0; 78 | } 79 | 80 | int timer_set_mode(timer *tim, enum timer_mode mode) 81 | { 82 | switch (mode) 83 | { 84 | case TIMER_MODE_PERIODIC: 85 | tim->TIMER_CTRL_REG |= TIMER_CTRL_MODE; 86 | break; 87 | case TIMER_MODE_ONESHOT: 88 | tim->TIMER_CTRL_REG |= TIMER_CTRL_MODE; 89 | break; 90 | default: 91 | rt_kprintf("Not support TIMER mode\n"); 92 | return -1; 93 | break; 94 | } 95 | 96 | return 0; 97 | } 98 | 99 | void timer_set_period(timer *tim, UINT32 period, UINT32 clock) 100 | { 101 | tim->TIMER_LOAD_COUNT = clock / period; 102 | } 103 | 104 | void timer_enable(timer *tim) { tim->TIMER_CTRL_REG |= TIMER_CTRL_ENABLE; } 105 | void timer_disable(timer *tim) { tim->TIMER_CTRL_REG &= ~TIMER_CTRL_ENABLE; } 106 | void timer_enable_irq(timer *tim) 107 | { 108 | tim->TIMER_CTRL_REG &= ~TIMER_CTRL_INTMASK; 109 | } 110 | 111 | void timer_disable_irq(timer *tim) 112 | { 113 | tim->TIMER_CTRL_REG |= TIMER_CTRL_INTMASK; 114 | } 115 | 116 | UINT32 timer_get_status(timer *tim) { return tim->TIMER_INT_STATUS; } 117 | UINT32 timer_get_eoi(timer *tim) { return tim->TIMER_EOI; } 118 | UINT32 timer_get_value(timer *tim) 119 | { 120 | return tim->TIMER_LOAD_COUNT - tim->TIMER_CURRENT_VALUE; 121 | } 122 | -------------------------------------------------------------------------------- /firmware/Libraries/driverlib/fh_wdt.c: -------------------------------------------------------------------------------- 1 | /* 2 | * File : fh_wdt.c 3 | * This file is part of FH8620 BSP for RT-Thread distribution. 4 | * 5 | * Copyright (c) 2016 Shanghai Fullhan Microelectronics Co., Ltd. 6 | * All rights reserved 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License along 19 | * with this program; if not, write to the Free Software Foundation, Inc., 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | * 22 | * Visit http://www.fullhan.com to get contact with Fullhan. 23 | * 24 | * Change Logs: 25 | * Date Author Notes 26 | */ 27 | 28 | #include "inc/fh_driverlib.h" 29 | 30 | void WDT_Enable(struct fh_wdt_obj *wdt_obj, int enable) 31 | { 32 | SET_REG(wdt_obj->base + WDOG_CONTROL_REG_OFFSET, enable); 33 | } 34 | 35 | void WDT_SetTopValue(struct fh_wdt_obj *wdt_obj, int top) 36 | { 37 | SET_REG(wdt_obj->base + WDOG_TIMEOUT_RANGE_REG_OFFSET, top); 38 | } 39 | 40 | void WDT_SetCtrl(struct fh_wdt_obj *wdt_obj, UINT32 reg) 41 | { 42 | SET_REG(wdt_obj->base + WDOG_CONTROL_REG_OFFSET, reg); 43 | } 44 | 45 | void WDT_Kick(struct fh_wdt_obj *wdt_obj) 46 | { 47 | SET_REG(wdt_obj->base + WDOG_COUNTER_RESTART_REG_OFFSET, 48 | WDOG_COUNTER_RESTART_KICK_VALUE); 49 | } 50 | 51 | UINT32 WDT_GetCurrCount(struct fh_wdt_obj *wdt_obj) 52 | { 53 | return GET_REG(wdt_obj->base + WDOG_CURRENT_COUNT_REG_OFFSET); 54 | } 55 | -------------------------------------------------------------------------------- /firmware/Libraries/extlib/SConscript: -------------------------------------------------------------------------------- 1 | Import('RTT_ROOT') 2 | Import('rtconfig') 3 | from building import * 4 | 5 | cwd = GetCurrentDir() 6 | 7 | # The set of source files associated with this SConscript file. 8 | src = Glob('src/*.c') 9 | 10 | path = [cwd + '/inc'] 11 | path += [cwd + '/inc/dsp'] 12 | path += [cwd + '/inc/isp'] 13 | path += [cwd + '/inc/types'] 14 | path += [cwd + '/inc/di'] 15 | path += [cwd + '/inc/advapi'] 16 | 17 | LIBS = Glob('*.a') 18 | if GetDepend('RT_USING_OV9732'): 19 | LIBS += ['libov9732_rtt.a'] 20 | if GetDepend('RT_USING_OV9712'): 21 | LIBS += ['libov9712_rtt.a'] 22 | if GetDepend('RT_USING_AR0130'): 23 | LIBS += ['libar0130_rtt.a'] 24 | if GetDepend('RT_USING_IMX138'): 25 | LIBS += ['libimx-138_rtt.a'] 26 | if GetDepend('RT_USING_GC1024'): 27 | LIBS += ['libgc1024_rtt.a'] 28 | if GetDepend('RT_USING_GC1004'): 29 | LIBS += ['libgc1024_rtt.a'] 30 | if GetDepend('RT_USING_H42'): 31 | LIBS += ['libH42_rtt.a'] 32 | if GetDepend('RT_USING_SC1020'): 33 | LIBS += ['libsc1020_rtt.a'] 34 | if GetDepend('RT_USING_BF3016'): 35 | LIBS += ['libbf3016_rtt.a'] 36 | if GetDepend('RT_USING_GC0308'): 37 | LIBS += ['libgc0308_rtt.a'] 38 | 39 | if not GetDepend('FH_USING_ADVAPI_MD'): 40 | for item in LIBS: 41 | if os.path.basename(item.rstr()) == 'libadvapi_md.a': 42 | LIBS.remove(item) 43 | break 44 | 45 | libadvapi_isp = None 46 | for item in LIBS: 47 | if os.path.basename(item.rstr()) == 'libadvapi_isp.a': 48 | libadvapi_isp = item 49 | LIBS.remove(item) 50 | break 51 | 52 | LINKFLAGS = '' 53 | if GetDepend('FH_USING_ADVAPI_ISP'): 54 | LIBS.append(libadvapi_isp) 55 | NM = rtconfig.PREFIX + 'nm' 56 | import subprocess, re 57 | out = subprocess.check_output([NM, cwd + "/libadvapi_isp.a"]) 58 | 59 | if GetDepend('FH_USING_MULTI_SENSOR'): 60 | LINKFLAGS = ' -u ' + ' -u '.join(re.findall(r'w (.*_[^A-Z]+?)\n', out)) 61 | else: 62 | LINKFLAGS = ' -u ' + ' -u '.join(re.findall(r'w (.*[A-Za-z])\n', out)) 63 | 64 | # print LINKFLAGS 65 | LINKFLAGS = ' -u GetDefaultParam -u GetMirrorFlipBayerFormat -u GetSensorAwbGain -u GetSensorLtmCurve -u Sensor_Create' 66 | 67 | LIBPATH = [cwd] 68 | 69 | if GetDepend('FH_USING_MULTI_SENSOR'): 70 | LIBPATH += [cwd + '/sensors/multiple'] 71 | else: 72 | LIBPATH += [cwd + '/sensors'] 73 | 74 | group = DefineGroup('extlib', src, depend = [''], CPPPATH=path,LIBS=LIBS, LIBPATH=LIBPATH, LINKFLAGS=LINKFLAGS) 75 | 76 | Return('group') 77 | -------------------------------------------------------------------------------- /firmware/Libraries/extlib/inc/advapi/FHAdv_audio_cap.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file FHAdv_audio_cap.h 3 | * @brief FHAdv audio capture module interface 4 | * @version V1.0.0 5 | * @date 11-May-2016 6 | * @author Software Team 7 | * 8 | * @note 9 | * Copyright (C) 2016 Shanghai Fullhan Microelectronics Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * @par 13 | * Fullhan is supplying this software which provides customers with programming 14 | * information regarding the products. Fullhan has no responsibility or 15 | * liability for the use of the software. Fullhan not guarantee the correctness 16 | * of this software. Fullhan reserves the right to make changes in the software 17 | * without notification. 18 | * 19 | */ 20 | 21 | #ifndef _FHADV_AUDIO_CAP_H 22 | #define _FHADV_AUDIO_CAP_H 23 | 24 | #include "FH_typedef.h" 25 | 26 | /** @addtogroup Audio_Cap Audio Capture 27 | * @{ 28 | */ 29 | 30 | #define FHADV_AUCAP_NOERR FH_SUCCESS 31 | #define FHADV_AUCAP_ENODEV FH_FAILURE 32 | 33 | /** 34 | * @brief Current frame information returned by audio capture engine 35 | */ 36 | typedef struct 37 | { 38 | FH_UINT64 ts; /*!< capture time stamp */ 39 | } FHADV_AUCAP_FRM_INFO_t; 40 | 41 | /** 42 | * @brief Get one audio frame callback function 43 | * 44 | * This function will be called after one audio frame captured. 45 | * 46 | * @param[in] info Pointer of frame information structure 47 | * @param[in] data Pointer of stream buffer 48 | * @param[in] len The length of stream buffer in bytes 49 | * @return NULL 50 | */ 51 | typedef void (*FHAdv_Aucap_GetFrame_cb)(const FHADV_AUCAP_FRM_INFO_t *info, const FH_ADDR data, const FH_SINT32 len); 52 | 53 | /** 54 | * @brief Audio Sample rate 55 | */ 56 | typedef enum { 57 | FHADV_AUCAP_8000 = 8000, /*!< 8kHz */ 58 | FHADV_AUCAP_16000 = 16000, /*!< 16kHz */ 59 | FHADV_AUCAP_44100 = 44100, /*!< 44.1kHz */ 60 | FHADV_AUCAP_48000 = 48000, /*!< 48kHz */ 61 | } FHADV_AUCAP_SAMPLERATE; 62 | 63 | /** 64 | * @brief Sample bit depth 65 | */ 66 | typedef enum { 67 | FHADV_AUCAP_8BIT = 8, /*!< 8 bits per sample */ 68 | FHADV_AUCAP_16BIT = 16, /*!< 16 bits per sample */ 69 | } FHADV_AUCAP_BITDEPTH; 70 | 71 | /** 72 | * @brief Input source 73 | */ 74 | typedef enum { 75 | FHADV_AUCAP_MIC_IN = 0, 76 | FHADV_AUCAP_LINE_IN = 1, 77 | } FHADV_AUCAP_INPUT_INTERFACE; 78 | 79 | /** 80 | * @brief Audio Capture Configure 81 | */ 82 | typedef struct 83 | { 84 | FHADV_AUCAP_SAMPLERATE sample_rate; /*!< sample rate */ 85 | FHADV_AUCAP_BITDEPTH bit_depth; /*!< sample bit depth */ 86 | FH_SINT32 volume; /*!< capture volume 0~100, (-1) using default value */ 87 | FHAdv_Aucap_GetFrame_cb cb; /*!< get audio frame callback */ 88 | FHADV_AUCAP_INPUT_INTERFACE input_if; /*!< input source type */ 89 | } FHADV_AUCAP_CONFIG_t; 90 | 91 | /** 92 | * @brief Audio Capture engine Open 93 | * 94 | * The configuration can only be set once. Changing configuration such as 95 | * sample_rate dynamically is not supported. 96 | * This function will fail when it is called at the second time. 97 | * 98 | * @param[in] pConfig Pointer of Audio Capture Configure 99 | * @return -errno 100 | */ 101 | FH_SINT32 FHAdv_Aucap_Open(FHADV_AUCAP_CONFIG_t *pConfig); 102 | 103 | /** 104 | * @brief Audio Capture engine Close 105 | * 106 | * @return -errno 107 | */ 108 | FH_SINT32 FHAdv_Aucap_Close(void); 109 | 110 | /** 111 | * @brief Activate audio capture engine, callback will be triggered periodically 112 | * 113 | * @return -errno 114 | */ 115 | FH_SINT32 FHAdv_Aucap_Start(void); 116 | 117 | /** 118 | * @brief Deactivate audio capture engine 119 | * 120 | * @return -errno 121 | */ 122 | FH_SINT32 FHAdv_Aucap_Stop(void); 123 | 124 | /** 125 | * @brief Set audio capture volume 126 | * 127 | * @param[in] vol Volume for audio capture, range [0,100] 128 | * @return -errno 129 | */ 130 | FH_SINT32 FHAdv_Aucap_SetVolume(FH_SINT32 vol); 131 | 132 | /** 133 | * @brief Turn on/off AEC ( Acoustic Echo Canceller ) 134 | * 135 | * @param[in] enable 1: turn on, 0: turn off 136 | * @return -errno 137 | * @retval FHADV_AUCAP_NOERR Setting success 138 | * @retval -FHADV_AUCAP_ENODEV AEC not support 139 | */ 140 | FH_SINT32 FHAdv_Aucap_AecEnable(FH_SINT32 enable); 141 | 142 | /*@} end of group Audio_Cap */ 143 | 144 | #endif 145 | -------------------------------------------------------------------------------- /firmware/Libraries/extlib/inc/advapi/FHAdv_audio_play.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file FHAdv_audio_play.h 3 | * @brief FHAdv audio play module interface 4 | * @version V1.0.0 5 | * @date 11-May-2016 6 | * @author Software Team 7 | * 8 | * @note 9 | * Copyright (C) 2016 Shanghai Fullhan Microelectronics Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * @par 13 | * Fullhan is supplying this software which provides customers with programming 14 | * information regarding the products. Fullhan has no responsibility or 15 | * liability for the use of the software. Fullhan not guarantee the correctness 16 | * of this software. Fullhan reserves the right to make changes in the software 17 | * without notification. 18 | * 19 | */ 20 | 21 | #ifndef _FHADV_AUDIO_PLAY_H 22 | #define _FHADV_AUDIO_PLAY_H 23 | 24 | #include "FH_typedef.h" 25 | 26 | /** @addtogroup Audio_Play Audio Play 27 | * @{ 28 | */ 29 | 30 | /** 31 | * @brief Audio Sample rate for play engine 32 | */ 33 | typedef enum { 34 | FHADV_AUPLY_8000 = 8000, /*!< 8kHz */ 35 | FHADV_AUPLY_16000 = 16000, /*!< 16kHz */ 36 | FHADV_AUPLY_44100 = 44100, /*!< 44.1kHz */ 37 | FHADV_AUPLY_48000 = 48000, /*!< 48kHz */ 38 | } FHADV_AUPLY_SAMPLERATE; 39 | 40 | /** 41 | * @brief Sample bit depth for play engine 42 | */ 43 | typedef enum { 44 | FHADV_AUPLY_8BIT = 8, /*!< 8 bits per sample */ 45 | FHADV_AUPLY_16BIT = 16, /*!< 16 bits per sample */ 46 | } FHADV_AUPLY_BITDEPTH; 47 | 48 | /** 49 | * @brief Output source 50 | */ 51 | typedef enum { 52 | FHADV_AUPLY_SPK_OUT = 2, 53 | FHADV_AUPLY_LINE_OUT = 3, 54 | } FHADV_AUCAP_OUTPUT_INTERFACE; 55 | 56 | /** 57 | * @brief Audio Play Configure 58 | */ 59 | typedef struct 60 | { 61 | FHADV_AUPLY_SAMPLERATE sample_rate; /*!< sample rate */ 62 | FHADV_AUPLY_BITDEPTH bit_depth; /*!< sample bit depth */ 63 | FH_SINT32 volume; /*!< play volume 0~100, (-1) using default value */ 64 | FHADV_AUCAP_OUTPUT_INTERFACE output_if; /*!< output interface type */ 65 | } FHADV_AUPLY_CONFIG_t; 66 | 67 | /** 68 | * @brief Audio Play engine Open 69 | * 70 | * The configuration can only be set once. Changing configuration such as 71 | * sample_rate dynamically is not supported. 72 | * This function will fail when it is called at the second time. 73 | * 74 | * @param[in] pConfig Pointer of Audio Play Configure 75 | * @return -errno 76 | */ 77 | FH_SINT32 FHAdv_Auply_Open(FHADV_AUPLY_CONFIG_t *pConfig); 78 | 79 | /** 80 | * @brief Audio Play engine Close 81 | * 82 | * @return -errno 83 | */ 84 | FH_SINT32 FHAdv_Auply_Close(void); 85 | 86 | /** 87 | * @brief Play audio data 88 | * 89 | * This function works on BLOCKING mode, i.e. the function will not 90 | * returned until all the data have been moved to playback buffer. 91 | * And the function will be called again, to transfer next slice of 92 | * data.\n 93 | * The PCM data format is needed. For 16bit data, sample is stored 94 | * in little-endian.\n 95 | * The time interval of TWO calls of this function should NOT exceed 96 | * 500ms for continuous playing. 97 | * 98 | * @param[in] data audio buffer pointer 99 | * @param[in] len audio buffer length 100 | * @return -errno 101 | */ 102 | FH_SINT32 FHAdv_Auply_Play(FH_ADDR data, FH_SINT32 len); 103 | 104 | /** 105 | * @brief Set audio play volume 106 | * 107 | * @param[in] vol Volume for audio play, range [0,100] 108 | * @return -errno 109 | */ 110 | FH_SINT32 FHAdv_Auply_SetVolume(FH_SINT32 vol); 111 | 112 | /*@} end of group Audio_Play */ 113 | 114 | #endif 115 | -------------------------------------------------------------------------------- /firmware/Libraries/extlib/inc/advapi/FH_typedef.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file FH_typedef.h 3 | * @brief FHAdv video capture module interface 4 | * @version V1.0.0 5 | * @date 12-May-2016 6 | * @author Software Team 7 | * 8 | * @note 9 | * Copyright (C) 2016 Shanghai Fullhan Microelectronics Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * @par 13 | * Fullhan is supplying this software which provides customers with programming 14 | * information regarding the products. Fullhan has no responsibility or 15 | * liability for the use of the software. Fullhan not guarantee the correctness 16 | * of this software. Fullhan reserves the right to make changes in the software 17 | * without notification. 18 | * 19 | */ 20 | 21 | #ifndef __FH_TYPEDEF_H__ 22 | #define __FH_TYPEDEF_H__ 23 | #ifndef __TYPE_DEF_H__ 24 | 25 | #ifdef __cplusplus 26 | #if __cplusplus 27 | extern "C" { 28 | #endif 29 | #endif /* __cplusplus */ 30 | 31 | typedef unsigned long long FH_UINT64; 32 | typedef long long FH_SINT64; 33 | typedef unsigned int FH_UINT32; 34 | typedef int FH_SINT32; 35 | typedef unsigned short FH_UINT16; 36 | typedef short FH_SINT16; 37 | typedef unsigned char FH_UINT8; 38 | typedef char FH_SINT8; 39 | typedef FH_UINT8* FH_ADDR; 40 | 41 | typedef char FH_CHAR; 42 | typedef void FH_VOID; 43 | 44 | typedef enum { 45 | FH_FALSE = 0, 46 | FH_TRUE = 1, 47 | DUMMY = 0xffffffff, 48 | } FH_BOOL; 49 | 50 | #define FH_NULL 0L 51 | #define FH_SUCCESS 0 52 | #define FH_FAILURE (-1) 53 | 54 | #define INT_MINI (-2147483647 - 1) /*!< minimum (signed) int value */ 55 | #define INT_MAXI 2147483647 /*!< maximum (signed) int value */ 56 | 57 | #ifdef __cplusplus 58 | #if __cplusplus 59 | } 60 | #endif 61 | #endif /* __cplusplus */ 62 | 63 | #endif 64 | #endif /* __TYPE_DEF_H__ */ 65 | -------------------------------------------------------------------------------- /firmware/Libraries/extlib/inc/di/debug_interface.h: -------------------------------------------------------------------------------- 1 | #ifndef DEBUG_INTERFACE_H_ 2 | #define DEBUG_INTERFACE_H_ 3 | 4 | typedef int (*dbi_send)(void *obj, unsigned char *buf, int size); 5 | typedef int (*dbi_recv)(void *obj, unsigned char *buf, int size); 6 | 7 | typedef struct DI_config 8 | { 9 | void *obj; 10 | dbi_send send; 11 | dbi_recv recv; 12 | 13 | } DI_config; 14 | 15 | struct Debug_Interface; 16 | 17 | int DI_handle(struct Debug_Interface *di); 18 | 19 | int DI_destroy(struct Debug_Interface *di); 20 | 21 | /* object create */ 22 | struct Debug_Interface *DI_create(struct DI_config *cfg); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /firmware/Libraries/extlib/inc/dsp/fh_common.h: -------------------------------------------------------------------------------- 1 | #ifndef __FH_COMMON_H__ 2 | #define __FH_COMMON_H__ 3 | #include "types/type_def.h" 4 | 5 | #ifdef __cplusplus 6 | #if __cplusplus 7 | extern "C" { 8 | #endif 9 | #endif /* __cplusplus */ 10 | 11 | //#define API_PRT 12 | #ifdef API_PRT 13 | #define API_DEBUG(...) \ 14 | do \ 15 | { \ 16 | printf("%s %d: ", __func__, __LINE__); \ 17 | printf(__VA_ARGS__); \ 18 | } while (0) 19 | #else 20 | #define API_DEBUG(...) 21 | #endif 22 | 23 | #define VPU_CHN_COUNT 4 24 | #define PAE_CHN_COUNT 8 25 | #define PAE_MAX_NALU_CNT 20 26 | #define MAX_OSD_LINE 3 27 | #define MAX_INVERT_CNT 8 28 | 29 | #define RETURN_NULL (0) 30 | #define RETURN_OK (0) 31 | #define NO_DEVICE (-1) 32 | #define OPEN_DEVICE_ERR (-1) 33 | #define CLOSE_DEVICE_ERR (-2) 34 | #define FIND_DEVICE_ERR (-3) 35 | #define PARAM_NULL (-4) 36 | #define PARAM_ERR (-5) 37 | #define ALIGN_ERR (-6) 38 | #define MODULE_ENABLE_ERR (-7) 39 | #define CHAN_ERR (-8) 40 | #define MEM_NULL (-9) 41 | #define GET_STREAM_EMPTY (-10) 42 | 43 | #define MAX_MASK_AREA (8) 44 | #define MIN_PITCH_ALIGN (8) 45 | #define DEFALT_ALIGN (8) 46 | #define MAX_VPU_CHANNO (4) 47 | #define MAX_ENC_CHANNO (8) 48 | 49 | #define MOU_ENABLE (1) 50 | #define MOU_UNABLE (0) 51 | 52 | #define MALLOCED_MEM_BASE_DSP (1) 53 | #define MALLOCED_MEM_VPUPKG (0) 54 | 55 | typedef struct fhVERSION_INFO_ 56 | { 57 | FH_UINT32 build_date; /**<构建号*/ 58 | FH_UINT32 sw_version; /**<软件版本号*/ 59 | FH_UINT32 hw_version; /**<硬件驱动版本号*/ 60 | } FH_VERSION_INFO; 61 | 62 | typedef struct fhPOINT_ 63 | { 64 | FH_UINT32 u32X; /**< 水平坐标 */ 65 | FH_UINT32 u32Y; /**< 垂直坐标 */ 66 | } FH_POINT; 67 | 68 | typedef struct fhSIZE_S 69 | { 70 | FH_UINT32 u32Width; /**< 宽度像素 */ 71 | FH_UINT32 u32Height; /**<高度像素 */ 72 | } FH_SIZE; 73 | 74 | typedef struct fhRECT_S 75 | { 76 | FH_UINT32 u32X; /**< 起始点水平坐标 */ 77 | FH_UINT32 u32Y; /**< 起始点垂直坐标*/ 78 | FH_UINT32 u32Width; /**< 区域宽度*/ 79 | FH_UINT32 u32Height; /**< 区域高度 */ 80 | } FH_AREA; 81 | 82 | typedef struct 83 | { 84 | FH_ADDR addr; 85 | FH_UINT32 size; 86 | } FH_ADDR_INFO; 87 | 88 | typedef struct 89 | { 90 | unsigned int base; /**< 物理地址 */ 91 | void* vbase; /**< 虚拟地址 */ 92 | unsigned int size; /**< 内存大小 */ 93 | } FH_MEM_INFO; 94 | 95 | typedef struct 96 | { 97 | FH_UINT16 frame_count; /**< 帧数 */ 98 | FH_UINT16 frame_time; /**< 统计时间 (s)*/ 99 | } FH_FRAMERATE; 100 | 101 | typedef struct 102 | { 103 | FH_UINT32 y; 104 | FH_UINT32 cb; 105 | FH_UINT32 cr; 106 | FH_UINT32 alpha; 107 | } FH_YC_COLOR; 108 | 109 | typedef enum { 110 | FH_RO_OPS_0 = 0, 111 | FH_RO_OPS_90 = 1, 112 | FH_RO_OPS_180 = 2, 113 | FH_RO_OPS_270 = 3, 114 | } FH_ROTATE_OPS; 115 | 116 | #ifdef __cplusplus 117 | #if __cplusplus 118 | } 119 | #endif 120 | #endif /* __cplusplus */ 121 | 122 | #endif /* _FH_COMMON_H_ */ 123 | -------------------------------------------------------------------------------- /firmware/Libraries/extlib/inc/dsp/fh_jpeg_mpi.h: -------------------------------------------------------------------------------- 1 | #ifndef __FH_JPEG_MPI_H__ 2 | #define __FH_JPEG_MPI_H__ 3 | 4 | #include "types/type_def.h" 5 | #include "fh_common.h" 6 | #include "fh_jpeg_mpipara.h" 7 | 8 | #ifdef __cplusplus 9 | #if __cplusplus 10 | extern "C" { 11 | #endif 12 | #endif /* __cplusplus */ 13 | 14 | /** 15 | * FH_JPEG_InitMem 16 | *@brief 配置JPEG模块需要的内存 17 | *@param [in] Jpegwidth:JPEG编码的宽度。 18 | *@param [in] Jpeghight:JPEG编码的高度。 19 | *@param [out] 无 20 | *@return 是否成功 21 | * - RETURN_OK(0): 成功 22 | * - 其他:失败,错误详见错误号 23 | */ 24 | FH_SINT32 FH_JPEG_InitMem(FH_UINT32 Jpegwidth, FH_UINT32 Jpeghight); 25 | 26 | /** 27 | * FH_JPEG_Setconfig 28 | *@brief 设置JPEG配置参数 29 | *@param [in] pstJpegconfig JPEG编码配置参数 30 | *@param [out] 无 31 | *@return 是否成功 32 | * - RETURN_OK(0): 成功 33 | * - 其他:失败,错误详见错误号 34 | */ 35 | FH_SINT32 FH_JPEG_Setconfig(const FH_JPEG_CONFIG *pstJpegconfig); 36 | 37 | /** 38 | * FH_JPEG_Getconfig 39 | *@brief 获取JPEG配置参数 40 | *@param [in] 无 41 | *@param [out] pstJpegconfig:JPEG编码配置参数 42 | *@return 是否成功 43 | * - RETURN_OK(0): 成功 44 | * - 其他:失败,错误详见错误号 45 | */ 46 | FH_SINT32 FH_JPEG_Getconfig(FH_JPEG_CONFIG *pstJpegconfig); 47 | 48 | /** 49 | * FH_JPEG_Setqp 50 | *@brief 设置JPEG编码的QP值,动态调整。 51 | *@param [in] QP JPEG编码的QP值 52 | *@param [out] 无 53 | *@return 是否成功 54 | * - RETURN_OK(0): 成功 55 | * - 其他:失败,错误详见错误号 56 | */ 57 | FH_SINT32 FH_JPEG_Setqp(FH_UINT32 QP); 58 | 59 | /** 60 | * FH_JPEG_Getqp 61 | *@brief 获取JPEG编码的QP值。 62 | *@param [in] 无 63 | *@param [out] QP JPEG编码的QP值 64 | *@return 是否成功 65 | * - RETURN_OK(0): 成功 66 | * - 其他:失败,错误详见错误号 67 | */ 68 | FH_SINT32 FH_JPEG_Getqp(FH_UINT32 *QP); 69 | 70 | /** 71 | * FH_JPEG_Setstream 72 | *@brief 用户手动提交一帧图像给JPEG编码 73 | *@param [in] pstJpegframe 编码的码流信息 74 | *@param [out] 无 75 | *@return 是否成功 76 | * - RETURN_OK(0): 成功 77 | * - 其他:失败,错误详见错误号 78 | */ 79 | FH_SINT32 FH_JPEG_Setstream(const FH_JPEG_FRAME_INFO *pstJpegframe); 80 | 81 | /** 82 | * FH_JPEG_Getstream 83 | *@brief 获取JPEG编码的码流信息,非阻塞,只有一帧的buf,需要在图像完全取走后,才可以启动下一帧编码。 84 | *@param [in] 无 85 | *@param [out] pstJpegconfig 编码的码流信息 86 | *@return 是否成功 87 | * - RETURN_OK(0): 成功 88 | * - 其他:失败,错误详见错误号 89 | */ 90 | FH_SINT32 FH_JPEG_Getstream(FH_JPEG_STREAM_INFO *pstJpegframe); 91 | 92 | /** 93 | * FH_JPEG_Getstream_Block 94 | *@brief 获取JPEG编码的码流信息,阻塞方式,只有一帧的buf,需要在图像完全取走后,才可以启动下一帧编码。 95 | *@param [in] 无 96 | *@param [out] pstJpegconfig 编码的码流信息 97 | *@return 是否成功 98 | * - RETURN_OK(0): 成功 99 | * - 其他:失败,错误详见错误号 100 | */ 101 | FH_SINT32 FH_JPEG_Getstream_Block(FH_JPEG_STREAM_INFO *pstJpegframe); 102 | 103 | /** 104 | * fh_jpeg_init 105 | *@brief JPEG驱动初始化,供内部调用,用户无需显性调用 106 | *@param [in] 无 107 | *@param [out] 无 108 | *@return 是否成功 109 | * - RETURN_OK(0): 成功 110 | * - 其他:失败,错误详见错误号 111 | */ 112 | FH_SINT32 fh_jpeg_init(); 113 | 114 | /** 115 | * fh_jpeg_close 116 | *@brief JPEG驱动初始化,供内部调用,用户无需显性调用 117 | *@param [in] 无 118 | *@param [out] 无 119 | *@return 是否成功 120 | * - RETURN_OK(0): 成功 121 | * - 其他:失败,错误详见错误号 122 | */ 123 | FH_SINT32 fh_jpeg_close(); 124 | 125 | #ifdef __cplusplus 126 | #if __cplusplus 127 | } 128 | #endif 129 | #endif /* __cplusplus */ 130 | #endif /*__MPI_VO_H__ */ 131 | -------------------------------------------------------------------------------- /firmware/Libraries/extlib/inc/dsp/fh_jpeg_mpipara.h: -------------------------------------------------------------------------------- 1 | #ifndef __FH_JPEG_MPIPARA_H__ 2 | #define __FH_JPEG_MPIPARA_H__ 3 | 4 | #include "types/type_def.h" 5 | #include "fh_common.h" 6 | 7 | #ifdef __cplusplus 8 | #if __cplusplus 9 | } 10 | #endif 11 | #endif /* __cplusplus */ 12 | 13 | typedef struct 14 | { 15 | FH_SINT32 QP; // 0-98 16 | FH_SINT32 rate; // JPEG 完成速度控制 28bit 17 | FH_ROTATE_OPS rotate; 18 | } FH_JPEG_CONFIG; 19 | 20 | typedef struct 21 | { 22 | FH_SINT32 frame_id; 23 | FH_ADDR YADDR; 24 | FH_ADDR CADDR; 25 | FH_SIZE jpeg_size; 26 | } FH_JPEG_FRAME_INFO; 27 | 28 | typedef struct 29 | { 30 | FH_SINT32 frame_id; 31 | FH_SIZE size; 32 | FH_ADDR_INFO stream; 33 | } FH_JPEG_STREAM_INFO; 34 | 35 | #ifdef __cplusplus 36 | #if __cplusplus 37 | } 38 | #endif 39 | #endif /* __cplusplus */ 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /firmware/Libraries/extlib/inc/dsp/fh_system_mpi.h: -------------------------------------------------------------------------------- 1 | #ifndef __FH_SYSTEM_MPI_H__ 2 | #define __FH_SYSTEM_MPI_H__ 3 | 4 | #include "types/type_def.h" 5 | #include "fh_common.h" 6 | 7 | #ifdef __cplusplus 8 | #if __cplusplus 9 | extern "C" { 10 | #endif 11 | #endif /* __cplusplus */ 12 | 13 | /** 14 | * FH_SYS_Init 15 | *@brief DSP 系统初始化,完成打开驱动设备及分配系统内存 16 | *@param [in] 无 17 | *@param [out] 无 18 | *@return 是否成功 19 | * - RETURN_OK(0): 成功 20 | * - 其他:失败,错误详见错误号 21 | */ 22 | FH_SINT32 FH_SYS_Init(); 23 | 24 | /** 25 | * FH_SYS_Exit 26 | *@brief DSP 系统退出 27 | *@param [in] 无 28 | *@param [out] 无 29 | *@return 是否成功 30 | * - RETURN_OK(0): 成功 31 | * - 其他:失败,错误详见错误号 32 | */ 33 | FH_SINT32 FH_SYS_Exit(); 34 | 35 | /** 36 | * FH_SYS_BindVpu2Enc 37 | *@brief 数据源绑定到H264编码通道 38 | *@param [in] srcchn(VPU 通道),取值为0 - 2 39 | *@param [in] dstschn(ENC 通道),取值为0 - 7 40 | *@param [out] 无 41 | *@return 是否成功 42 | * - RETURN_OK(0): 成功 43 | * - 其他:失败,错误详见错误号 44 | */ 45 | FH_SINT32 FH_SYS_BindVpu2Enc(FH_UINT32 srcchn, FH_UINT32 dstschn); 46 | 47 | /** 48 | * FH_SYS_BindVpu2Vou 49 | *@brief 数据源绑定到显示通道 50 | *@param [in] 无 51 | *@param [out] 无 52 | *@return 是否成功 53 | * - RETURN_OK(0): 成功 54 | * - 其他:失败,错误详见错误号 55 | */ 56 | FH_SINT32 FH_SYS_BindVpu2Vou(); 57 | 58 | /** 59 | * FH_SYS_BindVpu2Jpeg 60 | *@brief 数据源绑定JPEG编码通道。 61 | *@param [in] srcchn(VPU 通道),取值为0 - 2 62 | *@param [out] 无 63 | *@return 是否成功 64 | * - RETURN_OK(0): 成功 65 | * - 其他:失败,错误详见错误号 66 | */ 67 | FH_SINT32 FH_SYS_BindVpu2Jpeg(FH_UINT32 srcchn); 68 | 69 | /** 70 | * FH_SYS_GetBindbyDest 71 | *@brief 获取H264编码通道的绑定对象 72 | *@param [in] dstschn(ENC 通道),取值为0 - 7 73 | *@param [out] srcchn(VPU 通道),取值为0 - 2 74 | *@return 是否成功 75 | * - RETURN_OK(0): 成功 76 | * - 其他:失败,错误详见错误号 77 | */ 78 | FH_SINT32 FH_SYS_GetBindbyDest(FH_UINT32 *srcchn, FH_UINT32 dstschn); 79 | 80 | /** 81 | * FH_SYS_UnBindbySrc 82 | *@brief 解除数据绑定关系 83 | *@param [in] srcchn(VPU 通道),取值为0 - 2 84 | *@param [out] 无 85 | *@return 是否成功 86 | * - RETURN_OK(0): 成功 87 | * - 其他:失败,错误详见错误号 88 | */ 89 | FH_SINT32 FH_SYS_UnBindbySrc(FH_UINT32 srcchn); 90 | 91 | /** 92 | * FH_SYS_GetVersion 93 | *@brief 获取DSP驱动版本信息 94 | *@param [in] 无 95 | *@param [out] pstSystemversion 版本信息 96 | *@return 是否成功 97 | * - RETURN_OK(0): 成功 98 | * - 其他:失败,错误详见错误号 99 | */ 100 | FH_SINT32 FH_SYS_GetVersion(FH_VERSION_INFO *pstSystemversion); 101 | 102 | /** 103 | * FH_SYS_SetReg 104 | *@brief 设置寄存器值 105 | *@param [in] addr 寄存器物理地址 106 | *@param [in] value 设置寄存器值 107 | *@param [out] 无 108 | *@return 是否成功 109 | * - RETURN_OK(0): 成功 110 | * - 其他:失败,错误详见错误号 111 | */ 112 | FH_SINT32 FH_SYS_SetReg(FH_UINT32 addr, FH_UINT32 value); 113 | 114 | /** 115 | * FH_SYS_GetReg 116 | *@brief 获取寄存器的值 117 | *@param [in] u32Addr 寄存器物理地址 118 | *@param [out] pu32Value 寄存器的值 119 | *@return 是否成功 120 | * - RETURN_OK(0): 成功 121 | * - 其他:失败,错误详见错误号 122 | */ 123 | FH_SINT32 FH_SYS_GetReg(FH_UINT32 u32Addr, FH_UINT32 *pu32Value); 124 | 125 | #ifdef __cplusplus 126 | #if __cplusplus 127 | } 128 | #endif 129 | #endif /* __cplusplus */ 130 | #endif /*__MPI_VO_H__ */ 131 | -------------------------------------------------------------------------------- /firmware/Libraries/extlib/inc/dsp/fh_venc_mpipara.h: -------------------------------------------------------------------------------- 1 | #ifndef __FH_VENC_MPIPARA_H__ 2 | #define __FH_VENC_MPIPARA_H__ 3 | 4 | #include "types/type_def.h" 5 | #include "fh_common.h" 6 | 7 | #ifdef __cplusplus 8 | #if __cplusplus 9 | extern "C" { 10 | #endif 11 | #endif /* __cplusplus */ 12 | 13 | typedef struct 14 | { 15 | FH_ADDR lumma_addr; 16 | FH_ADDR chroma_addr; 17 | FH_UINT64 time_stamp; 18 | FH_SIZE size; 19 | } FH_ENC_FRAME; 20 | 21 | typedef enum { 22 | FH_PRO_BASELINE = 66, /**< baseline */ 23 | FH_PRO_MAIN = 77, /**< main profile */ 24 | } FH_ENC_PROFILE_IDC; 25 | 26 | typedef struct 27 | { 28 | FH_BOOL chn_en; 29 | FH_ENC_PROFILE_IDC profile; 30 | FH_UINT32 i_frame_intterval; 31 | FH_SIZE size; 32 | } FH_ENC_CHN_ATTR; 33 | 34 | typedef enum { 35 | FH_RC_VBR = 0, 36 | FH_RC_CBR = 1, 37 | FH_RC_FIXEQP = 2, 38 | } FH_ENC_RC_MODE; 39 | 40 | typedef enum { 41 | FH_RC_VERYLOW = 0, 42 | FH_RC_LOW = 1, 43 | FH_RC_MIDDLE = 2, 44 | FH_RC_HIGH = 3, 45 | } FH_ENC_RC_LEVEL; 46 | 47 | typedef struct 48 | { 49 | FH_ENC_RC_MODE RCmode; 50 | FH_ENC_RC_LEVEL RClevel; 51 | FH_UINT32 bitrate; 52 | FH_UINT32 IminQP; 53 | FH_UINT32 ImaxQP; 54 | FH_UINT32 PminQP; 55 | FH_UINT32 PmaxQP; 56 | FH_UINT32 max_delay; //(1-60) 57 | FH_FRAMERATE FrameRate; //输出帧率 58 | } FH_RC_CONFIG; 59 | 60 | typedef struct 61 | { 62 | unsigned int I_proportion; 63 | unsigned int P_proportion; 64 | } FH_RC_I_DIV_P; 65 | 66 | typedef struct 67 | { 68 | FH_UINT32 init_qp; 69 | FH_ENC_CHN_ATTR chn_attr; 70 | FH_RC_CONFIG rc_config; 71 | } FH_CHR_CONFIG; 72 | 73 | typedef struct 74 | { 75 | FH_UINT32 totalfrmcnt; /**< 总共完成编码帧数*/ 76 | FH_UINT32 totalstreamcnt; /**< 所有输出队列中待获取的帧数*/ 77 | } FH_SYS_STATUS; 78 | 79 | typedef struct 80 | { 81 | FH_UINT32 lastqp; 82 | FH_UINT32 bps; 83 | FH_UINT32 FrameToEnc; //待编码帧数 84 | FH_UINT32 framecnt; //已编码帧数 85 | FH_UINT32 streamcnt; //输出队列中的帧数 86 | } FH_CHN_STATUS; 87 | 88 | typedef enum { 89 | NALU_P_SLICE = 0, 90 | NALU_I_SLICE = 2, 91 | NALU_IDR = 5, 92 | NALU_SEI = 6, 93 | NALU_SPS = 7, 94 | NALU_PPS = 8, 95 | NALU_AUD = 9, 96 | } FH_ENC_NALU_TYPE; 97 | 98 | typedef struct 99 | { 100 | FH_ENC_NALU_TYPE type; 101 | FH_UINT32 length; 102 | FH_UINT8 *start; 103 | } FH_ENC_STREAM_NALU; 104 | 105 | typedef enum { 106 | P_SLICE = 0, 107 | I_SLICE = 2, 108 | } FH_ENC_SLICE_TYPE; 109 | 110 | typedef struct 111 | { 112 | FH_UINT32 chan; 113 | FH_ADDR start; 114 | FH_ENC_SLICE_TYPE frame_type; 115 | FH_UINT32 length; 116 | FH_UINT64 time_stamp; 117 | FH_UINT32 nalu_cnt; 118 | FH_ENC_STREAM_NALU nalu[PAE_MAX_NALU_CNT]; 119 | } FH_ENC_STREAM_ELEMENT; 120 | 121 | typedef struct 122 | { 123 | FH_UINT8 *base; 124 | FH_UINT32 size; 125 | } FH_ENC_MEM; 126 | 127 | typedef struct 128 | { 129 | FH_BOOL water_enable; 130 | FH_ENC_MEM water_info; 131 | } FH_WATER_INFO; 132 | 133 | typedef struct 134 | { 135 | FH_UINT32 enable; 136 | FH_ROTATE_OPS rotate; 137 | } FH_ROTATE; 138 | 139 | typedef enum { FH_ROI_L0 = 0, FH_ROI_L1 = 1, FH_ROI_L2 = 2, FH_ROI_L3 = 3 } FH_ROI_LEVEL; 140 | 141 | typedef struct 142 | { 143 | FH_UINT32 enable; 144 | FH_UINT32 qp; 145 | FH_AREA area; 146 | FH_ROI_LEVEL level; 147 | } FH_ROI; 148 | 149 | typedef enum { 150 | FH_REF_MODE_1X = 0, 151 | FH_REF_MODE_2X = 1, 152 | FH_REF_MODE_4X = 2, 153 | } FH_REF_MODE_OPS; 154 | 155 | typedef enum { 156 | FH_CAVLC = 0, 157 | FH_CABAC = 1, 158 | } FH_ENTROPY_MODE; 159 | 160 | typedef enum { 161 | FH_IDC_0 = 0, 162 | FH_IDC_1 = 1, 163 | FH_IDC_2 = 2, 164 | } FH_CACBC_INIT_IDC; 165 | 166 | typedef struct 167 | { 168 | FH_ENTROPY_MODE entropy_coding_mode; 169 | FH_CACBC_INIT_IDC cabac_init_idc; 170 | } FH_ENTROPY_OPS; 171 | 172 | typedef struct 173 | { 174 | FH_UINT32 deblocking_filter; // 0,1 175 | FH_UINT32 disable_deblocking; // 0,1,2 176 | FH_UINT32 slice_alpha; //-6~+6 : S4 177 | FH_UINT32 slice_beta; //-6~+6 : S4 178 | } FH_DEBLOCKING_FILTER_PARAM; 179 | 180 | typedef enum { 181 | FH_NONE = 0, 182 | FH_LUMMA = 1, 183 | FH_CHORMA = 2, 184 | FH_Y_C = 3, 185 | } FH_INTERMBSCE_OPS; 186 | 187 | typedef struct 188 | { 189 | FH_UINT32 enable; 190 | FH_UINT32 slicesplit; 191 | } FH_SLICE_SPLIT; 192 | 193 | typedef struct 194 | { 195 | FH_MEM_INFO mem_info; 196 | FH_UINT32 user_w; 197 | FH_UINT32 user_h; 198 | } FH_ENC_CHN_INFO; 199 | 200 | #ifdef __cplusplus 201 | #if __cplusplus 202 | } 203 | #endif 204 | #endif /* __cplusplus */ 205 | 206 | #endif 207 | -------------------------------------------------------------------------------- /firmware/Libraries/extlib/inc/dsp/fh_vou_mpi.h: -------------------------------------------------------------------------------- 1 | #ifndef __FH_VOU_MPI_H__ 2 | #define __FH_VOU_MPI_H__ 3 | 4 | #include "fh_vou_mpipara.h" 5 | #include "types/type_def.h" 6 | #include "fh_common.h" 7 | 8 | #ifdef __cplusplus 9 | #if __cplusplus 10 | extern "C" { 11 | #endif 12 | #endif /* __cplusplus */ 13 | 14 | /** 15 | * FH_VOU_Enable 16 | *@brief 启用视频输出设备 17 | *@param [in] 无 18 | *@param [out] 无 19 | *@return 是否成功 20 | * - RETURN_OK(0): 成功 21 | * - 其他:失败,错误详见错误号 22 | */ 23 | FH_SINT32 FH_VOU_Enable(); 24 | 25 | /** 26 | * FH_VOU_Disable 27 | *@brief 禁用视频输出设备 28 | *@param [in] 无 29 | *@param [out] 无 30 | *@return 是否成功 31 | * - RETURN_OK(0): 成功 32 | * - 其他:失败,错误详见错误号 33 | */ 34 | FH_SINT32 FH_VOU_Disable(); 35 | 36 | /** 37 | * FH_VOU_SetConfig 38 | *@brief 设置视频输出设备的配置属性。 39 | *@param [in] pstVouconfig:配置参数指针 40 | *@param [out] 无 41 | *@return 是否成功 42 | * - RETURN_OK(0): 成功 43 | * - 其他:失败,错误详见错误号 44 | */ 45 | FH_SINT32 FH_VOU_SetConfig(const FH_VOU_PIC_CONFIG *pstVouconfig); 46 | 47 | /** 48 | * FH_VOU_GetConfig 49 | *@brief 获取视频输出设备的配置属性。 50 | *@param [in] 无 51 | *@param [out] pstVouconfig:配置参数指针 52 | *@return 是否成功 53 | * - RETURN_OK(0): 成功 54 | * - 其他:失败,错误详见错误号 55 | */ 56 | FH_SINT32 FH_VOU_GetConfig(FH_VOU_PIC_SIZE *pstVouconfig); 57 | /** 58 | * FH_VOU_Enable 59 | *@brief 启用视频输出设备 60 | *@param [in] 无 61 | *@param [out] 无 62 | *@return 是否成功 63 | * - RETURN_OK(0): 成功 64 | * - 其他:失败,错误详见错误号 65 | */ 66 | FH_SINT32 FH_VOU_SendFrame(const FH_VOU_PIC_INFO *pstVouframeinfo); 67 | 68 | /** 69 | * fh_vou_init 70 | *@brief 视频显示驱动初始化,供内部调用,用户无需显性调用 71 | *@param [in] 无 72 | *@param [out] 无 73 | *@return 是否成功 74 | * - RETURN_OK(0): 成功 75 | * - 其他:失败,错误详见错误号 76 | */ 77 | FH_SINT32 fh_vou_init(); 78 | 79 | /** 80 | * fh_vou_close 81 | *@brief 视频显示驱动退出,供内部调用,用户无需显性调用 82 | *@param [in] 无 83 | *@param [out] 无 84 | *@return 是否成功 85 | * - RETURN_OK(0): 成功 86 | * - 其他:失败,错误详见错误号 87 | */ 88 | FH_SINT32 fh_vou_close(); 89 | 90 | #ifdef __cplusplus 91 | #if __cplusplus 92 | } 93 | #endif 94 | #endif /* __cplusplus */ 95 | 96 | #endif /*__MPI_VO_H__ */ 97 | -------------------------------------------------------------------------------- /firmware/Libraries/extlib/inc/dsp/fh_vou_mpipara.h: -------------------------------------------------------------------------------- 1 | #ifndef __FH_VOU_MPIPARA_H__ 2 | #define __FH_VOU_MPIPARA_H__ 3 | 4 | #include "types/type_def.h" 5 | #include "fh_common.h" 6 | 7 | #ifdef __cplusplus 8 | #if __cplusplus 9 | extern "C" { 10 | #endif 11 | #endif /* __cplusplus */ 12 | 13 | typedef struct 14 | { 15 | FH_UINT32 mode; /**< 表示VOU 输出模式 PAL制720 = 0 ,NTSC制 = 1,960暂不支持 */ 16 | } FH_VOU_PIC_CONFIG; 17 | 18 | typedef struct 19 | { 20 | FH_SIZE vou_size; 21 | } FH_VOU_PIC_SIZE; 22 | 23 | typedef struct 24 | { 25 | FH_ADDR yaddr; 26 | FH_ADDR caddr; 27 | FH_UINT32 ystride; 28 | FH_UINT32 cstride; 29 | FH_SIZE vou_size; 30 | } FH_VOU_PIC_INFO; 31 | 32 | #ifdef __cplusplus 33 | #if __cplusplus 34 | } 35 | #endif 36 | #endif /* __cplusplus */ 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /firmware/Libraries/extlib/inc/isp/dci_api.h: -------------------------------------------------------------------------------- 1 | #ifndef _DCI_API_H_ 2 | #define _DCI_API_H_ 3 | 4 | enum DCI_CMD 5 | { 6 | DCI_NO_COMMAND = 0, 7 | DCI_SAVE_DRV_REG = 1, 8 | 9 | }; // DCI 命令 10 | enum space_type 11 | { 12 | userspace = 0, 13 | defaultsapce = 1, 14 | }; //存储空间类型 15 | 16 | void DCI_Init(); // DCI 初始化 17 | void DCI_DrvCommand(); // DCI 主循环 读取命令并完成相关操作(设置参数) 18 | int API_DCI_GET_PARAM(unsigned char *cmd, unsigned char *cmd_param, unsigned int *param0, 19 | unsigned int *param1); //读取相关参数 cmd为dci命令,后面均为参数 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /firmware/Libraries/extlib/inc/isp/isp_enum.h: -------------------------------------------------------------------------------- 1 | #ifndef ISP_ENUM_H_ 2 | #define ISP_ENUM_H_ 3 | 4 | #define ISP_WAIT_VD 0 5 | #define ISP_WAIT_FRAME_EDGE 1 6 | #define ISP_PROC_RUN 2 7 | #define ISP_GET_VERSION 3 8 | #define ISP_GET_AE_STAT 4 9 | #define ISP_GET_AWB_STAT 5 10 | 11 | #ifdef __cplusplus 12 | #if __cplusplus 13 | extern "C" { 14 | #endif 15 | #endif /* __cplusplus */ 16 | 17 | enum IPB_LTM_CURVE_TYPE 18 | { 19 | LTM_CURVE_LINEAR, 20 | LTM_CURVE_60DB, 21 | LTM_CURVE_80DB, 22 | LTM_CURVE_100DB, 23 | LTM_CURVE_120DB, 24 | LTM_CURVE_USER01, 25 | LTM_CURVE_USER02, 26 | LTM_CURVE_USER03, 27 | LTM_MANUAL_CURVE = 0xF, 28 | }; 29 | 30 | enum MISC_DATA_COMP 31 | { 32 | MISC_COMP_NONE, 33 | MISC_COMP_LINEAR_12BIT, 34 | MISC_COMP_LINEAR_10BIT, 35 | MISC_COMP_NORMAL, 36 | MISC_COMP_USER, 37 | }; 38 | enum FORMAT 39 | { 40 | 41 | FORMAT_720P25 = 0, 42 | FORMAT_720P30 = 1, 43 | FORMAT_960P25 = 2, 44 | FORMAT_960P30 = 3, 45 | 46 | FORMAT_VGAP25 = 10, 47 | FORMAT_VGAP30 = 11, 48 | // 49 | SENSOR_FORMAT_MAX, 50 | }; 51 | 52 | enum CIS_CLK 53 | { 54 | CIS_CLK_18M, 55 | CIS_CLK_24M, 56 | CIS_CLK_27M, 57 | CIS_CLK_36M, 58 | CIS_CLK_43M2, // 43.2M 59 | CIS_CLK_54M, 60 | CIS_CLK_72M, 61 | CIS_CLK_108M, 62 | }; 63 | 64 | #ifdef __cplusplus 65 | #if __cplusplus 66 | } 67 | #endif 68 | #endif /* __cplusplus */ 69 | 70 | #endif /* ISP_ENUM_IF_H_ */ 71 | -------------------------------------------------------------------------------- /firmware/Libraries/extlib/inc/isp/isp_func_def.h: -------------------------------------------------------------------------------- 1 | #ifndef _ISP_FUNC_DEF_H_ 2 | #define _ISP_FUNC_DEF_H_ 3 | 4 | #define FH_ISP_CORE_ERR_BASE (-1000) 5 | #define FH_API_ERR_BASE (-3000) 6 | 7 | #define FH_RET_OK (0) 8 | 9 | #define FH_ERR_ISP_NOT_INITED (FH_ISP_CORE_ERR_BASE - 5) 10 | #define FH_ERR_WAIT_PICEND_FAILED (FH_ISP_CORE_ERR_BASE - 8) 11 | #define FH_ERR_ISP_RAW_BUFF_NOTENOUGH (FH_ISP_CORE_ERR_BASE - 9) 12 | #define FH_ERR_ISP_SET_CIS_CLK (FH_ISP_CORE_ERR_BASE - 10) 13 | #define FH_ERR_ISP_UNEXPECTED_PIC_SIZE (FH_ISP_CORE_ERR_BSE - 11) 14 | 15 | #define FH_ERR_MEMSIZE_UNDERFLOW (FH_API_ERR_BASE - 1) 16 | #define FH_ERR_NULL_POINTER (FH_API_ERR_BASE - 2) 17 | #define FH_ERR_ISP_INIT (FH_API_ERR_BASE - 3) 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /firmware/Libraries/extlib/inc/isp/isp_sensor_if.h: -------------------------------------------------------------------------------- 1 | #ifndef _ISP_SENSOR_IF_H_ 2 | #define _ISP_SENSOR_IF_H_ 3 | 4 | #include "types/type_def.h" 5 | #include "isp_common.h" 6 | 7 | #ifdef __cplusplus 8 | #if __cplusplus 9 | extern "C" { 10 | #endif 11 | #endif /* __cplusplus */ 12 | 13 | struct Sensor_Resolution_S 14 | { 15 | FH_SINT32 active_height; 16 | FH_SINT32 active_width; 17 | }; 18 | 19 | struct Sensor_Frame_S 20 | { 21 | FH_SINT32 frame_height; 22 | FH_SINT32 frame_width; 23 | }; 24 | 25 | typedef struct _Sensor_Input_Cfg_S 26 | { 27 | struct Sensor_Resolution_S resolution; 28 | struct Sensor_Frame_S frame; 29 | 30 | } SENSOR_INPUT_CFG_S; 31 | 32 | /** 33 | * @brief ISP sensor 接口,每个sensor模块应该使用该接口以便与ISP对接,通过安装sensor, 34 | * 将其加入ISP Core中。 35 | */ 36 | struct isp_sensor_if // module interface 37 | { 38 | FH_SINT8* name; /*!< sensor名称 */ 39 | 40 | /** 41 | * @brief 设置sensor增益 42 | * @param[in] gain sensor的增益,6为小数(0x40 表示 x1.0) 43 | * @return 无 44 | */ 45 | FH_SINT32 (*set_gain)(FH_UINT32 gain); 46 | 47 | /** 48 | * @brief 获取配置幅面信息 49 | * @param[in] 无 50 | * @return 幅面信息 51 | */ 52 | FH_SINT32 (*get_vi_attr)(ISP_VI_ATTR_S* vi_attr); 53 | 54 | /** 55 | * @brief 获取sensor增益 56 | * @param[in] 无 57 | * @return 当前sensor的增益,6为小数(0x40 表示 x1.0) 58 | */ 59 | FH_SINT32 (*get_gain)(FH_UINT32* u32Gain); 60 | 61 | /** 62 | * @brief 设置sensor曝光时间 63 | * @param[in] intt sensor的曝光时间,按行为单位,4为小数(0x10 表示 1.0 * row_time) 64 | * @return 无 65 | */ 66 | FH_SINT32 (*set_intt)(FH_UINT32 intt); 67 | 68 | /** 69 | * @brief 设置sensor框架高度 70 | * @param[in] multiple sensor框架高度的倍数,用于通过降低帧率来增加曝光时间 71 | * @return 无 72 | */ 73 | FH_SINT32 (*set_frame_height)(FH_UINT32 multiple); 74 | 75 | /** 76 | * @brief 获取sensor曝光时间 77 | * @param[in] 无 78 | * @return 当前sensor的曝光时间,按行为单位,4为小数(0x10 表示 1.0 * row_time) 79 | */ 80 | FH_SINT32 (*get_intt)(FH_UINT32* intt); 81 | 82 | /** 83 | * @brief 设置sensor图像的水平翻转和垂直翻转 84 | * @param[in] sensor_en_stat 最低位为flip(vertical)翻转 次低位为mirror(horizontal)翻转 85 | * @return 无 86 | */ 87 | FH_SINT32 (*set_flipmirror)(FH_UINT32 sensor_en_stat); 88 | 89 | /** 90 | * @brief 获取sensor图像的水平翻转和垂直翻转 91 | * @param[out] sensor_en_stat 最低位为flip(vertical)翻转 次低位为mirror(horizontal)翻转 92 | * @return 无 93 | */ 94 | FH_SINT32 (*get_flipmirror)(FH_UINT32* sensor_en_stat); 95 | 96 | /** 97 | * @brief 设置光圈大小 98 | * @param[in] 无 99 | * @return 设置光圈大小 100 | */ 101 | FH_SINT32 (*set_iris)(FH_UINT32 iris); 102 | 103 | /** 104 | * @brief sensor初始化 105 | * @param[in] 无 106 | * @return 无 107 | */ 108 | FH_SINT32 (*init)(FH_VOID); 109 | 110 | /** 111 | * @brief sensor复位 112 | * @param[in] 无 113 | * @return 无 114 | */ 115 | FH_VOID (*reset)(FH_VOID); 116 | 117 | /** 118 | * @brief sensor退出 119 | * @param[in] 无 120 | * @return 无 121 | */ 122 | FH_SINT32 (*deinit)(FH_VOID); 123 | 124 | FH_SINT32 (*set_sns_fmt)(int format); 125 | 126 | FH_SINT32 (*set_sns_reg)(FH_UINT16 addr, FH_UINT16 data); 127 | }; 128 | 129 | struct isp_sensor_if* Sensor_Create(void); 130 | FH_VOID Sensor_Destroy(struct isp_sensor_if* s_if); 131 | 132 | FH_UINT32* GetSensorAwbGain(int idx); 133 | FH_UINT32* GetSensorLtmCurve(int idx); 134 | FH_UINT32* GetDefaultParam(); 135 | FH_UINT32* GetMirrorFlipBayerFormat(); 136 | FH_UINT32* GetMirrorFlipRgbaBayerFormat(); 137 | FH_UINT32* GetContrast(); 138 | FH_UINT32* GetSaturation(); 139 | FH_UINT32* GetSharpness(); 140 | 141 | #ifdef __cplusplus 142 | #if __cplusplus 143 | } 144 | #endif 145 | #endif /* __cplusplus */ 146 | 147 | #endif /* _ISP_SENSOR_H_ */ 148 | -------------------------------------------------------------------------------- /firmware/Libraries/extlib/inc/isp/isp_strategy_if.h: -------------------------------------------------------------------------------- 1 | #ifndef _ISP_STRATEGY_IF_H_ 2 | #define _ISP_STRATEGY_IF_H_ 3 | 4 | #include "types/type_def.h" 5 | 6 | #ifdef __cplusplus 7 | #if __cplusplus 8 | extern "C" { 9 | #endif 10 | #endif /* __cplusplus */ 11 | 12 | /** 13 | * @brief ISP策略模块基类,每个策略模块应该继承该类,并初始化。通过安装策略, 14 | * 将其加入ISP Core中。 15 | */ 16 | struct isp_strategy // module interface 17 | { 18 | FH_SINT8* name; /*!< 策略名称 */ 19 | FH_VOID (*run)(FH_VOID); /*!< 策略运行函数指针 */ 20 | }; 21 | 22 | #ifdef __cplusplus 23 | #if __cplusplus 24 | } 25 | #endif 26 | #endif /* __cplusplus */ 27 | 28 | #endif /* _ISP_STRATEGY_H_ */ 29 | -------------------------------------------------------------------------------- /firmware/Libraries/extlib/inc/types/bufCtrl.h: -------------------------------------------------------------------------------- 1 | #ifndef _BUFCTRL_H_ 2 | #define _BUFCTRL_H_ 3 | #include "dsp/fh_common.h" 4 | 5 | typedef struct fhMEM_DESC_ 6 | { 7 | unsigned int base; 8 | void* vbase; 9 | unsigned int size; 10 | unsigned int align; 11 | } MEM_DESC; 12 | 13 | #define mem_desc fhMEM_DESC_ 14 | 15 | typedef unsigned int cmm_handle; 16 | 17 | /**alloc vmm useby harware*/ 18 | int bufferInit(unsigned char* pAddr, unsigned int bufSize); 19 | int buffer_malloc(MEM_DESC* mem, int size, int align); 20 | int buffer_malloc_withname(MEM_DESC* mem, int size, int align, char* name); 21 | 22 | /** alloc cached none buffered(CNB) memory management used by dma */ 23 | cmm_handle cmm_init(unsigned char* pAddr, unsigned int bufSize); 24 | int cmm_malloc(cmm_handle handle, MEM_DESC* mem, int size, int align, char* name); 25 | int cmm_free(cmm_handle handle); 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /firmware/Libraries/extlib/inc/types/type_def.h: -------------------------------------------------------------------------------- 1 | #ifndef __TYPE_DEF_H__ 2 | #define __TYPE_DEF_H__ 3 | 4 | #ifdef __cplusplus 5 | #if __cplusplus 6 | extern "C" { 7 | #endif 8 | #endif /* __cplusplus */ 9 | 10 | typedef unsigned long long FH_UINT64; 11 | typedef long long FH_SINT64; 12 | typedef unsigned int FH_UINT32; 13 | typedef int FH_SINT32; 14 | typedef unsigned short FH_UINT16; 15 | typedef short FH_SINT16; 16 | typedef unsigned char FH_UINT8; 17 | typedef char FH_SINT8; 18 | typedef FH_UINT8* FH_ADDR; 19 | 20 | typedef char FH_CHAR; 21 | typedef void FH_VOID; 22 | 23 | typedef enum { 24 | FH_FALSE = 0, 25 | FH_TRUE = 1, 26 | DUMMY = 0xffffffff, 27 | } FH_BOOL; 28 | 29 | #define FH_NULL 0L 30 | #define FH_SUCCESS 0 31 | #define FH_FAILURE (-1) 32 | 33 | /*fixed for enum type*/ 34 | #define INT_MINI (-2147483647 - 1) /* minimum (signed) int value */ 35 | #define INT_MAXI 2147483647 /* maximum (signed) int value */ 36 | 37 | #ifdef __cplusplus 38 | #if __cplusplus 39 | } 40 | #endif 41 | #endif /* __cplusplus */ 42 | 43 | #endif /* __TYPE_DEF_H__ */ 44 | -------------------------------------------------------------------------------- /firmware/Libraries/extlib/libadvapi.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RT-Thread/IoT_Camera/1d4eccb6468556a79ebae1b311bf7bd0817ba3b6/firmware/Libraries/extlib/libadvapi.a -------------------------------------------------------------------------------- /firmware/Libraries/extlib/libadvapi_isp.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RT-Thread/IoT_Camera/1d4eccb6468556a79ebae1b311bf7bd0817ba3b6/firmware/Libraries/extlib/libadvapi_isp.a -------------------------------------------------------------------------------- /firmware/Libraries/extlib/libadvapi_md.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RT-Thread/IoT_Camera/1d4eccb6468556a79ebae1b311bf7bd0817ba3b6/firmware/Libraries/extlib/libadvapi_md.a -------------------------------------------------------------------------------- /firmware/Libraries/extlib/libdbi_rtt.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RT-Thread/IoT_Camera/1d4eccb6468556a79ebae1b311bf7bd0817ba3b6/firmware/Libraries/extlib/libdbi_rtt.a -------------------------------------------------------------------------------- /firmware/Libraries/extlib/libdci_rtt.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RT-Thread/IoT_Camera/1d4eccb6468556a79ebae1b311bf7bd0817ba3b6/firmware/Libraries/extlib/libdci_rtt.a -------------------------------------------------------------------------------- /firmware/Libraries/extlib/libdsp_rtt.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RT-Thread/IoT_Camera/1d4eccb6468556a79ebae1b311bf7bd0817ba3b6/firmware/Libraries/extlib/libdsp_rtt.a -------------------------------------------------------------------------------- /firmware/Libraries/extlib/libenc_rtt.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RT-Thread/IoT_Camera/1d4eccb6468556a79ebae1b311bf7bd0817ba3b6/firmware/Libraries/extlib/libenc_rtt.a -------------------------------------------------------------------------------- /firmware/Libraries/extlib/libisp_rtt.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RT-Thread/IoT_Camera/1d4eccb6468556a79ebae1b311bf7bd0817ba3b6/firmware/Libraries/extlib/libisp_rtt.a -------------------------------------------------------------------------------- /firmware/Libraries/extlib/libispcore_rtt.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RT-Thread/IoT_Camera/1d4eccb6468556a79ebae1b311bf7bd0817ba3b6/firmware/Libraries/extlib/libispcore_rtt.a -------------------------------------------------------------------------------- /firmware/Libraries/extlib/libjpeg_rtt.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RT-Thread/IoT_Camera/1d4eccb6468556a79ebae1b311bf7bd0817ba3b6/firmware/Libraries/extlib/libjpeg_rtt.a -------------------------------------------------------------------------------- /firmware/Libraries/extlib/libmedia_process_rtt.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RT-Thread/IoT_Camera/1d4eccb6468556a79ebae1b311bf7bd0817ba3b6/firmware/Libraries/extlib/libmedia_process_rtt.a -------------------------------------------------------------------------------- /firmware/Libraries/extlib/librtt_driver_isp.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RT-Thread/IoT_Camera/1d4eccb6468556a79ebae1b311bf7bd0817ba3b6/firmware/Libraries/extlib/librtt_driver_isp.a -------------------------------------------------------------------------------- /firmware/Libraries/extlib/libvmm_rtt.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RT-Thread/IoT_Camera/1d4eccb6468556a79ebae1b311bf7bd0817ba3b6/firmware/Libraries/extlib/libvmm_rtt.a -------------------------------------------------------------------------------- /firmware/Libraries/extlib/libvou_rtt.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RT-Thread/IoT_Camera/1d4eccb6468556a79ebae1b311bf7bd0817ba3b6/firmware/Libraries/extlib/libvou_rtt.a -------------------------------------------------------------------------------- /firmware/Libraries/extlib/libvpu_rtt.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RT-Thread/IoT_Camera/1d4eccb6468556a79ebae1b311bf7bd0817ba3b6/firmware/Libraries/extlib/libvpu_rtt.a -------------------------------------------------------------------------------- /firmware/Libraries/extlib/sensors/libgc1024_ir_rtt.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RT-Thread/IoT_Camera/1d4eccb6468556a79ebae1b311bf7bd0817ba3b6/firmware/Libraries/extlib/sensors/libgc1024_ir_rtt.a -------------------------------------------------------------------------------- /firmware/Libraries/extlib/sensors/libgc1024_rtt.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RT-Thread/IoT_Camera/1d4eccb6468556a79ebae1b311bf7bd0817ba3b6/firmware/Libraries/extlib/sensors/libgc1024_rtt.a -------------------------------------------------------------------------------- /firmware/Libraries/extlib/src/media_proc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * File : media_proc.c 3 | * This file is part of FH8620 BSP for RT-Thread distribution. 4 | * 5 | * Copyright (c) 2016 Shanghai Fullhan Microelectronics Co., Ltd. 6 | * All rights reserved 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License along 19 | * with this program; if not, write to the Free Software Foundation, Inc., 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | * 22 | * Visit http://www.fullhan.com to get contact with Fullhan. 23 | * 24 | * Change Logs: 25 | * Date Author Notes 26 | */ 27 | #define FH_DGB_ISP_PROC 28 | #define FH_DGB_DSP_PROC 29 | 30 | #include "rtthread.h" 31 | 32 | #ifdef FH_DGB_DSP_PROC 33 | extern int media_read_proc(); 34 | extern int media_mem_proc(); 35 | extern int vpu_read_proc(); 36 | extern int vpu_write_proc(char *s); 37 | extern int enc_read_proc(); 38 | extern int enc_write_proc(char *s); 39 | extern int jpeg_read_proc(); 40 | extern int jpeg_write_proc(char *s); 41 | extern int vou_read_proc(); 42 | extern int vou_write_proc(char *s); 43 | extern void cmm_mem_proc(int index); 44 | 45 | #ifdef RT_USING_FINSH 46 | 47 | #include 48 | 49 | #ifdef FH_DGB_ISP_PROC 50 | extern int isp_read_proc(); 51 | FINSH_FUNCTION_EXPORT(isp_read_proc, read proc info); 52 | #endif 53 | 54 | FINSH_FUNCTION_EXPORT(media_mem_proc, media mem use info.e.g 55 | : media_mem_proc()); 56 | FINSH_FUNCTION_EXPORT(jpeg_write_proc, write jpeg proc info); 57 | FINSH_FUNCTION_EXPORT(jpeg_read_proc, read jpeg proc info); 58 | FINSH_FUNCTION_EXPORT(media_read_proc, get media process proc info); 59 | FINSH_FUNCTION_EXPORT(enc_write_proc, write enc proc info); 60 | FINSH_FUNCTION_EXPORT(enc_read_proc, read enc proc info); 61 | FINSH_FUNCTION_EXPORT(vou_write_proc, write vou proc info); 62 | FINSH_FUNCTION_EXPORT(vou_read_proc, read vou proc info); 63 | FINSH_FUNCTION_EXPORT(vpu_write_proc, write vpu proc info); 64 | FINSH_FUNCTION_EXPORT(vpu_read_proc, read vpu proc info); 65 | FINSH_FUNCTION_EXPORT(cmm_mem_proc, reserved mem use info.e.g 66 | : cmm_mem_proc(index)); 67 | #endif 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /firmware/Libraries/inc/fh_driverlib.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "fh_def.h" 4 | #include "fh_arch.h" 5 | #include "fh_ictl.h" 6 | #include "fh_timer.h" 7 | #include "fh_uart.h" 8 | #include "fh_spi.h" 9 | #include "fh_gpio.h" 10 | #include "fh_mmc.h" 11 | #include "fh_i2c.h" 12 | #include "fh_pwm.h" 13 | #include "fh_wdt.h" 14 | -------------------------------------------------------------------------------- /firmware/Libraries/inc/fh_gpio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File : fh_gpio.h 3 | * This file is part of FH8620 BSP for RT-Thread distribution. 4 | * 5 | * Copyright (c) 2016 Shanghai Fullhan Microelectronics Co., Ltd. 6 | * All rights reserved 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License along 19 | * with this program; if not, write to the Free Software Foundation, Inc., 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | * 22 | * Visit http://www.fullhan.com to get contact with Fullhan. 23 | * 24 | * Change Logs: 25 | * Date Author Notes 26 | */ 27 | 28 | #ifndef FH_GPIO_H_ 29 | #define FH_GPIO_H_ 30 | 31 | #define REG_GPIO_SWPORTA_DR (0x0000) 32 | #define REG_GPIO_SWPORTA_DDR (0x0004) 33 | #define REG_GPIO_PORTA_CTL (0x0008) 34 | #define REG_GPIO_INTEN (0x0030) 35 | #define REG_GPIO_INTMASK (0x0034) 36 | #define REG_GPIO_INTTYPE_LEVEL (0x0038) 37 | #define REG_GPIO_INT_POLARITY (0x003C) 38 | #define REG_GPIO_INTSTATUS (0x0040) 39 | #define REG_GPIO_RAWINTSTATUS (0x0044) 40 | #define REG_GPIO_DEBOUNCE (0x0048) 41 | #define REG_GPIO_PORTA_EOI (0x004C) 42 | #define REG_GPIO_EXT_PORTA (0x0050) 43 | 44 | #define NUM_OF_GPIO (64) 45 | 46 | struct fh_gpio_obj 47 | { 48 | unsigned int id; 49 | unsigned int irq; 50 | }; 51 | 52 | #endif /* FH_GPIO_H_ */ 53 | -------------------------------------------------------------------------------- /firmware/Libraries/inc/fh_ictl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File : fh_ictl.h 3 | * This file is part of FH8620 BSP for RT-Thread distribution. 4 | * 5 | * Copyright (c) 2016 Shanghai Fullhan Microelectronics Co., Ltd. 6 | * All rights reserved 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License along 19 | * with this program; if not, write to the Free Software Foundation, Inc., 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | * 22 | * Visit http://www.fullhan.com to get contact with Fullhan. 23 | * 24 | * Change Logs: 25 | * Date Author Notes 26 | */ 27 | 28 | #ifndef FH_ICTL_H_ 29 | #define FH_ICTL_H_ 30 | 31 | #include "fh_def.h" 32 | 33 | typedef struct 34 | { 35 | RwReg IRQ_EN_L; 36 | RwReg IRQ_EN_H; 37 | RwReg IRQ_MASK_L; 38 | RwReg IRQ_MASK_H; 39 | RwReg IRQ_FORCE_L; 40 | RwReg IRQ_FORCE_H; 41 | RwReg IRQ_RAWSTARUS_L; 42 | RwReg IRQ_RAWSTARUS_H; 43 | RwReg IRQ_STATUS_L; 44 | RwReg IRQ_STATUS_H; 45 | RwReg IRQ_MASKSTATUS_L; 46 | RwReg IRQ_MASKSTATUS_H; 47 | RwReg IRQ_FINALSTATUS_L; 48 | RwReg IRQ_FINALSTATUS_H; 49 | RwReg IRQ_VECTOR; 50 | } fh_intc; 51 | 52 | void ictl_close_all_isr(fh_intc *p); 53 | 54 | void ictl_mask_isr(fh_intc *p, int irq); 55 | 56 | void ictl_unmask_isr(fh_intc *p, int irq); 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /firmware/Libraries/inc/fh_pwm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File : fh_pwm.h 3 | * This file is part of FH8620 BSP for RT-Thread distribution. 4 | * 5 | * Copyright (c) 2016 Shanghai Fullhan Microelectronics Co., Ltd. 6 | * All rights reserved 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License along 19 | * with this program; if not, write to the Free Software Foundation, Inc., 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | * 22 | * Visit http://www.fullhan.com to get contact with Fullhan. 23 | * 24 | * Change Logs: 25 | * Date Author Notes 26 | */ 27 | 28 | #ifndef FH_PWM_H_ 29 | #define FH_PWM_H_ 30 | 31 | #define OFFSET_PWM_CTRL (0x00) 32 | #define OFFSET_PWM_CMD(n) (((n)*4) + OFFSET_PWM_CTRL + 4) 33 | 34 | struct fh_pwm_obj 35 | { 36 | int id; 37 | int irq; 38 | unsigned int base; 39 | unsigned int *pri; 40 | }; 41 | 42 | void PWM_Enable(struct fh_pwm_obj *pwm_obj, int enable); 43 | void PWM_SetPwmCmd(struct fh_pwm_obj *pwm_obj, int device_id, unsigned int reg); 44 | unsigned int PWM_GetPwmCmd(struct fh_pwm_obj *pwm_obj, int device_id); 45 | 46 | #endif /* FH_PWM_H_ */ 47 | -------------------------------------------------------------------------------- /firmware/Libraries/inc/fh_timer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File : fh_timer.h 3 | * This file is part of FH8620 BSP for RT-Thread distribution. 4 | * 5 | * Copyright (c) 2016 Shanghai Fullhan Microelectronics Co., Ltd. 6 | * All rights reserved 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License along 19 | * with this program; if not, write to the Free Software Foundation, Inc., 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | * 22 | * Visit http://www.fullhan.com to get contact with Fullhan. 23 | * 24 | * Change Logs: 25 | * Date Author Notes 26 | */ 27 | 28 | #ifndef FH_TIMER_H_ 29 | #define FH_TIMER_H_ 30 | 31 | /**************************************************************************** 32 | * #include section 33 | * add #include here if any 34 | ***************************************************************************/ 35 | #include "fh_def.h" 36 | 37 | /**************************************************************************** 38 | * #define section 39 | * add constant #define here if any 40 | ***************************************************************************/ 41 | #define TIMER_CTRL_ENABLE (1u << 0) 42 | #define TIMER_CTRL_MODE (1u << 1) 43 | #define TIMER_CTRL_INTMASK (1u << 2) 44 | #define TIMER_CTRL_PWMEN (1u << 3) 45 | 46 | /**************************************************************************** 47 | * ADT section 48 | * add Abstract Data Type definition here 49 | ***************************************************************************/ 50 | typedef struct 51 | { 52 | RwReg TIMER_LOAD_COUNT; 53 | RwReg TIMER_CURRENT_VALUE; 54 | RwReg TIMER_CTRL_REG; 55 | RwReg TIMER_EOI; 56 | RwReg TIMER_INT_STATUS; 57 | } timer; 58 | 59 | enum timer_mode 60 | { 61 | TIMER_MODE_PERIODIC = 0, 62 | TIMER_MODE_ONESHOT = 1, 63 | }; 64 | 65 | /**************************************************************************** 66 | * extern variable declaration section 67 | ***************************************************************************/ 68 | 69 | /**************************************************************************** 70 | * section 71 | * add function prototype here if any 72 | ***************************************************************************/ 73 | 74 | int timer_init(timer *tim); 75 | 76 | int timer_set_mode(timer *tim, enum timer_mode); 77 | 78 | void timer_set_period(timer *tim, UINT32 period, UINT32 clock); 79 | 80 | void timer_enable(timer *tim); 81 | 82 | void timer_disable(timer *tim); 83 | 84 | void timer_enable_irq(timer *tim); 85 | 86 | void timer_disable_irq(timer *tim); 87 | 88 | UINT32 timer_get_status(timer *tim); 89 | 90 | UINT32 timer_get_eoi(timer *tim); 91 | #endif /* #ifndef _TIMER_ */ 92 | -------------------------------------------------------------------------------- /firmware/Libraries/inc/fh_wdt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File : fh_wdt.h 3 | * This file is part of FH8620 BSP for RT-Thread distribution. 4 | * 5 | * Copyright (c) 2016 Shanghai Fullhan Microelectronics Co., Ltd. 6 | * All rights reserved 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License along 19 | * with this program; if not, write to the Free Software Foundation, Inc., 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | * 22 | * Visit http://www.fullhan.com to get contact with Fullhan. 23 | * 24 | * Change Logs: 25 | * Date Author Notes 26 | */ 27 | 28 | #ifndef FH_WDT_H_ 29 | #define FH_WDT_H_ 30 | 31 | #include "fh_def.h" 32 | 33 | #define WDOG_CONTROL_REG_OFFSET 0x00 34 | #define WDOG_CONTROL_REG_WDT_EN_MASK 0x01 35 | #define WDOG_CONTROL_REG_RMOD_MASK 0x02 36 | #define WDOG_TIMEOUT_RANGE_REG_OFFSET 0x04 37 | #define WDOG_CURRENT_COUNT_REG_OFFSET 0x08 38 | #define WDOG_COUNTER_RESTART_REG_OFFSET 0x0c 39 | 40 | #define WDOG_COUNTER_RESTART_KICK_VALUE 0x76 41 | 42 | /* Hardware timeout in seconds */ 43 | #define WDT_HW_TIMEOUT 2 44 | /* User land timeout */ 45 | #define WDT_HEARTBEAT 15 46 | 47 | /* The maximum TOP (timeout period) value that can be set in the watchdog. */ 48 | #define FH_WDT_MAX_TOP 15 49 | 50 | #define WDT_TIMEOUT (HZ / 2) 51 | 52 | struct fh_wdt_obj 53 | { 54 | int id; 55 | int irq; 56 | unsigned int base; 57 | }; 58 | 59 | void WDT_Enable(struct fh_wdt_obj *wdt_obj, int enable); 60 | 61 | static inline int WDT_IsEnable(struct fh_wdt_obj *wdt_obj) 62 | { 63 | return GET_REG(wdt_obj->base + WDOG_CONTROL_REG_OFFSET) & 64 | WDOG_CONTROL_REG_WDT_EN_MASK; 65 | } 66 | 67 | void WDT_SetTopValue(struct fh_wdt_obj *wdt_obj, int top); 68 | void WDT_SetCtrl(struct fh_wdt_obj *wdt_obj, UINT32 reg); 69 | void WDT_Kick(struct fh_wdt_obj *wdt_obj); 70 | unsigned int WDT_GetCurrCount(struct fh_wdt_obj *wdt_obj); 71 | 72 | #endif /* FH_WDT_H_ */ 73 | -------------------------------------------------------------------------------- /firmware/Libraries/startup/SConscript: -------------------------------------------------------------------------------- 1 | from building import * 2 | 3 | Import('rtconfig') 4 | 5 | cwd = GetCurrentDir() 6 | src = ['gcc/start_gcc.S', 'gcc/delay.S'] 7 | 8 | group = DefineGroup('Libraries', src, depend = [''], CPPPATH=[cwd]) 9 | 10 | Return('group') 11 | -------------------------------------------------------------------------------- /firmware/Libraries/startup/gcc/delay.S: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define ALIGN .align 4 4 | 5 | #ifndef ENTRY 6 | #define ENTRY(name) \ 7 | .globl name; \ 8 | ALIGN; \ 9 | name: 10 | #endif 11 | 12 | #ifndef END 13 | #define END(name) \ 14 | .size name, .-name 15 | #endif 16 | 17 | #ifndef ENDPROC 18 | #define ENDPROC(name) \ 19 | .type name, %function; \ 20 | END(name) 21 | #endif 22 | .text 23 | 24 | .LC0: .word loops_per_jiffy 25 | .LC1: .word (2199023*RT_TICK_PER_SECOND)>>11 26 | 27 | /* 28 | * r0 <= 2000 29 | * lpj <= 0x01ffffff (max. 3355 bogomips) 30 | * HZ <= 1000 31 | */ 32 | 33 | ENTRY(__udelay) 34 | ldr r2, .LC1 35 | mul r0, r2, r0 36 | ENTRY(__const_udelay) @ 0 <= r0 <= 0x7fffff06 37 | mov r1, #-1 38 | ldr r2, .LC0 39 | ldr r2, [r2] @ max = 0x01ffffff 40 | add r0, r0, r1, lsr #32-14 41 | mov r0, r0, lsr #14 @ max = 0x0001ffff 42 | add r2, r2, r1, lsr #32-10 43 | mov r2, r2, lsr #10 @ max = 0x00007fff 44 | mul r0, r2, r0 @ max = 2^32-1 45 | add r0, r0, r1, lsr #32-6 46 | movs r0, r0, lsr #6 47 | moveq pc, lr 48 | 49 | /* 50 | * loops = r0 * HZ * loops_per_jiffy / 1000000 51 | * 52 | * Oh, if only we had a cycle counter... 53 | */ 54 | 55 | @ Delay routine 56 | ENTRY(__delay) 57 | subs r0, r0, #1 58 | #if 0 59 | movls pc, lr 60 | subs r0, r0, #1 61 | movls pc, lr 62 | subs r0, r0, #1 63 | movls pc, lr 64 | subs r0, r0, #1 65 | movls pc, lr 66 | subs r0, r0, #1 67 | movls pc, lr 68 | subs r0, r0, #1 69 | movls pc, lr 70 | subs r0, r0, #1 71 | movls pc, lr 72 | subs r0, r0, #1 73 | #endif 74 | bhi __delay 75 | mov pc, lr 76 | ENDPROC(__udelay) 77 | ENDPROC(__const_udelay) 78 | ENDPROC(__delay) 79 | 80 | -------------------------------------------------------------------------------- /firmware/Libraries/startup/gcc/delay.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern void __bad_udelay(void); 4 | extern void __delay(int loops); 5 | extern void __udelay(int loops); 6 | extern void __const_udelay(rt_uint32_t); 7 | 8 | #define MAX_UDELAY_MS 2 9 | 10 | #define udelay(n) \ 11 | (__builtin_constant_p(n) \ 12 | ? ((n) > (MAX_UDELAY_MS * 1000) \ 13 | ? __bad_udelay() \ 14 | : __const_udelay((n) * \ 15 | ((2199023U * RT_TICK_PER_SECOND) >> 11))) \ 16 | : __udelay(n)) 17 | -------------------------------------------------------------------------------- /firmware/Makefile: -------------------------------------------------------------------------------- 1 | scons := python ${SCONS}\scons.py 2 | 3 | all: 4 | @$(scons) 5 | 6 | clean: 7 | @$(scons) -c 8 | 9 | buildua: 10 | @$(scons) --target=ua -s 11 | 12 | buildlib: 13 | @$(scons) --buildlib=WICED -s 14 | 15 | cleanlib: 16 | @$(scons) --cleanlib -s 17 | -------------------------------------------------------------------------------- /firmware/README.md: -------------------------------------------------------------------------------- 1 | # Firmware in IoT Camera 2 | -------------------------------------------------------------------------------- /firmware/SConscript: -------------------------------------------------------------------------------- 1 | # for module compiling 2 | import os 3 | Import('RTT_ROOT') 4 | 5 | cwd = str(Dir('#')) 6 | objs = [] 7 | list = os.listdir(cwd) 8 | 9 | for d in list: 10 | path = os.path.join(cwd, d) 11 | if os.path.isfile(os.path.join(path, 'SConscript')): 12 | objs = objs + SConscript(os.path.join(d, 'SConscript')) 13 | 14 | Return('objs') -------------------------------------------------------------------------------- /firmware/SConstruct: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | import rtconfig 4 | 5 | if os.getenv('RTT_ROOT'): 6 | RTT_ROOT = os.getenv('RTT_ROOT') 7 | else: 8 | RTT_ROOT = os.path.normpath(os.getcwd() + '/rt-thread') 9 | 10 | sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')] 11 | from building import * 12 | 13 | TARGET = rtconfig.OUTPUT_NAME + rtconfig.TARGET_EXT 14 | 15 | # add rtconfig.h path to the assembler 16 | rtconfig.AFLAGS += ' -I' + str(Dir('#')) +' -I' + str(Dir('#')) + '/armv6' 17 | 18 | env = Environment(tools = ['mingw'], 19 | AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS, 20 | CC = rtconfig.CC, CCFLAGS = rtconfig.CFLAGS, 21 | CXX = rtconfig.CXX, CXXFLAGS = rtconfig.CXXFLAGS, 22 | AR = rtconfig.AR, ARFLAGS = '-rc', 23 | LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS) 24 | env.PrependENVPath('PATH', rtconfig.EXEC_PATH) 25 | 26 | if env['PLATFORM'] == 'win32': 27 | env['ASCOM'] = '$AS $ASFLAGS $CCFLAGS $_CCCOMCOM -o $TARGET $SOURCES' 28 | 29 | Export('RTT_ROOT') 30 | Export('rtconfig') 31 | 32 | # prepare building environment 33 | objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=True) 34 | 35 | # make a building 36 | DoBuilding(TARGET, objs) 37 | -------------------------------------------------------------------------------- /firmware/applications/SConscript: -------------------------------------------------------------------------------- 1 | import rtconfig 2 | Import('RTT_ROOT') 3 | from building import * 4 | 5 | cwd = GetCurrentDir() 6 | src = Glob('*.c') + Glob('*.cpp') 7 | 8 | CPPPATH = [cwd, str(Dir('#'))] 9 | group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH) 10 | 11 | list = os.listdir(cwd) 12 | for d in list: 13 | path = os.path.join(cwd, d) 14 | if os.path.isfile(os.path.join(path, 'SConscript')): 15 | group = group + SConscript(os.path.join(d, 'SConscript')) 16 | 17 | Return('group') 18 | -------------------------------------------------------------------------------- /firmware/applications/audio_video_demo/SConscript: -------------------------------------------------------------------------------- 1 | Import('rtconfig') 2 | import os 3 | from building import * 4 | 5 | src = Glob('*.c') 6 | 7 | group = DefineGroup('Applications', src, depend = ['']) 8 | Return('group') 9 | -------------------------------------------------------------------------------- /firmware/applications/audio_video_demo/vlc.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int vlc(int argc, char** argv) 5 | { 6 | extern int vlcview(const char *ip, int port); 7 | 8 | vlcview("10", 5000); 9 | 10 | return 0; 11 | } 12 | MSH_CMD_EXPORT(vlc, vlc demo); 13 | -------------------------------------------------------------------------------- /firmware/applications/gpio_demo/SConscript: -------------------------------------------------------------------------------- 1 | from building import * 2 | 3 | cwd = GetCurrentDir() 4 | src = Glob('*.c') 5 | CPPPATH = [cwd] 6 | 7 | group = DefineGroup('demo', src, depend = ['']) 8 | 9 | Return('group') 10 | -------------------------------------------------------------------------------- /firmware/applications/gpio_demo/gpio_demo.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "gpio.h" 4 | #include "iomux.h" 5 | 6 | /* 7 | function: gpio trig led blink 8 | gpio_num: which gpio to light 9 | */ 10 | static int gpio_blink(rt_uint32_t gpio_num) 11 | { 12 | int status; 13 | int toggle = 0; 14 | 15 | rt_kprintf("Testing gpio %d for %s\n", gpio_num, "output"); 16 | status = gpio_request(gpio_num); /// tab key for 8 char 17 | if (status < 0) 18 | { 19 | rt_kprintf("ERROR can not open GPIO %d\n", gpio_num); 20 | return status; 21 | } 22 | 23 | gpio_direction_output(gpio_num, 0); 24 | 25 | toggle = gpio_get_value(gpio_num); 26 | 27 | while (1) 28 | { 29 | toggle = !(toggle); 30 | 31 | gpio_set_value(gpio_num, toggle); 32 | 33 | rt_thread_delay(10); 34 | 35 | if (gpio_get_value(gpio_num) != toggle) 36 | { 37 | return -RT_ERROR; 38 | } 39 | } 40 | return RT_EOK; 41 | } 42 | 43 | static void gpio_blink_main(void* parameter) { gpio_blink(7); } 44 | /* 45 | function: gpio trig led blink 46 | gpio_num: input gpio 47 | gpio_num_out: output gpio to light led 48 | */ 49 | static int gpio_light(int gpio_num, int gpio_num_out) 50 | { 51 | int ret = 0; 52 | int PreValue = 0; 53 | int CurrentValue = 0; 54 | int status; 55 | 56 | status = gpio_request(gpio_num); 57 | if (status < 0) 58 | { 59 | rt_kprintf("ERROR can not open GPIO %d\n", gpio_num); 60 | return status; 61 | } 62 | 63 | status = gpio_request(gpio_num_out); 64 | if (status < 0) 65 | { 66 | rt_kprintf("ERROR can not open GPIO %d\n", gpio_num_out); 67 | return status; 68 | } 69 | 70 | gpio_direction_input(gpio_num); 71 | 72 | gpio_direction_output(gpio_num_out, 0); 73 | 74 | while (1) 75 | { 76 | CurrentValue = gpio_get_value(gpio_num); 77 | 78 | rt_thread_delay(5); 79 | 80 | if (CurrentValue == PreValue) continue; 81 | 82 | gpio_set_value(gpio_num_out, CurrentValue); 83 | 84 | PreValue = CurrentValue; 85 | } 86 | return ret; 87 | } 88 | 89 | static void gpio_light_main(void* parameter) { gpio_light(6, 5); } 90 | void gpio_demo_init() 91 | { 92 | //////start gpio demo task/////2015.11.24//trj//// 93 | rt_thread_t threadBlink; 94 | 95 | threadBlink = 96 | rt_thread_create("blink", gpio_blink_main, RT_NULL, 10 * 1024, 8, 20); 97 | 98 | if (threadBlink != RT_NULL) rt_thread_startup(threadBlink); 99 | 100 | rt_thread_t threadLight; 101 | 102 | threadLight = 103 | rt_thread_create("light", gpio_light_main, RT_NULL, 10 * 1024, 8, 20); 104 | 105 | if (threadLight != RT_NULL) rt_thread_startup(threadLight); 106 | } 107 | 108 | #ifdef RT_USING_FINSH 109 | #include 110 | FINSH_FUNCTION_EXPORT(gpio_blink_main, gpio_blink_main(gpioNum)); 111 | FINSH_FUNCTION_EXPORT(gpio_light_main, gpio_light_main(gpioNum, gpioNumOut)); 112 | #endif 113 | -------------------------------------------------------------------------------- /firmware/applications/gpio_demo/gpio_demo.h: -------------------------------------------------------------------------------- 1 | #ifndef __GPIO_TEST__ 2 | #define __GPIO_TEST__ 3 | 4 | void gpio_demo_init(); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /firmware/applications/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FH8620 BSP for RT-Thread distribution. 3 | * 4 | * Copyright (c) 2016 Shanghai Fullhan Microelectronics Co., Ltd. 5 | * All rights reserved 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | * Visit http://www.fullhan.com to get contact with Fullhan. 22 | * 23 | * Change Logs: 24 | * Date Author Notes 25 | */ 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | 34 | #ifdef RT_USING_WIFI 35 | #ifdef PKG_USING_WLAN_WICED 36 | 37 | #include "wlan_wiced.h" 38 | 39 | int wifi_init(void) 40 | { 41 | rt_kprintf("wifi init\n"); 42 | wifi_hw_init(); 43 | } 44 | INIT_APP_EXPORT(wifi_init); 45 | 46 | #endif 47 | #endif 48 | 49 | 50 | int main(int argc, char** argv) 51 | { 52 | 53 | FILE *fp; 54 | char cmd[] = "sdcard/init.sh"; 55 | 56 | fp = fopen(cmd, "rb"); 57 | if (fp >= 0) 58 | { 59 | fclose(fp); 60 | 61 | printf("exec init.sh...\n"); 62 | msh_exec(cmd, sizeof(cmd)); 63 | } 64 | 65 | return 0; 66 | } 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /firmware/applications/sadc_demo/SConscript: -------------------------------------------------------------------------------- 1 | from building import * 2 | 3 | cwd = GetCurrentDir() 4 | src = Glob('*.c') 5 | CPPPATH = [cwd] 6 | 7 | group = DefineGroup('demo', src, depend = ['']) 8 | 9 | Return('group') 10 | -------------------------------------------------------------------------------- /firmware/applications/sadc_demo/sadc_demo.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "sadc.h" 4 | 5 | #define CHANNEL_NUM 1 6 | #define REF_VOLT 3300 7 | #define DIGIT_MAX 0x3ff /// driver def 8 | 9 | void sadc_demo_main(void* param) 10 | { 11 | rt_device_t sadc_dev; 12 | 13 | SADC_INFO info; 14 | 15 | info.channel = CHANNEL_NUM; 16 | info.sadc_data = 0; 17 | 18 | sadc_dev = rt_device_find("sadc"); 19 | 20 | if (!sadc_dev) 21 | { 22 | rt_kprintf("cann't find the sadc dev\n"); 23 | } 24 | 25 | sadc_dev->init(sadc_dev); 26 | sadc_dev->open(sadc_dev, 0); 27 | 28 | rt_kprintf("channel:%d,ref volt:%dmv\n", info.channel, REF_VOLT); 29 | 30 | while (1) 31 | { 32 | sadc_dev->control(sadc_dev, SADC_CMD_READ_RAW_DATA, 33 | &info); ////get digit data 34 | 35 | rt_kprintf("sadc digit:%4d volt:%4dmv\r", info.sadc_data, 36 | info.sadc_data * REF_VOLT / DIGIT_MAX); 37 | 38 | rt_thread_delay(100); 39 | } 40 | 41 | return; 42 | } 43 | 44 | void sadc_demo_init() 45 | { 46 | rt_thread_t threadSadc; 47 | 48 | threadSadc = 49 | rt_thread_create("sadc", sadc_demo_main, RT_NULL, 10 * 1024, 80, 20); 50 | 51 | if (threadSadc != RT_NULL) rt_thread_startup(threadSadc); 52 | } 53 | 54 | #ifdef RT_USING_FINSH 55 | #include 56 | FINSH_FUNCTION_EXPORT(sadc_demo_main, sadc_demo_main()); 57 | #endif 58 | -------------------------------------------------------------------------------- /firmware/applications/sadc_demo/sadc_demo.h: -------------------------------------------------------------------------------- 1 | #ifndef __SADC_TEST__ 2 | #define __SADC_TEST__ 3 | 4 | void sadc_demo_init(); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /firmware/applications/sensor_param/SConscript: -------------------------------------------------------------------------------- 1 | from building import * 2 | 3 | cwd = GetCurrentDir() 4 | src = Glob('*.c') 5 | 6 | group = DefineGroup('Applications', src, depend = [''], CPPPATH=[cwd]) 7 | Return('group') 8 | -------------------------------------------------------------------------------- /firmware/applications/sensor_param/multi_sensor.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "multi_sensor.h" 5 | 6 | #ifdef FH_USING_MULTI_SENSOR 7 | 8 | #ifdef RT_USING_IMX138 9 | extern char ISP_PARAM_BUFF(imx138)[FH_ISP_PARA_SIZE]; 10 | #endif 11 | 12 | #ifdef RT_USING_OV9712 13 | extern char ISP_PARAM_BUFF(ov9712)[FH_ISP_PARA_SIZE]; 14 | #endif 15 | 16 | #ifdef RT_USING_OV9732 17 | extern char ISP_PARAM_BUFF(ov9732)[FH_ISP_PARA_SIZE]; 18 | #endif 19 | 20 | #ifdef RT_USING_AR0130 21 | extern char ISP_PARAM_BUFF(ar0130)[FH_ISP_PARA_SIZE]; 22 | #endif 23 | 24 | #ifdef RT_USING_H42 25 | extern char ISP_PARAM_BUFF(h42)[FH_ISP_PARA_SIZE]; 26 | #endif 27 | 28 | #ifdef RT_USING_GC1024 29 | extern char ISP_PARAM_BUFF(gc1024)[FH_ISP_PARA_SIZE]; 30 | #endif 31 | 32 | #ifdef RT_USING_GC1004 // same with GC1024 33 | extern char ISP_PARAM_BUFF(gc1024)[FH_ISP_PARA_SIZE]; 34 | #endif 35 | 36 | #ifdef RT_USING_SC1020 37 | extern char ISP_PARAM_BUFF(sc1020)[FH_ISP_PARA_SIZE]; 38 | #endif 39 | 40 | #ifdef RT_USING_BF3016 41 | extern char ISP_PARAM_BUFF(bf3016)[FH_ISP_PARA_SIZE]; 42 | #endif 43 | 44 | #ifdef RT_USING_GC0308 45 | extern char ISP_PARAM_BUFF(gc0308)[FH_ISP_PARA_SIZE]; 46 | #endif 47 | 48 | #define ADD_SENSOR_INFO(suffix) \ 49 | { \ 50 | .sensor_name = ""#suffix, \ 51 | .sensor_param = ISP_PARAM_BUFF(suffix), \ 52 | .param_len = FH_ISP_PARA_SIZE, \ 53 | } 54 | 55 | FHADV_ISP_SENSOR_INFO_t g_sensor_infos[] = { 56 | #ifdef RT_USING_IMX138 57 | ADD_SENSOR_INFO(imx138), 58 | #endif 59 | #ifdef RT_USING_OV9712 60 | ADD_SENSOR_INFO(ov9712), 61 | #endif 62 | #ifdef RT_USING_OV9732 63 | ADD_SENSOR_INFO(ov9732), 64 | #endif 65 | #ifdef RT_USING_AR0130 66 | ADD_SENSOR_INFO(ar0130), 67 | #endif 68 | #ifdef RT_USING_H42 69 | ADD_SENSOR_INFO(h42), 70 | #endif 71 | #ifdef RT_USING_GC1024 72 | ADD_SENSOR_INFO(gc1024), 73 | #endif 74 | #ifdef RT_USING_SC1020 75 | ADD_SENSOR_INFO(sc1020), 76 | #endif 77 | #ifdef RT_USING_BF3016 78 | ADD_SENSOR_INFO(bf3016), 79 | #endif 80 | #ifdef RT_USING_GC0308 81 | ADD_SENSOR_INFO(gc0308), 82 | #endif 83 | }; 84 | 85 | #else 86 | 87 | extern char isp_param_buff[FH_ISP_PARA_SIZE]; 88 | 89 | FHADV_ISP_SENSOR_INFO_t g_sensor_infos[] = { 90 | { 91 | .sensor_name = "fixed", 92 | .sensor_param = isp_param_buff, 93 | .param_len = FH_ISP_PARA_SIZE 94 | } 95 | }; 96 | 97 | #endif 98 | 99 | void get_isp_sensor_info(FHADV_ISP_SENSOR_INFO_t **info, int *len) 100 | { 101 | *info = g_sensor_infos; 102 | *len = sizeof(g_sensor_infos) / sizeof(FHADV_ISP_SENSOR_INFO_t); 103 | } -------------------------------------------------------------------------------- /firmware/applications/sensor_param/multi_sensor.h: -------------------------------------------------------------------------------- 1 | #ifndef _MULTI_SENSOR_H 2 | #define _MULTI_SENSOR_H 3 | 4 | #include "FHAdv_Isp_mpi.h" 5 | 6 | #define FH_ISP_PARA_SIZE (0x000007eC) 7 | 8 | #ifdef FH_USING_MULTI_SENSOR 9 | #define ISP_PARAM_BUFF(n) isp_param_buff_##n 10 | #endif 11 | 12 | void get_isp_sensor_info(FHADV_ISP_SENSOR_INFO_t **info, int *len); 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /firmware/applications/symbols.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | RTM_EXPORT(gpio_to_irq); 6 | RTM_EXPORT(gpio_release); 7 | RTM_EXPORT(gpio_direction_input); 8 | RTM_EXPORT(gpio_irq_enable); 9 | RTM_EXPORT(gpio_set_irq_type); 10 | RTM_EXPORT(gpio_request); 11 | 12 | extern void fh_select_gpio(int gpio_no); 13 | RTM_EXPORT(fh_select_gpio); 14 | 15 | #include 16 | RTM_EXPORT(pbuf_free) 17 | RTM_EXPORT(pbuf_ref); 18 | RTM_EXPORT(pbuf_copy); 19 | RTM_EXPORT(pbuf_alloc); 20 | RTM_EXPORT(pbuf_header); 21 | 22 | RTM_EXPORT(sys_arch_assert); 23 | 24 | #include 25 | RTM_EXPORT(sdio_high_speed_mode); 26 | RTM_EXPORT(fh_sdio1_init); 27 | RTM_EXPORT(sdio_drv_creg_write); 28 | RTM_EXPORT(sdio_drv_write); 29 | RTM_EXPORT(sdio_drv_creg_read); 30 | RTM_EXPORT(sdio_drv_read); 31 | RTM_EXPORT(sdio_init); 32 | 33 | #include 34 | #include 35 | RTM_EXPORT(eth_device_linkchange); 36 | RTM_EXPORT(netif_set_link_up); 37 | RTM_EXPORT(etharp_output); 38 | RTM_EXPORT(eth_device_init); 39 | RTM_EXPORT(eth_device_init_with_flag); 40 | 41 | #include 42 | RTM_EXPORT(rt_hw_interrupt_install); 43 | 44 | extern int sdio_set_bcm43362(int bcm43362); 45 | RTM_EXPORT(sdio_set_bcm43362); 46 | 47 | -------------------------------------------------------------------------------- /firmware/applications/wave/SConscript: -------------------------------------------------------------------------------- 1 | from building import * 2 | 3 | src = Glob('*.c') 4 | cwd = GetCurrentDir() 5 | 6 | group = DefineGroup('Applications', src, depend = [''], CPPPATH=[cwd]) 7 | Return('group') 8 | -------------------------------------------------------------------------------- /firmware/applications/wave/wave.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "wave.h" 5 | 6 | int init_wave_header(struct WAVE_HEADER *h) 7 | { 8 | strcpy(h->riffHeader.szRiffID, "RIFF"); 9 | h->riffHeader.dwRiffSize = 0; 10 | strcpy(h->riffHeader.szRiffFormat, "WAVE"); 11 | 12 | strcpy(h->fmtBlock.szFmtID, "fmt "); 13 | h->fmtBlock.dwFmtSize = 16; 14 | h->fmtBlock.wavFormat.wFormatTag = 1; // PCM 15 | h->fmtBlock.wavFormat.wChannels = 1; // mono 16 | h->fmtBlock.wavFormat.dwSamplesPerSec = 8000; 17 | h->fmtBlock.wavFormat.wBitsPerSample = 16; 18 | h->fmtBlock.wavFormat.dwAvgBytesPerSec = h->fmtBlock.wavFormat.dwSamplesPerSec * h->fmtBlock.wavFormat.wChannels * 19 | h->fmtBlock.wavFormat.wBitsPerSample / 8; 20 | h->fmtBlock.wavFormat.wBlockAlign = h->fmtBlock.wavFormat.wChannels * h->fmtBlock.wavFormat.wBitsPerSample / 8; 21 | 22 | strcpy(h->factBlock.szFactID, "fact"); 23 | h->factBlock.dwFactSize = 0; 24 | 25 | strcpy(h->dataBlock.szDataID, "data"); 26 | h->dataBlock.dwDataSize = 0; 27 | 28 | return 0; 29 | } 30 | 31 | int read_riff_header(int fd, struct RIFF_HEADER *h) 32 | { 33 | read(fd, &h->dwRiffSize, 4); 34 | read(fd, h->szRiffFormat, 4); 35 | 36 | return 0; 37 | } 38 | 39 | int read_fmt_block(int fd, struct FMT_BLOCK *h) 40 | { 41 | read(fd, &h->dwFmtSize, 4); 42 | read(fd, &h->wavFormat, h->dwFmtSize); 43 | 44 | return 0; 45 | } 46 | 47 | int read_fact_block(int fd, struct FACT_BLOCK *h) 48 | { 49 | unsigned int dummy; 50 | int cnt; 51 | 52 | read(fd, &h->dwFactSize, 4); 53 | 54 | cnt = h->dwFactSize / 4; 55 | while (cnt--) 56 | read(fd, &dummy, 1); 57 | 58 | return 0; 59 | } 60 | 61 | int read_data_header(int fd, struct DATA_BLOCK *h) 62 | { 63 | read(fd, &h->dwDataSize, 4); 64 | 65 | return 0; 66 | } 67 | 68 | int get_wave_header(int fd, struct WAVE_HEADER *h) 69 | { 70 | unsigned int id; 71 | int file_size; 72 | 73 | file_size = lseek(fd, 0, SEEK_END); 74 | lseek(fd, 0, SEEK_SET); 75 | 76 | int is_data_block = 0; 77 | 78 | while (!is_data_block) 79 | { 80 | if (0 > read(fd, &id, 4)) 81 | { 82 | printf("file corrupted.\n"); 83 | return -1; 84 | } 85 | 86 | switch (id) 87 | { 88 | case 0x46464952: // RIFF 89 | *(unsigned int *)h->riffHeader.szRiffID = id; 90 | read_riff_header(fd, &h->riffHeader); 91 | 92 | if (file_size - 8 != h->riffHeader.dwRiffSize) 93 | { 94 | printf("WARNING: file size not match\n"); 95 | } 96 | 97 | if (*(unsigned int *)h->riffHeader.szRiffFormat != 0x45564157) // WAVE 98 | { 99 | printf("invaild wave file.\n"); 100 | return -1; 101 | } 102 | break; 103 | case 0x20746d66: // fmt 104 | *(unsigned int *)h->fmtBlock.szFmtID = id; 105 | read_fmt_block(fd, &h->fmtBlock); 106 | break; 107 | case 0x74636166: // fact 108 | *(unsigned int *)h->factBlock.szFactID = id; 109 | read_fact_block(fd, &h->factBlock); 110 | break; 111 | case 0x61746164: // data 112 | *(unsigned int *)h->dataBlock.szDataID = id; 113 | read_data_header(fd, &h->dataBlock); 114 | is_data_block = 1; 115 | break; 116 | default: 117 | printf("block type unknown.\n"); 118 | return -1; 119 | } 120 | } 121 | 122 | return lseek(fd, 0, SEEK_CUR); 123 | } 124 | -------------------------------------------------------------------------------- /firmware/applications/wave/wave.h: -------------------------------------------------------------------------------- 1 | #ifndef _WAVE_H_ 2 | #define _WAVE_H_ 3 | 4 | struct RIFF_HEADER 5 | { 6 | char szRiffID[4]; // 'R','I','F','F' 7 | unsigned int dwRiffSize; 8 | char szRiffFormat[4]; // 'W','A','V','E' 9 | }; 10 | 11 | struct WAVE_FORMAT 12 | { 13 | unsigned short wFormatTag; // 1:PCM 14 | unsigned short wChannels; // 1: mono; 2:stereo 15 | unsigned int dwSamplesPerSec; // 0x1F40 = 8000Hz 16 | unsigned int dwAvgBytesPerSec; // = dwSamplesPerSec * wChannels * wBitsPerSample / 8 17 | unsigned short wBlockAlign; // = wChannels * wBitsPerSample / 8 18 | unsigned short wBitsPerSample; // 16 19 | }; 20 | 21 | struct FMT_BLOCK 22 | { 23 | char szFmtID[4]; // 'f','m','t',' ' 24 | unsigned int dwFmtSize; // 16 25 | struct WAVE_FORMAT wavFormat; 26 | }; 27 | 28 | struct FACT_BLOCK 29 | { 30 | char szFactID[4]; // 'f','a','c','t' 31 | unsigned int dwFactSize; 32 | }; 33 | 34 | struct DATA_BLOCK 35 | { 36 | char szDataID[4]; // 'd','a','t','a' 37 | unsigned int dwDataSize; 38 | }; 39 | 40 | struct WAVE_HEADER 41 | { 42 | struct RIFF_HEADER riffHeader; 43 | struct FMT_BLOCK fmtBlock; 44 | struct FACT_BLOCK factBlock; 45 | struct DATA_BLOCK dataBlock; 46 | }; 47 | 48 | int init_wave_header(struct WAVE_HEADER *h); 49 | int get_wave_header(int fd, struct WAVE_HEADER *h); 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /firmware/armv6/SConscript: -------------------------------------------------------------------------------- 1 | from building import * 2 | 3 | cwd = GetCurrentDir() 4 | src = Glob('*.c') + Glob('*.S') 5 | CPPPATH = [cwd] 6 | 7 | group = DefineGroup('ARMv6', src, depend = [''], CPPPATH = CPPPATH) 8 | 9 | Return('group') 10 | -------------------------------------------------------------------------------- /firmware/armv6/arm_entry_gcc.S: -------------------------------------------------------------------------------- 1 | /* 2 | * File : arm_entry_gcc.S 3 | * This file is part of RT-Thread RTOS 4 | * COPYRIGHT (C) 2006, RT-Thread Development Team 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program; if not, write to the Free Software Foundation, Inc., 18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | * 20 | * Change Logs: 21 | * Date Author Notes 22 | * 2014-11-07 weety first version 23 | */ 24 | 25 | #include 26 | 27 | #include "armv6.h" 28 | 29 | //#define DEBUG 30 | 31 | .macro PRINT, str 32 | #ifdef DEBUG 33 | stmfd sp!, {r0-r3, ip, lr} 34 | add r0, pc, #4 35 | bl rt_kprintf 36 | b 1f 37 | .asciz "UNDEF: \str\n" 38 | .balign 4 39 | 1: ldmfd sp!, {r0-r3, ip, lr} 40 | #endif 41 | .endm 42 | 43 | .macro PRINT1, str, arg 44 | #ifdef DEBUG 45 | stmfd sp!, {r0-r3, ip, lr} 46 | mov r1, \arg 47 | add r0, pc, #4 48 | bl rt_kprintf 49 | b 1f 50 | .asciz "UNDEF: \str\n" 51 | .balign 4 52 | 1: ldmfd sp!, {r0-r3, ip, lr} 53 | #endif 54 | .endm 55 | 56 | .macro PRINT3, str, arg1, arg2, arg3 57 | #ifdef DEBUG 58 | stmfd sp!, {r0-r3, ip, lr} 59 | mov r3, \arg3 60 | mov r2, \arg2 61 | mov r1, \arg1 62 | add r0, pc, #4 63 | bl rt_kprintf 64 | b 1f 65 | .asciz "UNDEF: \str\n" 66 | .balign 4 67 | 1: ldmfd sp!, {r0-r3, ip, lr} 68 | #endif 69 | .endm 70 | 71 | .macro get_current_thread, rd 72 | ldr \rd, .current_thread 73 | ldr \rd, [\rd] 74 | .endm 75 | 76 | .current_thread: 77 | .word rt_current_thread 78 | 79 | #ifdef RT_USING_NEON 80 | .align 6 81 | 82 | /* is the neon instuction on arm mode? */ 83 | .neon_opcode: 84 | .word 0xfe000000 @ mask 85 | .word 0xf2000000 @ opcode 86 | 87 | .word 0xff100000 @ mask 88 | .word 0xf4000000 @ opcode 89 | 90 | .word 0x00000000 @ end mask 91 | .word 0x00000000 @ end opcode 92 | #endif 93 | 94 | /* undefined instruction exception processing */ 95 | .globl undef_entry 96 | undef_entry: 97 | PRINT1 "r0=0x%08x", r0 98 | PRINT1 "r2=0x%08x", r2 99 | PRINT1 "r9=0x%08x", r9 100 | PRINT1 "sp=0x%08x", sp 101 | 102 | #ifdef RT_USING_NEON 103 | ldr r6, .neon_opcode 104 | __check_neon_instruction: 105 | ldr r7, [r6], #4 @ load mask value 106 | cmp r7, #0 @ end mask? 107 | beq __check_vfp_instruction 108 | and r8, r0, r7 109 | ldr r7, [r6], #4 @ load opcode value 110 | cmp r8, r7 @ is NEON instruction? 111 | bne __check_neon_instruction 112 | b vfp_entry 113 | __check_vfp_instruction: 114 | #endif 115 | tst r0, #0x08000000 @ only CDP/CPRT/LDC/STC instruction has bit 27 116 | tstne r0, #0x04000000 @ bit 26 set on both ARM and Thumb-2 instruction 117 | moveq pc, lr @ no vfp coprocessor instruction, return 118 | get_current_thread r10 119 | and r8, r0, #0x00000f00 @ get coprocessor number 120 | PRINT1 "CP=0x%08x", r8 121 | add pc, pc, r8, lsr #6 122 | nop 123 | mov pc, lr @ CP0 124 | mov pc, lr @ CP1 125 | mov pc, lr @ CP2 126 | mov pc, lr @ CP3 127 | mov pc, lr @ CP4 128 | mov pc, lr @ CP5 129 | mov pc, lr @ CP6 130 | mov pc, lr @ CP7 131 | mov pc, lr @ CP8 132 | mov pc, lr @ CP9 133 | mov pc, lr @ CP10 VFP 134 | mov pc, lr @ CP11 VFP 135 | mov pc, lr @ CP12 136 | mov pc, lr @ CP13 137 | mov pc, lr @ CP14 DEBUG 138 | mov pc, lr @ CP15 SYS CONTROL 139 | 140 | 141 | -------------------------------------------------------------------------------- /firmware/armv6/armv6.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File : armv6.h 3 | * This file is part of RT-Thread RTOS 4 | * COPYRIGHT (C) 2006, RT-Thread Development Team 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program; if not, write to the Free Software Foundation, Inc., 18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | * 20 | * Change Logs: 21 | * Date Author Notes 22 | */ 23 | 24 | #ifndef __ARMV6_H__ 25 | #define __ARMV6_H__ 26 | 27 | 28 | /*****************************/ 29 | /* CPU Mode */ 30 | /*****************************/ 31 | #define USERMODE 0x10 32 | #define FIQMODE 0x11 33 | #define IRQMODE 0x12 34 | #define SVCMODE 0x13 35 | #define ABORTMODE 0x17 36 | #define UNDEFMODE 0x1b 37 | #define MODEMASK 0x1f 38 | #define NOINT 0xc0 39 | 40 | #ifndef __ASSEMBLY__ 41 | struct rt_hw_register 42 | { 43 | rt_uint32_t cpsr; 44 | rt_uint32_t r0; 45 | rt_uint32_t r1; 46 | rt_uint32_t r2; 47 | rt_uint32_t r3; 48 | rt_uint32_t r4; 49 | rt_uint32_t r5; 50 | rt_uint32_t r6; 51 | rt_uint32_t r7; 52 | rt_uint32_t r8; 53 | rt_uint32_t r9; 54 | rt_uint32_t r10; 55 | rt_uint32_t fp; 56 | rt_uint32_t ip; 57 | rt_uint32_t sp; 58 | rt_uint32_t lr; 59 | rt_uint32_t pc; 60 | }; 61 | #if(0) 62 | struct rt_hw_register{ 63 | rt_uint32_t r0; 64 | rt_uint32_t r1; 65 | rt_uint32_t r2; 66 | rt_uint32_t r3; 67 | rt_uint32_t r4; 68 | rt_uint32_t r5; 69 | rt_uint32_t r6; 70 | rt_uint32_t r7; 71 | rt_uint32_t r8; 72 | rt_uint32_t r9; 73 | rt_uint32_t r10; 74 | rt_uint32_t fp; 75 | rt_uint32_t ip; 76 | rt_uint32_t sp; 77 | rt_uint32_t lr; 78 | rt_uint32_t pc; 79 | rt_uint32_t cpsr; 80 | rt_uint32_t ORIG_r0; 81 | }; 82 | #endif 83 | #endif 84 | 85 | /* rt_hw_register offset */ 86 | #define S_FRAME_SIZE 68 87 | 88 | #define S_PC 64 89 | #define S_LR 60 90 | #define S_SP 56 91 | #define S_IP 52 92 | #define S_FP 48 93 | #define S_R10 44 94 | #define S_R9 40 95 | #define S_R8 36 96 | #define S_R7 32 97 | #define S_R6 28 98 | #define S_R5 24 99 | #define S_R4 20 100 | #define S_R3 16 101 | #define S_R2 12 102 | #define S_R1 8 103 | #define S_R0 4 104 | #define S_CPSR 0 105 | 106 | 107 | #endif 108 | -------------------------------------------------------------------------------- /firmware/armv6/context_gcc.S: -------------------------------------------------------------------------------- 1 | /* 2 | * File : context.S 3 | * This file is part of RT-Thread RTOS 4 | * COPYRIGHT (C) 2006, RT-Thread Development Team 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program; if not, write to the Free Software Foundation, Inc., 18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | * 20 | * Change Logs: 21 | * Date Author Notes 22 | * 2011-01-13 weety copy from mini2440 23 | */ 24 | 25 | /*! 26 | * \addtogroup ARMv6 27 | */ 28 | /*@{*/ 29 | 30 | #include 31 | 32 | #define NOINT 0xc0 33 | #define FPEXC_EN (1 << 30) /* VFP enable bit */ 34 | 35 | /* 36 | * rt_base_t rt_hw_interrupt_disable(); 37 | */ 38 | .globl rt_hw_interrupt_disable 39 | rt_hw_interrupt_disable: 40 | mrs r0, cpsr 41 | cpsid if 42 | bx lr 43 | 44 | /* 45 | * void rt_hw_interrupt_enable(rt_base_t level); 46 | */ 47 | .globl rt_hw_interrupt_enable 48 | rt_hw_interrupt_enable: 49 | msr cpsr_c, r0 50 | bx lr 51 | 52 | /* 53 | * void rt_hw_context_switch(rt_uint32 from, rt_uint32 to); 54 | * r0 --> from 55 | * r1 --> to 56 | */ 57 | .globl rt_hw_context_switch 58 | rt_hw_context_switch: 59 | stmfd sp!, {lr} @ push pc (lr should be pushed in place of PC) 60 | stmfd sp!, {r0-r12, lr} @ push lr & register file 61 | 62 | mrs r4, cpsr 63 | tst lr, #0x01 64 | orrne r4, r4, #0x20 @ it's thumb code 65 | 66 | stmfd sp!, {r4} @ push cpsr 67 | 68 | str sp, [r0] @ store sp in preempted tasks TCB 69 | ldr sp, [r1] @ get new task stack pointer 70 | 71 | ldmfd sp!, {r4} @ pop new task cpsr to spsr 72 | msr spsr_cxsf, r4 73 | _do_switch: 74 | ldmfd sp!, {r0-r12, lr, pc}^ @ pop new task r0-r12, lr & pc, copy spsr to cpsr 75 | 76 | /* 77 | * void rt_hw_context_switch_to(rt_uint32 to); 78 | * r0 --> to 79 | */ 80 | .globl rt_hw_context_switch_to 81 | rt_hw_context_switch_to: 82 | ldr sp, [r0] @ get new task stack pointer 83 | 84 | ldmfd sp!, {r4} @ pop new task spsr 85 | msr spsr_cxsf, r4 86 | 87 | bic r4, r4, #0x20 @ must be ARM mode 88 | msr cpsr_cxsf, r4 89 | ldmfd sp!, {r0-r12, lr, pc}^ @ pop new task r0-r12, lr & pc 90 | 91 | /* 92 | * void rt_hw_context_switch_interrupt(rt_uint32 from, rt_uint32 to); 93 | */ 94 | .globl rt_thread_switch_interrupt_flag 95 | .globl rt_interrupt_from_thread 96 | .globl rt_interrupt_to_thread 97 | .globl rt_hw_context_switch_interrupt 98 | rt_hw_context_switch_interrupt: 99 | ldr r2, =rt_thread_switch_interrupt_flag 100 | ldr r3, [r2] 101 | cmp r3, #1 102 | beq _reswitch 103 | mov r3, #1 @ set rt_thread_switch_interrupt_flag to 1 104 | str r3, [r2] 105 | ldr r2, =rt_interrupt_from_thread @ set rt_interrupt_from_thread 106 | str r0, [r2] 107 | _reswitch: 108 | ldr r2, =rt_interrupt_to_thread @ set rt_interrupt_to_thread 109 | str r1, [r2] 110 | bx lr 111 | -------------------------------------------------------------------------------- /firmware/armv6/stack.c: -------------------------------------------------------------------------------- 1 | /* 2 | * File : stack.c 3 | * This file is part of RT-Thread RTOS 4 | * COPYRIGHT (C) 2006, RT-Thread Development Team 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program; if not, write to the Free Software Foundation, Inc., 18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | * 20 | * Change Logs: 21 | * Date Author Notes 22 | * 2011-01-13 weety copy from mini2440 23 | */ 24 | #include 25 | 26 | /*****************************/ 27 | /* CPU Mode */ 28 | /*****************************/ 29 | #define USERMODE 0x10 30 | #define FIQMODE 0x11 31 | #define IRQMODE 0x12 32 | #define SVCMODE 0x13 33 | #define ABORTMODE 0x17 34 | #define UNDEFMODE 0x1b 35 | #define MODEMASK 0x1f 36 | #define NOINT 0xc0 37 | 38 | /** 39 | * This function will initialize thread stack 40 | * 41 | * @param tentry the entry of thread 42 | * @param parameter the parameter of entry 43 | * @param stack_addr the beginning stack address 44 | * @param texit the function will be called when thread exit 45 | * 46 | * @return stack address 47 | */ 48 | rt_uint8_t *rt_hw_stack_init(void *tentry, void *parameter, 49 | rt_uint8_t *stack_addr, void *texit) 50 | { 51 | rt_uint32_t *stk; 52 | 53 | stack_addr += sizeof(rt_uint32_t); 54 | stack_addr = (rt_uint8_t *)RT_ALIGN_DOWN((rt_uint32_t)stack_addr, 8); 55 | stk = (rt_uint32_t *)stack_addr; 56 | 57 | *(--stk) = (rt_uint32_t)tentry; /* entry point */ 58 | *(--stk) = (rt_uint32_t)texit; /* lr */ 59 | *(--stk) = 0xdeadbeef; /* r12 */ 60 | *(--stk) = 0xdeadbeef; /* r11 */ 61 | *(--stk) = 0xdeadbeef; /* r10 */ 62 | *(--stk) = 0xdeadbeef; /* r9 */ 63 | *(--stk) = 0xdeadbeef; /* r8 */ 64 | *(--stk) = 0xdeadbeef; /* r7 */ 65 | *(--stk) = 0xdeadbeef; /* r6 */ 66 | *(--stk) = 0xdeadbeef; /* r5 */ 67 | *(--stk) = 0xdeadbeef; /* r4 */ 68 | *(--stk) = 0xdeadbeef; /* r3 */ 69 | *(--stk) = 0xdeadbeef; /* r2 */ 70 | *(--stk) = 0xdeadbeef; /* r1 */ 71 | *(--stk) = (rt_uint32_t)parameter; /* r0 : argument */ 72 | 73 | /* cpsr */ 74 | if ((rt_uint32_t)tentry & 0x01) 75 | *(--stk) = SVCMODE | 0x20; /* thumb mode */ 76 | else 77 | *(--stk) = SVCMODE; /* arm mode */ 78 | 79 | /* return task's current stack address */ 80 | return (rt_uint8_t *)stk; 81 | } 82 | 83 | -------------------------------------------------------------------------------- /firmware/armv6/vfp.c: -------------------------------------------------------------------------------- 1 | /* 2 | * File : vfp.c 3 | * This file is part of RT-Thread RTOS 4 | * COPYRIGHT (C) 2006, RT-Thread Develop Team 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program; if not, write to the Free Software Foundation, Inc., 18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | * 20 | * Change Logs: 21 | * Date Author Notes 22 | * 2014-11-07 weety first version 23 | */ 24 | #include 25 | #include 26 | #include 27 | #include "vfp.h" 28 | 29 | #ifdef RT_USING_VFP 30 | 31 | void vfp_init(void) 32 | { 33 | int ret = 0; 34 | unsigned int value; 35 | asm volatile ("mrc p15, 0, %0, c1, c0, 2" 36 | :"=r"(value) 37 | :); 38 | value |= 0xf00000;/*enable CP10, CP11 user access*/ 39 | asm volatile("mcr p15, 0, %0, c1, c0, 2" 40 | : 41 | :"r"(value)); 42 | 43 | asm volatile("fmrx %0, fpexc" 44 | :"=r"(value)); 45 | value |=(1<<30); 46 | asm volatile("fmxr fpexc, %0" 47 | : 48 | :"r"(value)); 49 | 50 | } 51 | 52 | void vfp_regs_load(float arrays[32]) 53 | { 54 | asm volatile("fldmias %0, {s0-s31}\n" 55 | : 56 | :"r"(arrays)); 57 | } 58 | void vfp_regs_save(float arrays[32]) 59 | { 60 | asm volatile ("fstmias %0, {s0-s31}" 61 | : 62 | :"r"(arrays)); 63 | } 64 | 65 | void print_array(float array[32]) 66 | { 67 | int i; 68 | for(i=0; i<32; i++) 69 | { 70 | if(i%8==0) 71 | printf("\n"); 72 | printf("%f ",i, array[i]); 73 | } 74 | printf("\n"); 75 | } 76 | 77 | void vfp_test(void) 78 | { 79 | unsigned int fpscr; 80 | float f1=1.0, f2=1.0; 81 | float farrays[32], farrays2[32]; 82 | int i; 83 | 84 | //All instructions are scalar according to manual 85 | fpscr = 0x000000; 86 | 87 | asm volatile ("fmxr fpscr, %0\n" 88 | : 89 | :"r"(fpscr)); 90 | asm volatile ("fmrx %0, fpscr\n" 91 | :"=r"(fpscr)); 92 | 93 | vfp_regs_save(farrays2); 94 | for(i=0; i<32; i++) 95 | farrays[i] = f1+f2*(float)i; 96 | vfp_regs_load(farrays); 97 | vfp_regs_save(farrays2); 98 | rt_kprintf("\n1:ScalarA op ScalarB->ScalarD"); 99 | vfp_regs_load(farrays); 100 | asm volatile("fadds s0, s1, s2"); 101 | vfp_regs_save(farrays2); 102 | print_array(farrays2); 103 | rt_kprintf("\n2:VectorA[?] op ScalarB->VectorD[?]"); 104 | vfp_regs_load(farrays); 105 | asm volatile("fadds s8, s24, s0"); 106 | vfp_regs_save(farrays2); 107 | print_array(farrays2); 108 | rt_kprintf("\n3:VectorA[?] op VectorB[?]->VectorD[?]"); 109 | vfp_regs_load(farrays); 110 | asm volatile("fadds s8, s16, s24"); 111 | vfp_regs_save(farrays2); 112 | print_array(farrays2); 113 | } 114 | 115 | #ifdef RT_USING_FINSH 116 | #include 117 | FINSH_FUNCTION_EXPORT(vfp_test, vfp); 118 | #endif 119 | #endif 120 | -------------------------------------------------------------------------------- /firmware/drivers/SConscript: -------------------------------------------------------------------------------- 1 | Import('RTT_ROOT') 2 | Import('rtconfig') 3 | from building import * 4 | print (rtconfig) 5 | print (RTT_ROOT) 6 | 7 | import os 8 | cwd = GetCurrentDir() 9 | 10 | # add the general drvers. 11 | src = Split(""" 12 | uart.c 13 | interrupt.c 14 | gpio.c 15 | ssi.c 16 | trap.c 17 | drv_mmc.c 18 | i2c.c 19 | dma.c 20 | fh_dma.c 21 | wdt.c 22 | pwm.c 23 | """) 24 | 25 | # belows removed to plat-v2 26 | # fh_pmu.c 27 | # timer.c 28 | # reset.c 29 | 30 | # add Ethernet drvers. 31 | #if GetDepend('RT_USING_LED'): 32 | # src += ['led.c'] 33 | 34 | #if GetDepend('RT_USING_SDIO'): 35 | # src += ['at91_mci.c'] 36 | 37 | #if GetDepend('RT_USING_LWIP'): 38 | # src += ['macb.c'] 39 | 40 | #if GetDepend('RT_USING_I2C') and GetDepend('RT_USING_I2C_BITOPS'): 41 | # src += ['at91_i2c_gpio.c'] 42 | 43 | if GetDepend('RT_USING_SADC'): 44 | src += ['sadc.c'] 45 | if GetDepend('RT_USING_DMA_MEM'): 46 | src += ['dma_mem.c'] 47 | if GetDepend('RT_USING_FH_ACW') and GetDepend('RT_USING_FH_DMA'): 48 | src += ['acw.c','fh_audio_mpi.c'] 49 | if GetDepend('RT_USING_GMAC') and GetDepend('RT_USING_LWIP'): 50 | src += ['fh_gmac.c'] 51 | 52 | local_path = [cwd] 53 | 54 | local_path += [cwd+'/../Libraries'] 55 | local_path += [cwd+'/../platform'] 56 | local_path += [cwd+'/../'] 57 | 58 | group = DefineGroup('Drivers', src, depend = [''], CPPPATH = [cwd]) 59 | 60 | Return('group') 61 | -------------------------------------------------------------------------------- /firmware/drivers/dma.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File : dma.h 3 | * This file is part of FH8620 BSP for RT-Thread distribution. 4 | * 5 | * Copyright (c) 2016 Shanghai Fullhan Microelectronics Co., Ltd. 6 | * All rights reserved 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License along 19 | * with this program; if not, write to the Free Software Foundation, Inc., 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | * 22 | * Visit http://www.fullhan.com to get contact with Fullhan. 23 | * 24 | * Change Logs: 25 | * Date Author Notes 26 | */ 27 | 28 | #ifndef DMA_H_ 29 | #define DMA_H_ 30 | #include 31 | /**************************************************************************** 32 | * #include section 33 | * add #include here if any 34 | ***************************************************************************/ 35 | 36 | /**************************************************************************** 37 | * #define section 38 | * add constant #define here if any 39 | ***************************************************************************/ 40 | #define RT_DEVICE_CTRL_DMA_OPEN (1) 41 | #define RT_DEVICE_CTRL_DMA_CLOSE (2) 42 | #define RT_DEVICE_CTRL_DMA_REQUEST_CHANNEL (3) 43 | #define RT_DEVICE_CTRL_DMA_RELEASE_CHANNEL (4) 44 | #define RT_DEVICE_CTRL_DMA_SINGLE_TRANSFER (5) 45 | 46 | // cyclic add func below.... 47 | 48 | #define RT_DEVICE_CTRL_DMA_CYCLIC_PREPARE (6) 49 | #define RT_DEVICE_CTRL_DMA_CYCLIC_START (7) 50 | #define RT_DEVICE_CTRL_DMA_CYCLIC_STOP (8) 51 | #define RT_DEVICE_CTRL_DMA_CYCLIC_FREE (9) 52 | #define RT_DEVICE_CTRL_DMA_PAUSE (10) 53 | #define RT_DEVICE_CTRL_DMA_RESUME (11) 54 | 55 | //#define RT_DEVICE_CTRL_ (3) /* get the left time before reboot(in 56 | //seconds) */ 57 | //#define RT_DEVICE_CTRL_ (4) /* refresh watchdog */ 58 | //#define RT_DEVICE_CTRL_ (5) /* start watchdog */ 59 | //#define RT_DEVICE_CTRL_ (6) /* stop watchdog */ 60 | 61 | /**************************************************************************** 62 | * ADT section 63 | * add Abstract Data Type definition here 64 | ***************************************************************************/ 65 | 66 | struct rt_dma_ops; 67 | struct rt_dma_device 68 | { 69 | // the parent must be the fitst para.. 70 | struct rt_device parent; 71 | struct rt_dma_ops *ops; 72 | }; 73 | 74 | struct rt_dma_ops 75 | { 76 | rt_err_t (*init)(struct rt_dma_device *dma); 77 | rt_err_t (*control)(struct rt_dma_device *dma, int cmd, void *arg); 78 | }; 79 | 80 | /**************************************************************************** 81 | * extern variable declaration section 82 | ***************************************************************************/ 83 | 84 | /**************************************************************************** 85 | * section 86 | * add function prototype here if any 87 | ***************************************************************************/ 88 | rt_err_t rt_hw_dma_register(struct rt_dma_device *dma, const char *name, 89 | rt_uint32_t flag, void *data); 90 | 91 | /********************************End Of File********************************/ 92 | 93 | #endif 94 | -------------------------------------------------------------------------------- /firmware/drivers/dma_mem.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File : dma_mem.h 3 | * This file is part of FH8620 BSP for RT-Thread distribution. 4 | * 5 | * Copyright (c) 2016 Shanghai Fullhan Microelectronics Co., Ltd. 6 | * All rights reserved 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License along 19 | * with this program; if not, write to the Free Software Foundation, Inc., 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | * 22 | * Visit http://www.fullhan.com to get contact with Fullhan. 23 | * 24 | * Change Logs: 25 | * Date Author Notes 26 | */ 27 | 28 | #ifndef DMA_MEM_H_ 29 | #define DMA_MEM_H_ 30 | 31 | #ifndef RT_USING_MEMHEAP 32 | #define RT_USING_MEMHEAP 33 | #endif 34 | 35 | #include 36 | /**************************************************************************** 37 | * #include section 38 | * add #include here if any 39 | ***************************************************************************/ 40 | 41 | /**************************************************************************** 42 | * #define section 43 | * add constant #define here if any 44 | ***************************************************************************/ 45 | 46 | /**************************************************************************** 47 | * ADT section 48 | * add Abstract Data Type definition here 49 | ***************************************************************************/ 50 | 51 | /**************************************************************************** 52 | * extern variable declaration section 53 | ***************************************************************************/ 54 | 55 | /**************************************************************************** 56 | * section 57 | * add function prototype here if any 58 | ***************************************************************************/ 59 | #ifdef RT_USING_DMA_MEM 60 | rt_err_t fh_dma_mem_init(rt_uint32_t *mem_start, rt_uint32_t size); 61 | void *fh_dma_mem_malloc(rt_uint32_t size); 62 | void *fh_dma_mem_malloc_align(rt_uint32_t size, rt_uint32_t align, char *name); 63 | void fh_dma_mem_free(void *ptr); 64 | void fh_dma_mem_uninit(void); 65 | /********************************End Of File********************************/ 66 | 67 | #endif 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /firmware/drivers/drv_mmc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File : mmc.h 3 | * This file is part of FH8620 BSP for RT-Thread distribution. 4 | * 5 | * Copyright (c) 2016 Shanghai Fullhan Microelectronics Co., Ltd. 6 | * All rights reserved 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License along 19 | * with this program; if not, write to the Free Software Foundation, Inc., 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | * 22 | * Visit http://www.fullhan.com to get contact with Fullhan. 23 | * 24 | * Change Logs: 25 | * Date Author Notes 26 | */ 27 | 28 | #ifndef MMC_H_ 29 | #define MMC_H_ 30 | 31 | #include "Libraries/inc/fh_driverlib.h" 32 | #include "rtdevice.h" 33 | #define MMC_FEQ_MIN 100000 34 | #define MMC_FEQ_MAX 50000000 35 | 36 | #define CARD_UNPLUGED 1 37 | #define CARD_PLUGED 0 38 | 39 | struct mmc_driver 40 | { 41 | MMC_DMA_Descriptors *dma_descriptors; 42 | rt_uint32_t max_desc; 43 | struct rt_mmcsd_host *host; 44 | struct rt_mmcsd_req *req; 45 | struct rt_mmcsd_data *data; 46 | struct rt_mmcsd_cmd *cmd; 47 | struct rt_completion transfer_completion; 48 | void *priv; 49 | }; 50 | 51 | void rt_hw_mmc_init(void); 52 | 53 | #endif /* MMC_H_ */ 54 | -------------------------------------------------------------------------------- /firmware/drivers/fh81_gmac_phyt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File : fh81_gmac_phyt.h 3 | * This file is part of FH8620 BSP for RT-Thread distribution. 4 | * 5 | * Copyright (c) 2016 Shanghai Fullhan Microelectronics Co., Ltd. 6 | * All rights reserved 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License along 19 | * with this program; if not, write to the Free Software Foundation, Inc., 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | * 22 | * Visit http://www.fullhan.com to get contact with Fullhan. 23 | * 24 | * Change Logs: 25 | * Date Author Notes 26 | */ 27 | 28 | #ifndef FH81_GMAC_PHYT_H_ 29 | #define FH81_GMAC_PHYT_H_ 30 | 31 | #include "fh_def.h" 32 | 33 | #ifdef CONFIG_PHY_TI83848 34 | #define PHYT_ID (0x3) 35 | #define PHYT_OUI (0x32001c) 36 | #else 37 | #define PHYT_ID (0x0) 38 | #define PHYT_OUI (0x300007) 39 | #endif 40 | enum 41 | { 42 | gmac_phyt_speed_10M_half_duplex = 1, 43 | gmac_phyt_speed_100M_half_duplex = 2, 44 | gmac_phyt_speed_10M_full_duplex = 5, 45 | gmac_phyt_speed_100M_full_duplex = 6 46 | }; 47 | 48 | enum 49 | { 50 | gmac_phyt_reg_basic_ctrl = 0, 51 | gmac_phyt_reg_basic_status = 1, 52 | gmac_phyt_reg_phy_id1 = 2, 53 | gmac_phyt_reg_phy_id2 = 3, 54 | gmac_phyt_rtl8201_rmii_mode = 16, 55 | gmac_phyt_ti83848_rmii_mode = 17, 56 | gmac_phyt_ip101g_page_select = 20, 57 | gmac_phyt_rtl8201_power_saving = 24, 58 | gmac_phyt_rtl8201_page_select = 31 59 | }; 60 | 61 | typedef union { 62 | struct 63 | { 64 | UINT32 reserved_6_0 : 7; 65 | UINT32 collision_test : 1; 66 | UINT32 duplex_mode : 1; 67 | UINT32 restart_auto_negotiate : 1; 68 | UINT32 isolate : 1; 69 | UINT32 power_down : 1; 70 | UINT32 auto_negotiate_enable : 1; 71 | UINT32 speed_select : 1; 72 | UINT32 loopback : 1; 73 | UINT32 reset : 1; 74 | UINT32 reserved_31_16 : 16; 75 | } bit; 76 | UINT32 dw; 77 | } Reg_Phyt_Basic_Ctrl; 78 | 79 | typedef union { 80 | struct 81 | { 82 | UINT32 extended_capabilities : 1; 83 | UINT32 jabber_detect : 1; 84 | UINT32 link_status : 1; 85 | UINT32 auto_negotiate_ability : 1; 86 | UINT32 remote_fault : 1; 87 | UINT32 auto_negotiate_complete : 1; 88 | UINT32 reserved_10_6 : 5; 89 | UINT32 base_t_half_duplex_10 : 1; 90 | UINT32 base_t_full_duplex_10 : 1; 91 | UINT32 base_tx_half_duplex_100 : 1; 92 | UINT32 base_tx_full_duplex_100 : 1; 93 | UINT32 base_t_4 : 1; 94 | UINT32 reserved_31_16 : 16; 95 | } bit; 96 | UINT32 dw; 97 | } Reg_Phyt_Basic_Status; 98 | 99 | typedef union { 100 | struct 101 | { 102 | UINT32 scramble_disable : 1; 103 | UINT32 reserved_1 : 1; 104 | UINT32 speed_indication : 3; 105 | UINT32 reserved_5 : 1; 106 | UINT32 enable_4b5b : 1; 107 | UINT32 gpo : 3; 108 | UINT32 reserved_11_10 : 2; 109 | UINT32 auto_done : 1; 110 | UINT32 reserved_31_13 : 19; 111 | } bit; 112 | UINT32 dw; 113 | } Reg_Phyt_Special_Status; 114 | 115 | #endif /* FH81_GMAC_PHYT_H_ */ 116 | -------------------------------------------------------------------------------- /firmware/drivers/fh_audio_mpipar.h: -------------------------------------------------------------------------------- 1 | /* 2 | * fh_auido_mpipara.h 3 | * 4 | * Created on: 2015��2��15�� 5 | * Author: fanggm 6 | */ 7 | 8 | #ifndef FH_AUIDO_MPIPARA_H_ 9 | #define FH_AUIDO_MPIPARA_H_ 10 | #include "type_def.h" 11 | #include "acw.h" 12 | 13 | // typedef struct{ 14 | // FH_UINT32 len; 15 | // FH_UINT8 *data; 16 | //}FH_AC_FRAME_S; 17 | // 18 | // typedef enum{ 19 | // FH_AC_MIC_IN = 0, 20 | // FH_AC_LINE_IN = 1, 21 | // FH_AC_SPK_OUT = 2, 22 | // FH_AC_LINE_OUT = 3 23 | //}FH_AC_IO_TYPE_E; 24 | // 25 | // 26 | // typedef struct { 27 | // FH_AC_IO_TYPE_E io_type; 28 | // FH_AC_SAMPLE_RATE_E sample_rate; 29 | // FH_AC_BIT_WIDTH_E bit_width; 30 | // FH_UINT32 channels; //ͨ������ 31 | // FH_UINT32 period_size; //һ֡����еIJ������� 32 | // FH_UINT32 volume; 33 | //} FH_AC_CONFIG; 34 | 35 | #endif /* FH_AUIDO_MPIPARA_H_ */ 36 | -------------------------------------------------------------------------------- /firmware/drivers/fh_gmac.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File : fh_gmac.h 3 | * This file is part of FH8620 BSP for RT-Thread distribution. 4 | * 5 | * Copyright (c) 2016 Shanghai Fullhan Microelectronics Co., Ltd. 6 | * All rights reserved 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License along 19 | * with this program; if not, write to the Free Software Foundation, Inc., 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | * 22 | * Visit http://www.fullhan.com to get contact with Fullhan. 23 | * 24 | * Change Logs: 25 | * Date Author Notes 26 | */ 27 | 28 | #ifndef FH_GMAC_H_ 29 | #define FH_GMAC_H_ 30 | 31 | #ifdef RT_USING_GMAC 32 | int rt_app_fh_gmac_init(void); 33 | #endif 34 | 35 | #endif /* FH_GMAC_H_ */ 36 | -------------------------------------------------------------------------------- /firmware/drivers/i2c.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File : i2c.h 3 | * This file is part of FH8620 BSP for RT-Thread distribution. 4 | * 5 | * Copyright (c) 2016 Shanghai Fullhan Microelectronics Co., Ltd. 6 | * All rights reserved 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License along 19 | * with this program; if not, write to the Free Software Foundation, Inc., 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | * 22 | * Visit http://www.fullhan.com to get contact with Fullhan. 23 | * 24 | * Change Logs: 25 | * Date Author Notes 26 | */ 27 | 28 | #ifndef __FH81_I2C_H__ 29 | #define __FH81_I2C_H__ 30 | 31 | #include 32 | 33 | struct i2c_driver 34 | { 35 | int cmd_err; 36 | int msg_err; 37 | rt_uint32_t status; 38 | 39 | struct rt_i2c_msg *msgs; 40 | int msgs_num; 41 | int msg_write_idx; 42 | rt_uint32_t tx_buf_len; 43 | rt_uint8_t *tx_buf; 44 | int msg_read_idx; 45 | rt_uint32_t rx_buf_len; 46 | rt_uint8_t *rx_buf; 47 | 48 | struct rt_i2c_bus_device *i2c_bus_dev; 49 | struct rt_completion transfer_completion; 50 | rt_mutex_t lock; 51 | void *priv; 52 | }; 53 | 54 | void rt_hw_i2c_init(void); 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /firmware/drivers/interrupt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File : interrupt.h 3 | * This file is part of FH8620 BSP for RT-Thread distribution. 4 | * 5 | * Copyright (c) 2016 Shanghai Fullhan Microelectronics Co., Ltd. 6 | * All rights reserved 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License along 19 | * with this program; if not, write to the Free Software Foundation, Inc., 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | * 22 | * Visit http://www.fullhan.com to get contact with Fullhan. 23 | * 24 | * Change Logs: 25 | * Date Author Notes 26 | */ 27 | 28 | #ifndef INTERRUPT_H_ 29 | #define INTERRUPT_H_ 30 | #include 31 | 32 | #define NR_INTERNAL_IRQS 56 33 | #define NR_EXTERNAL_IRQS 64 34 | 35 | void rt_hw_interrupt_init(void); 36 | void rt_hw_interrupt_mask(int irq); 37 | void rt_hw_interrupt_umask(int irq); 38 | rt_isr_handler_t rt_hw_interrupt_install(int vector, rt_isr_handler_t handler, 39 | void *param, char *name); 40 | 41 | #endif /* INTERRUPT_H_ */ 42 | -------------------------------------------------------------------------------- /firmware/drivers/pwm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File : pwm.h 3 | * This file is part of FH8620 BSP for RT-Thread distribution. 4 | * 5 | * Copyright (c) 2016 Shanghai Fullhan Microelectronics Co., Ltd. 6 | * All rights reserved 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License along 19 | * with this program; if not, write to the Free Software Foundation, Inc., 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | * 22 | * Visit http://www.fullhan.com to get contact with Fullhan. 23 | * 24 | * Change Logs: 25 | * Date Author Notes 26 | */ 27 | 28 | #ifndef PWM_H_ 29 | #define PWM_H_ 30 | 31 | // #define FH_VPWM_DEBUG 32 | #include 33 | #ifdef RT_USING_TIMEKEEPING 34 | #include 35 | #include 36 | #endif 37 | #define ENABLE_PWM (0x10) 38 | #define DISABLE_PWM (0x11) 39 | 40 | #define SET_PWM_DUTY_CYCLE (0x12) 41 | #define GET_PWM_DUTY_CYCLE (0x13) 42 | 43 | struct pwm_device 44 | { 45 | int id; 46 | int working; 47 | rt_uint32_t period_ns; 48 | rt_uint32_t counter_ns; 49 | #ifdef RT_USING_VPWM 50 | unsigned int gpio_id; 51 | rt_uint32_t period_ticks; 52 | rt_uint32_t counter_ticks; 53 | rt_uint32_t invert_ticks[2]; 54 | void *func; 55 | char name[8]; 56 | struct hrtimer timer; 57 | int invert; 58 | #endif 59 | }; 60 | 61 | struct pwm_driver 62 | { 63 | // struct clk *clk; 64 | #ifdef RT_USING_VPWM 65 | struct pwm_device pwm[FH_VPWM_COUNT + 3]; 66 | #else 67 | struct pwm_device pwm[3]; 68 | #endif 69 | struct pwm_device *cur; 70 | void *priv; 71 | }; 72 | 73 | void rt_hw_pwm_init(void); 74 | 75 | #endif /* PWM_H_ */ 76 | -------------------------------------------------------------------------------- /firmware/drivers/sadc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File : sadc.h 3 | * This file is part of FH8620 BSP for RT-Thread distribution. 4 | * 5 | * Copyright (c) 2016 Shanghai Fullhan Microelectronics Co., Ltd. 6 | * All rights reserved 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License along 19 | * with this program; if not, write to the Free Software Foundation, Inc., 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | * 22 | * Visit http://www.fullhan.com to get contact with Fullhan. 23 | * 24 | * Change Logs: 25 | * Date Author Notes 26 | */ 27 | 28 | #ifndef SADC_H_ 29 | #define SADC_H_ 30 | 31 | #include 32 | #ifdef RT_USING_SADC 33 | 34 | /**************************************************************************** 35 | * #define section 36 | * add constant #define here if any 37 | ***************************************************************************/ 38 | //#define FH_SADC_PROC_FILE "driver/sadc" 39 | #define MAX_CHANNEL_NO (8) 40 | #define SADC_REF (3300) 41 | #define SADC_MAX_AD_VALUE (0x3ff) 42 | #define LOOP_MODE (0x55) 43 | #define ISR_MODE (0xAA) 44 | 45 | #define SADC_INIT_ALREADY (0x33) 46 | #define SADC_INIT_NOT_YET (0) 47 | 48 | #define SADC_CMD_READ_RAW_DATA (0x22) 49 | #define SADC_CMD_READ_VOLT (0x33) 50 | #define SADC_CMD_DISABLE (0x44) 51 | 52 | /**************************************************************************** 53 | * ADT section 54 | * add Abstract Data Type definition here 55 | ***************************************************************************/ 56 | 57 | struct wrap_sadc_reg 58 | { 59 | rt_uint32_t sadc_cmd; 60 | rt_uint32_t sadc_control; 61 | rt_uint32_t sadc_ier; 62 | rt_uint32_t sadc_int_status; 63 | rt_uint32_t sadc_dout0; 64 | rt_uint32_t sadc_dout1; 65 | rt_uint32_t sadc_dout2; 66 | rt_uint32_t sadc_dout3; 67 | rt_uint32_t sadc_debuge0; 68 | rt_uint32_t sadc_status; 69 | rt_uint32_t sadc_cnt; 70 | rt_uint32_t sadc_timeout; 71 | }; 72 | 73 | struct wrap_sadc_obj 74 | { 75 | rt_uint32_t id; 76 | void *regs; 77 | rt_uint32_t irq_no; 78 | rt_uint32_t init_flag; 79 | rt_uint32_t active_channel_no; 80 | rt_uint32_t active_channel_status; 81 | rt_uint16_t channel_data[MAX_CHANNEL_NO]; 82 | rt_uint32_t error_rec; 83 | rt_uint32_t en_isr; 84 | rt_uint32_t sample_mode; 85 | struct rt_mutex lock; 86 | struct rt_semaphore completion; 87 | 88 | // bind to the rtdev.. 89 | rt_device_t rt_dev; 90 | }; 91 | 92 | typedef struct 93 | { 94 | rt_uint32_t channel; 95 | rt_uint32_t sadc_data; 96 | } SADC_INFO; 97 | 98 | /**************************************************************************** 99 | * extern variable declaration section 100 | ***************************************************************************/ 101 | 102 | /**************************************************************************** 103 | * section 104 | * add function prototype here if any 105 | ***************************************************************************/ 106 | void rt_hw_sadc_init(void); 107 | #endif 108 | #endif /* SADC_H_ */ 109 | -------------------------------------------------------------------------------- /firmware/drivers/ssi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File : ssi.h 3 | * This file is part of FH8620 BSP for RT-Thread distribution. 4 | * 5 | * Copyright (c) 2016 Shanghai Fullhan Microelectronics Co., Ltd. 6 | * All rights reserved 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License along 19 | * with this program; if not, write to the Free Software Foundation, Inc., 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | * 22 | * Visit http://www.fullhan.com to get contact with Fullhan. 23 | * 24 | * Change Logs: 25 | * Date Author Notes 26 | */ 27 | 28 | #ifndef SSI_H_ 29 | #define SSI_H_ 30 | #include "Libraries/inc/fh_driverlib.h" 31 | #include 32 | #include 33 | #include "fh_dma.h" 34 | #define SPI_PRIV(drv) ((struct fh_spi_obj)(drv->priv)) 35 | 36 | #define FH_SPI_SLAVE_MAX_NO 2 37 | 38 | struct spi_controller; 39 | // platform use below 40 | struct spi_slave_platform_data 41 | { 42 | rt_uint32_t cs_pin; 43 | #define ACTIVE_LOW 1 44 | #define ACTIVE_HIGH 2 45 | rt_uint32_t actice_level; 46 | }; 47 | 48 | struct spi_control_platform_data 49 | { 50 | rt_uint32_t id; 51 | rt_uint32_t irq; 52 | rt_uint32_t base; 53 | rt_uint32_t max_hz; 54 | rt_uint32_t slave_no; 55 | rt_uint32_t clk_in; 56 | // handshake no... 57 | rt_uint32_t rx_hs_no; 58 | rt_uint32_t tx_hs_no; 59 | 60 | char *dma_name; 61 | // isr will be the default... 62 | #define USE_ISR_TRANSFER 0 63 | #define USE_DMA_TRANSFER 1 64 | rt_uint32_t transfer_mode; 65 | struct spi_controller *control; 66 | struct spi_slave_platform_data plat_slave[FH_SPI_SLAVE_MAX_NO]; 67 | }; 68 | 69 | struct spi_controller; 70 | // driver use below....... 71 | struct spi_slave_info 72 | { 73 | struct rt_spi_device spi_device; 74 | struct spi_controller *control; 75 | struct spi_slave_platform_data plat_slave; 76 | rt_uint32_t id; 77 | // spi control will use to find all the slave info.. 78 | struct spi_slave_info *next; 79 | }; 80 | 81 | struct spi_dma 82 | { 83 | char *dma_name; 84 | #define DMA_BIND_OK 0 85 | #define DMA_BIND_ERROR 1 86 | rt_uint32_t dma_flag; 87 | // bind to the dma dev.. 88 | rt_uint32_t rx_hs; 89 | rt_uint32_t tx_hs; 90 | rt_uint8_t *rx_dummy_buff; 91 | rt_uint8_t *tx_dummy_buff; 92 | struct rt_dma_device *dma_dev; 93 | struct dma_transfer tx_trans; 94 | struct dma_transfer rx_trans; 95 | struct spi_controller *control; 96 | }; 97 | 98 | struct spi_controller 99 | { 100 | rt_uint32_t id; 101 | rt_uint32_t irq; 102 | rt_uint32_t base; 103 | rt_uint32_t max_hz; 104 | rt_uint32_t slave_no; 105 | rt_uint32_t clk_in; 106 | // bind to the platform data.... 107 | struct spi_control_platform_data *plat_data; 108 | 109 | // rt_uint32_t dma_xfer_flag; 110 | 111 | #define XFER_USE_ISR 0 112 | #define XFER_USE_DMA 1 113 | rt_uint32_t xfer_mode; 114 | 115 | struct spi_dma dma; 116 | rt_uint32_t dma_complete_times; 117 | struct rt_spi_bus spi_bus; 118 | struct spi_slave_info *spi_slave; 119 | struct rt_spi_message *current_message; 120 | struct rt_completion transfer_completion; 121 | struct rt_semaphore xfer_lock; 122 | struct fh_spi_obj obj; 123 | rt_uint32_t received_len; 124 | rt_uint32_t transfered_len; 125 | void *priv; 126 | }; 127 | 128 | void rt_hw_spi_init(void); 129 | 130 | #endif /* SPI_H_ */ 131 | -------------------------------------------------------------------------------- /firmware/drivers/uart.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File : uart.h 3 | * This file is part of FH8620 BSP for RT-Thread distribution. 4 | * 5 | * Copyright (c) 2016 Shanghai Fullhan Microelectronics Co., Ltd. 6 | * All rights reserved 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License along 19 | * with this program; if not, write to the Free Software Foundation, Inc., 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | * 22 | * Visit http://www.fullhan.com to get contact with Fullhan. 23 | * 24 | * Change Logs: 25 | * Date Author Notes 26 | */ 27 | 28 | #ifndef UART_H_ 29 | #define UART_H_ 30 | 31 | void rt_hw_uart_init(void); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /firmware/drivers/wdt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File : wdt.h 3 | * This file is part of FH8620 BSP for RT-Thread distribution. 4 | * 5 | * Copyright (c) 2016 Shanghai Fullhan Microelectronics Co., Ltd. 6 | * All rights reserved 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License along 19 | * with this program; if not, write to the Free Software Foundation, Inc., 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | * 22 | * Visit http://www.fullhan.com to get contact with Fullhan. 23 | * 24 | * Change Logs: 25 | * Date Author Notes 26 | */ 27 | 28 | #ifndef WDT_H_ 29 | #define WDT_H_ 30 | 31 | struct wdt_driver 32 | { 33 | // struct clk *clk; 34 | unsigned long in_use; 35 | unsigned long next_heartbeat; 36 | // struct timer_list timer; 37 | int expect_close; 38 | 39 | void* priv; 40 | }; 41 | 42 | void rt_hw_wdt_init(void); 43 | 44 | #endif /* WDT_H_ */ 45 | -------------------------------------------------------------------------------- /firmware/link.ld: -------------------------------------------------------------------------------- 1 | OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") 2 | OUTPUT_ARCH(arm) 3 | ENTRY(_start) 4 | SECTIONS 5 | { 6 | . =0xA0000000; 7 | 8 | . = ALIGN(4); 9 | __text_start = .; 10 | _stext = __text_start; 11 | .text : 12 | { 13 | *(.init) 14 | *(.text) 15 | KEEP(*(.fini)) 16 | *(.gnu.linkonce.t*) 17 | 18 | /* section information for finsh shell */ 19 | . = ALIGN(4); 20 | __fsymtab_start = .; 21 | KEEP(*(FSymTab)) 22 | __fsymtab_end = .; 23 | . = ALIGN(4); 24 | __vsymtab_start = .; 25 | KEEP(*(VSymTab)) 26 | __vsymtab_end = .; 27 | . = ALIGN(4); 28 | 29 | . = ALIGN(4); 30 | __rt_init_start = .; 31 | KEEP(*(SORT(.rti_fn*))) 32 | __rt_init_end = .; 33 | . = ALIGN(4); 34 | 35 | /* section information for modules */ 36 | . = ALIGN(4); 37 | __rtmsymtab_start = .; 38 | KEEP(*(RTMSymTab)) 39 | __rtmsymtab_end = .; 40 | } 41 | __text_end = .; 42 | _etext = __text_end; 43 | 44 | . = ALIGN(4); 45 | __rodata_start = .; 46 | .rodata : { *(.rodata) *(.rodata.*) *(.gnu.linkonce.r*) *(.eh_frame) } 47 | __rodata_end = .; 48 | 49 | . = ALIGN(4); 50 | .ctors : 51 | { 52 | PROVIDE(__ctors_start__ = .); 53 | *crtbegin.o(.ctors) 54 | *crtbegin?.o(.ctors) 55 | *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors) 56 | *(SORT(.ctors.*)) 57 | *(.ctors) 58 | PROVIDE(__ctors_end__ = .); 59 | } 60 | 61 | .ARM.extab : 62 | { 63 | *(.ARM.extab* .gnu.linkonce.armextab.*) 64 | } 65 | 66 | /* The .ARM.exidx section is used for C++ exception handling. */ 67 | /* .ARM.exidx is sorted, so has to go in its own output section. */ 68 | __exidx_start = .; 69 | ARM.exidx : 70 | { 71 | *(.ARM.exidx* .gnu.linkonce.armexidx.*) 72 | 73 | /* This is used by the startup in order to initialize the .data secion */ 74 | _sidata = .; 75 | } 76 | __exidx_end = .; 77 | 78 | .dtors : 79 | { 80 | PROVIDE(__dtors_start__ = .); 81 | *crtbegin.o(.dtors) 82 | *crtbegin?.o(.dtors) 83 | *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors) 84 | *(SORT(.dtors.*)) 85 | *(.dtors) 86 | PROVIDE(__dtors_end__ = .); 87 | } 88 | 89 | . = ALIGN(4); 90 | __data_start = .; 91 | .data : 92 | { 93 | *(vtable) 94 | *(.data*) 95 | 96 | . = ALIGN(4); 97 | /* preinit data */ 98 | PROVIDE_HIDDEN (__preinit_array_start = .); 99 | KEEP(*(.preinit_array)) 100 | PROVIDE_HIDDEN (__preinit_array_end = .); 101 | 102 | . = ALIGN(4); 103 | /* init data */ 104 | PROVIDE_HIDDEN (__init_array_start = .); 105 | KEEP(*(SORT(.init_array.*))) 106 | KEEP(*(.init_array)) 107 | PROVIDE_HIDDEN (__init_array_end = .); 108 | 109 | 110 | . = ALIGN(4); 111 | /* finit data */ 112 | PROVIDE_HIDDEN (__fini_array_start = .); 113 | KEEP(*(SORT(.fini_array.*))) 114 | KEEP(*(.fini_array)) 115 | PROVIDE_HIDDEN (__fini_array_end = .); 116 | 117 | KEEP(*(.jcr*)) 118 | . = ALIGN(4); 119 | /* All data end */ 120 | *(.gnu.linkonce.d*) 121 | } 122 | __data_end = .; 123 | 124 | . = ALIGN(4); 125 | .nobss : { *(.nobss) } 126 | 127 | . = ALIGN(4); 128 | __bss_start = .; 129 | .bss : 130 | { 131 | *(.bss*) 132 | *(COMMON) 133 | } 134 | __bss_end = .; 135 | 136 | /* stabs debugging sections. */ 137 | .stab 0 : { *(.stab) } 138 | .stabstr 0 : { *(.stabstr) } 139 | .stab.excl 0 : { *(.stab.excl) } 140 | .stab.exclstr 0 : { *(.stab.exclstr) } 141 | .stab.index 0 : { *(.stab.index) } 142 | .stab.indexstr 0 : { *(.stab.indexstr) } 143 | .comment 0 : { *(.comment) } 144 | .debug_abbrev 0 : { *(.debug_abbrev) } 145 | .debug_info 0 : { *(.debug_info) } 146 | .debug_line 0 : { *(.debug_line) } 147 | .debug_pubnames 0 : { *(.debug_pubnames) } 148 | .debug_aranges 0 : { *(.debug_aranges) } 149 | 150 | _end = .; 151 | } 152 | -------------------------------------------------------------------------------- /firmware/packages/SConscript: -------------------------------------------------------------------------------- 1 | import os 2 | from building import * 3 | 4 | cwd = GetCurrentDir() 5 | objs = [] 6 | list = os.listdir(cwd) 7 | 8 | for d in list: 9 | path = os.path.join(cwd, d) 10 | if os.path.isfile(os.path.join(path, 'SConscript')): 11 | objs = objs + SConscript(os.path.join(d, 'SConscript')) 12 | 13 | Return('objs') 14 | -------------------------------------------------------------------------------- /firmware/packages/dbi/SConscript: -------------------------------------------------------------------------------- 1 | from building import * 2 | 3 | cwd = GetCurrentDir() 4 | src = Glob('*.c') 5 | 6 | group = DefineGroup('dbi', src, depend = ['FH_USING_COOLVIEW'], CPPPATH=[cwd + '/..']) 7 | 8 | Return('group') 9 | -------------------------------------------------------------------------------- /firmware/packages/dbi/dbi_over_tcp.h: -------------------------------------------------------------------------------- 1 | #ifndef _DBI_OVER_TCP_H 2 | #define _DBI_OVER_TCP_H 3 | 4 | struct dbi_tcp_config 5 | { 6 | int port; 7 | int *cancel; 8 | }; 9 | 10 | /* dbi_over_tcp main thread */ 11 | int *tcp_dbi_thread(struct dbi_tcp_config *conf); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /firmware/packages/dbi/dbi_over_udp.c: -------------------------------------------------------------------------------- 1 | /* 2 | * dbi_over_udp.c 3 | * 4 | * Created on: 2016.5.6 5 | * Author: gaoyb 6 | */ 7 | 8 | #include 9 | #include 10 | #include 11 | #include "lwip/sockets.h" 12 | #include "types/type_def.h" 13 | // #include 14 | #include "di/debug_interface.h" 15 | #include "dbi_over_udp.h" 16 | 17 | struct dbi_over_udp 18 | { 19 | int udp_port; 20 | int udp_connection; 21 | char debug_ip[16]; 22 | 23 | struct Debug_Interface *di; 24 | }; 25 | 26 | static int udp_send(void *obj, unsigned char *buf, int size) 27 | { 28 | struct dbi_over_udp *udp = (struct dbi_over_udp *)obj; 29 | 30 | return sendto(udp->udp_connection, buf, size, 0, 31 | (struct sockaddr *)&udp->debug_ip, sizeof(udp->debug_ip)); 32 | } 33 | 34 | static int udp_recv(void *obj, unsigned char *buf, int size) 35 | { 36 | socklen_t len; 37 | struct dbi_over_udp *udp = (struct dbi_over_udp *)obj; 38 | 39 | len = sizeof(udp->debug_ip); 40 | 41 | return recvfrom(udp->udp_connection, buf, size, 0, 42 | (struct sockaddr *)&udp->debug_ip, &len); 43 | } 44 | 45 | struct dbi_over_udp *udp_dbi_create(int port) 46 | { 47 | struct dbi_over_udp *udp; 48 | udp = malloc(sizeof(struct dbi_over_udp)); 49 | memset(udp, 0, sizeof(struct dbi_over_udp)); 50 | strcpy(udp->debug_ip, "0.0.0.0"); 51 | udp->udp_port = port; 52 | 53 | int ret; //, fd; 54 | // int on = 1; 55 | struct sockaddr_in local_addr; 56 | 57 | ret = socket(AF_INET, SOCK_DGRAM, 0); 58 | if (ret < 0) 59 | { 60 | perror("socket open failed"); 61 | return NULL; 62 | } 63 | 64 | udp->udp_connection = ret; 65 | 66 | lwip_fcntl(udp->udp_connection, F_SETFL, O_NONBLOCK); 67 | 68 | local_addr.sin_family = AF_INET; 69 | local_addr.sin_port = htons(port); 70 | local_addr.sin_addr.s_addr = htonl(INADDR_ANY); 71 | 72 | ret = bind(udp->udp_connection, (struct sockaddr *)&local_addr, 73 | sizeof(local_addr)); 74 | if (ret < 0) 75 | { 76 | perror("bind error"); 77 | return NULL; 78 | } 79 | 80 | struct DI_config di_cfg; 81 | 82 | di_cfg.obj = udp; 83 | di_cfg.send = udp_send; 84 | di_cfg.recv = udp_recv; 85 | 86 | udp->di = DI_create(&di_cfg); 87 | 88 | return udp; 89 | } 90 | 91 | int udp_dbi_destroy(struct dbi_over_udp *udp) 92 | { 93 | lwip_close(udp->udp_connection); 94 | DI_destroy(udp->di); 95 | 96 | free(udp); 97 | return 0; 98 | } 99 | 100 | int *udp_dbi_thread(struct dbi_udp_config *conf) 101 | { 102 | int ret; 103 | int *exit = conf->cancel; 104 | struct dbi_over_udp *udp = udp_dbi_create(conf->port); 105 | 106 | while (!*exit) 107 | { 108 | ret = DI_handle(udp->di); 109 | if (ret == -1) continue; 110 | } 111 | 112 | udp_dbi_destroy(udp); 113 | return 0; 114 | } 115 | -------------------------------------------------------------------------------- /firmware/packages/dbi/dbi_over_udp.h: -------------------------------------------------------------------------------- 1 | #ifndef _DBI_OVER_UDP_H 2 | #define _DBI_OVER_UDP_H 3 | 4 | struct dbi_udp_config 5 | { 6 | int port; 7 | int *cancel; 8 | }; 9 | 10 | /* dbi_over_udp main thread */ 11 | int *udp_dbi_thread(struct dbi_udp_config *conf); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /firmware/packages/partition/SConscript: -------------------------------------------------------------------------------- 1 | from building import * 2 | 3 | cwd = GetCurrentDir() 4 | src = Glob('*.c') 5 | CPPPATH = [cwd] 6 | 7 | group = DefineGroup('partition', src, depend = ['RT_USING_DFS'], CPPPATH = CPPPATH) 8 | 9 | Return('group') 10 | -------------------------------------------------------------------------------- /firmware/packages/partition/partition.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File : partition.h 3 | * COPYRIGHT (C) 2016, Shanghai Real-Thread Technology Co., Ltd 4 | * 5 | * Change Logs: 6 | * Date Author Notes 7 | * 2016-09-20 Bernard the first version 8 | */ 9 | 10 | #ifndef PARTITION_H__ 11 | #define PARTITION_H__ 12 | 13 | #define PARTITION_RDONLY 0x000 14 | #define PARTITION_WRITEABLE 0x100 /* Device is writable */ 15 | #define PARTITION_POWERUP_LOCK 0x200 /* Always locked after reset */ 16 | 17 | struct rt_partition 18 | { 19 | const char* name; 20 | 21 | rt_uint32_t offset; 22 | rt_uint32_t size; 23 | 24 | rt_uint32_t flags; 25 | }; 26 | 27 | int rt_partition_init(const char* block_device, const struct rt_partition* parts); 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /firmware/packages/stream_pack/SConscript: -------------------------------------------------------------------------------- 1 | import os 2 | from building import * 3 | 4 | cwd = GetCurrentDir() 5 | objs = [] 6 | dirs = os.listdir(cwd) 7 | 8 | for d in dirs: 9 | path = os.path.join(cwd, d) 10 | if os.path.isfile(os.path.join(path, 'SConscript')): 11 | objs = objs + SConscript(os.path.join(d, 'SConscript')) 12 | 13 | Return('objs') -------------------------------------------------------------------------------- /firmware/packages/stream_pack/pes/PSMuxLib.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __PSMUX_LIB_H__ 3 | #define __PSMUX_LIB_H__ 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | /* video stream type */ 10 | #define STREAM_TYPE_VIDEO_H264 0x1b /* 标准H264 */ 11 | 12 | /* 输入帧类型,对应frame_type */ 13 | #define FRAME_TYPE_UNDEF (-1) /* 未定义的帧类型 */ 14 | #define FRAME_TYPE_VIDEO_IFRAME 3 /* 视频数据 I 帧 */ 15 | #define FRAME_TYPE_VIDEO_PFRAME 1 /* 视频数据 P 帧 */ 16 | #define FRAME_TYPE_VIDEO_BFRAME 0 /* 视频数据 B 帧 */ 17 | 18 | /* 状态码:小于零表示有错误(0x80000000开始),零表示失败,大于零表示成功 */ 19 | #define PSMUX_LIB_S_OK 0x00000001 /* 成功 */ 20 | #define PSMUX_LIB_S_FAIL 0x00000000 /* 失败 */ 21 | #define PSMUX_LIB_E_PARA_NULL 0x80000000 /* 参数指针为空 */ 22 | #define PSMUX_LIB_E_MEM_OVER 0x80000001 /* 内存溢出 */ 23 | #define PSMUX_LIB_E_STREAM_TYPE 0x80000003 /* 流类型错误 */ 24 | 25 | #define MAX_PES_PACKET_LEN 65496 26 | 27 | #ifndef _HRESULT_DEFINED 28 | #define _HRESULT_DEFINED 29 | typedef int HRESULT; 30 | #endif /*!_HRESULT_DEFINED*/ 31 | 32 | typedef struct _PSMUX_ES_INFO_ 33 | { 34 | unsigned int max_byte_rate; /* 码率,以byte为单位*/ 35 | unsigned int max_packet_len; /* 最大 pes 包长度 */ 36 | unsigned int video_stream_type; /* 输入视频流类型 */ 37 | unsigned int set_frame_end_flg; /* 是否在pes包头的填充字节里设置帧或nalu结束开始标记 */ 38 | } PSMUX_ES_INFO; 39 | 40 | /* 复合器参数 */ 41 | typedef struct _PSMUX_PARAM_ 42 | { 43 | unsigned int buffer_size; 44 | unsigned char *buffer; 45 | PSMUX_ES_INFO info; 46 | } PSMUX_PARAM; 47 | 48 | /* 数据块处理参数 */ 49 | typedef struct _PSMUX_UNIT_ 50 | { 51 | unsigned int frame_type; /* 输入帧类型 */ 52 | unsigned int is_first_unit; /* 是否是一帧的第一个unit。标准H.264每帧会分成多个unit*/ 53 | /* 其余编码每帧都只有一个unit */ 54 | unsigned int is_last_unit; /* 是否是一帧的最后一个unit */ 55 | unsigned int is_key_frame; /* 是否关键数据(I帧) */ 56 | unsigned int is_unit_start; /* 若是一个nalu或一帧的第一段数据,则置1,若送进的是完整的一帧或一个nalu也置1*/ 57 | unsigned int is_unit_end; /* 若是一个nalu或一帧的最后一段数据,则置1,若送进的是完整的一帧或一个nalu也置1*/ 58 | unsigned long long sys_clk_ref; /* 系统参考时钟,以 1/45000 秒为单位 */ 59 | unsigned long long ptime_stamp; /* 该帧在接收端的显示时标,单位同上 */ 60 | unsigned int frame_num; /* 当前帧号 */ 61 | unsigned char *unit_in_buf; /* 输入 unit 指针 */ 62 | unsigned int unit_in_len; /* 输出 unit 长度 */ 63 | 64 | unsigned char *out_buf; /* 输出缓冲区 */ 65 | unsigned int out_buf_len; /* 输出缓冲区长度 */ 66 | unsigned int out_buf_size; /* 输出缓冲区大小 */ 67 | 68 | /* 码流信息 */ 69 | unsigned int encrypt; /* 是否加密 */ 70 | 71 | } PSMUX_PROCESS_PARAM; 72 | 73 | /****************************************************************************** 74 | * 功 能:获取所需内存大小 75 | * 参 数:param - 参数结构指针 76 | * 返回值:返回错误码 77 | * 备 注:参数结构中 buffer_size变量用来表示所需内存大小 78 | ******************************************************************************/ 79 | HRESULT PSMUX_GetMemSize(PSMUX_PARAM *param); 80 | 81 | /****************************************************************************** 82 | * 功 能:创建PSMUX模块 83 | * 参 数:param - 参数结构指针 84 | * **handle - 返回PSMUX模块句柄 85 | * 返回值:返回错误码 86 | ******************************************************************************/ 87 | HRESULT PSMUX_Create(PSMUX_PARAM *param, void **handle); 88 | 89 | /****************************************************************************** 90 | * 功 能:复合一段数据块 91 | * 参 数:handle - 句柄(handle由PSMUX_Create返回) 92 | * 返回值:返回错误码 93 | ******************************************************************************/ 94 | HRESULT PSMUX_Process(void *handle, PSMUX_PROCESS_PARAM *param); 95 | 96 | /****************************************************************************** 97 | * 功 能:重置参考数据 98 | * 参 数:handle - 句柄(handle由PSMUX_Create返回) 99 | * info - 参考数据句柄 100 | * 返回值:返回错误码 101 | ******************************************************************************/ 102 | HRESULT PSMUX_ResetStreamInfo(void *handle, PSMUX_ES_INFO *info); 103 | 104 | #ifdef __cplusplus 105 | } 106 | #endif 107 | 108 | #endif /* __PSMUX_LIB_H__ */ 109 | -------------------------------------------------------------------------------- /firmware/packages/stream_pack/pes/SConscript: -------------------------------------------------------------------------------- 1 | Import('rtconfig') 2 | import os 3 | from building import * 4 | 5 | cwd = GetCurrentDir() 6 | 7 | src = Glob('*.c') 8 | group = DefineGroup('pes_pack', src, depend=['FH_USING_PES_PACK'], CPPPATH=[cwd]) 9 | Return('group') 10 | -------------------------------------------------------------------------------- /firmware/packages/stream_pack/pes/pes_pack.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __LIBVLCVIEW_H__ 3 | #define __LIBVLCVIEW_H__ 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | #define MAX_NALU_COUNT 20 10 | 11 | enum vlcview_enc_frame_type 12 | { 13 | VLCVIEW_ENC_H264_I_FRAME, 14 | VLCVIEW_ENC_H264_P_FRAME 15 | }; 16 | 17 | struct vlcview_h264_nalu 18 | { 19 | unsigned int len; 20 | unsigned char *start; 21 | }; 22 | 23 | struct vlcview_enc_stream_element 24 | { 25 | enum vlcview_enc_frame_type frame_type; 26 | int frame_len; 27 | int nalu_count; 28 | unsigned long long time_stamp; 29 | struct vlcview_h264_nalu nalu[MAX_NALU_COUNT]; 30 | }; 31 | 32 | int vlcview_pes_init(void); 33 | int vlcview_pes_uninit(void); 34 | int vlcview_pes_stream_pack(int channel, struct vlcview_enc_stream_element stream_element); 35 | int vlcview_pes_send_to_vlc(int channel, const char *ip, int port); 36 | int init_stream_pack(); 37 | int deinit_stream_pack(); 38 | 39 | #ifdef __cplusplus 40 | } 41 | #endif 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /firmware/packages/stream_pack/rtsp/SConscript: -------------------------------------------------------------------------------- 1 | Import('rtconfig') 2 | import os 3 | from building import * 4 | 5 | cwd = GetCurrentDir() 6 | 7 | src = Glob('*.c') 8 | group = DefineGroup('rtsp', src, depend=['FH_USING_RTSP'], CPPPATH=[cwd]) 9 | Return('group') 10 | -------------------------------------------------------------------------------- /firmware/packages/stream_pack/rtsp/rtsp.h: -------------------------------------------------------------------------------- 1 | #ifndef __RTSP_H__ 2 | #define __RTSP_H__ 3 | 4 | #define RTSP_DEBUG 5 | 6 | #ifdef RTSP_DEBUG 7 | #define debug printf 8 | #else 9 | #define debug 10 | #endif 11 | 12 | enum rtp_transport 13 | { 14 | RTP_TRANSPORT_UDP, 15 | RTP_TRANSPORT_TCP 16 | }; 17 | 18 | struct rtsp_server_context; 19 | 20 | struct rtsp_server_context *rtsp_start_server(enum rtp_transport transport, int port); 21 | void rtsp_stop_server(struct rtsp_server_context *server); 22 | void rtp_push_data(struct rtsp_server_context *server, void *data, int size, unsigned long long pts); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /firmware/packages/wget/SConscript: -------------------------------------------------------------------------------- 1 | from building import * 2 | 3 | cwd = GetCurrentDir() 4 | src = Glob('*.c') 5 | CPPPATH = [cwd] 6 | 7 | group = DefineGroup('wget', src, depend = ['RT_USING_LWIP'], CPPPATH = CPPPATH) 8 | 9 | Return('group') 10 | -------------------------------------------------------------------------------- /firmware/packages/wget/webclient.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File : webclient.h 3 | * COPYRIGHT (C) 2012-2013, Shanghai Real-Thread Technology Co., Ltd 4 | * 5 | * Change Logs: 6 | * Date Author Notes 7 | * 2013-05-05 Bernard the first version 8 | * 2015-11-14 aozima add content_length_remainder. 9 | */ 10 | 11 | #ifndef __WEBCLIENT_H__ 12 | #define __WEBCLIENT_H__ 13 | 14 | #include 15 | 16 | #include 17 | 18 | #define WEBCLIENT_HEADER_BUFSZ 1024 19 | #define BUF_SIZE 2048 20 | 21 | //typedef unsigned int size_t; 22 | 23 | enum WEBCLIENT_STATUS 24 | { 25 | WEBCLIENT_OK, 26 | WEBCLIENT_NOMEM, 27 | WEBCLIENT_NOSOCKET, 28 | WEBCLIENT_NOBUFFER, 29 | WEBCLIENT_CONNECT_FAILED, 30 | WEBCLIENT_DISCONNECT, 31 | WEBCLIENT_FILE_ERROR, 32 | WEBCLIENT_TIMEOUT, 33 | }; 34 | 35 | enum WEBCLIENT_METHOD 36 | { 37 | WEBCLIENT_USER_METHOD, 38 | WEBCLIENT_GET, 39 | WEBCLIENT_POST, 40 | }; 41 | 42 | struct webclient_session 43 | { 44 | /* the session socket */ 45 | int socket; 46 | /* the response code of HTTP request */ 47 | int response; 48 | 49 | /* transfer encoding */ 50 | char *transfer_encoding; 51 | int chunk_sz; 52 | int chunk_offset; 53 | 54 | /* content_type of HTTP response */ 55 | char* content_type; 56 | /* content_length of HTTP response */ 57 | size_t content_length; 58 | 59 | /* last modified timestamp of resource */ 60 | char* last_modified; 61 | 62 | /* location */ 63 | char* location; 64 | 65 | /* server host */ 66 | char* host; 67 | /* HTTP request */ 68 | char* request; 69 | 70 | /* private for webclient session. */ 71 | 72 | /* position of reading */ 73 | unsigned int position; 74 | 75 | /* remainder of content reading */ 76 | size_t content_length_remainder; 77 | }; 78 | 79 | struct webclient_session* webclient_open(const char* URI); 80 | struct webclient_session* webclient_open_position(const char* URI, int position); 81 | struct webclient_session* webclient_open_header(const char* URI, int method, const char* header, size_t header_sz); 82 | int webclient_close(struct webclient_session* session); 83 | 84 | int webclient_set_timeout(struct webclient_session* session, int millisecond); 85 | 86 | int webclient_read (struct webclient_session* session, unsigned char *buffer, size_t size); 87 | int webclient_write(struct webclient_session* session, const unsigned char *buffer, size_t size); 88 | 89 | int webclient_send_header(struct webclient_session* session, int method, 90 | const char *header, size_t header_sz); 91 | int webclient_connect(struct webclient_session* session, const char *URI); 92 | int webclient_handle_response(struct webclient_session* session); 93 | 94 | /* hight level APIs for HTTP client */ 95 | int webclient_response(struct webclient_session* session, void **response); 96 | struct webclient_session* webclient_open_custom(const char* URI, int method, 97 | const char* header, size_t header_sz, 98 | const char* data, size_t data_sz); 99 | 100 | int webclient_transfer(const char* URI, const char* header, size_t header_sz, 101 | const char* data, size_t data_sz, 102 | char *result, size_t result_sz); 103 | 104 | 105 | #ifdef RT_USING_DFS 106 | int webclient_get_file(const char* URI, const char* filename); 107 | int webclient_post_file(const char* URI, const char* filename, const char* form_data); 108 | #endif 109 | 110 | #endif 111 | -------------------------------------------------------------------------------- /firmware/platform/SConscript: -------------------------------------------------------------------------------- 1 | # RT-Thread building script for bridge 2 | 3 | import os 4 | from building import * 5 | 6 | cwd = GetCurrentDir() 7 | objs = [] 8 | list = os.listdir(cwd) 9 | 10 | for d in list: 11 | path = os.path.join(cwd, d) 12 | if os.path.isfile(os.path.join(path, 'SConscript')): 13 | objs = objs + SConscript(os.path.join(d, 'SConscript')) 14 | 15 | Return('objs') 16 | -------------------------------------------------------------------------------- /firmware/platform/board.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File : board.h 3 | * This file is part of FH8620 BSP for RT-Thread distribution. 4 | * 5 | * Copyright (c) 2016 Shanghai Fullhan Microelectronics Co., Ltd. 6 | * All rights reserved 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License along 19 | * with this program; if not, write to the Free Software Foundation, Inc., 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | * 22 | * Visit http://www.fullhan.com to get contact with Fullhan. 23 | * 24 | * Change Logs: 25 | * Date Author Notes 26 | */ 27 | 28 | #ifndef __BOARD_H__ 29 | #define __BOARD_H__ 30 | 31 | void rt_hw_board_init(void); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /firmware/platform/board_info.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File : board_info.h 3 | * This file is part of FH8620 BSP for RT-Thread distribution. 4 | * 5 | * Copyright (c) 2016 Shanghai Fullhan Microelectronics Co., Ltd. 6 | * All rights reserved 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License along 19 | * with this program; if not, write to the Free Software Foundation, Inc., 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | * 22 | * Visit http://www.fullhan.com to get contact with Fullhan. 23 | * 24 | * Change Logs: 25 | * Date Author Notes 26 | */ 27 | 28 | #ifndef __BOARD_INFO_H__ 29 | #define __BOARD_INFO_H__ 30 | 31 | #ifdef __cplusplus 32 | extern "C" { 33 | #endif 34 | 35 | /**************************************************************************** 36 | * #include section 37 | * add #include here if any 38 | ***************************************************************************/ 39 | 40 | /**************************************************************************** 41 | * #define section 42 | * add constant #define here if any 43 | ***************************************************************************/ 44 | 45 | /**************************************************************************** 46 | * ADT section 47 | * add Abstract Data Type definition here 48 | ***************************************************************************/ 49 | 50 | typedef int (*probe_p)(void *); 51 | typedef int (*exit_p)(void *); 52 | 53 | struct fh_board_ops 54 | { 55 | // void *ops_data; 56 | probe_p probe; 57 | probe_p exit; 58 | }; 59 | 60 | struct fh_board_info 61 | { 62 | char *name; 63 | void *data; 64 | struct fh_board_ops *ops; 65 | }; 66 | 67 | /**************************************************************************** 68 | * extern variable declaration section 69 | ***************************************************************************/ 70 | 71 | int fh_board_info_init(void); 72 | struct fh_board_info *fh_board_info_register(char *info_name, void *data); 73 | int fh_board_driver_register(char *info_name, struct fh_board_ops *ops); 74 | void fh_print_all_board_info(void); 75 | void fh_free_all_info(void); 76 | /**************************************************************************** 77 | * section 78 | * add function prototype here if any 79 | ***************************************************************************/ 80 | 81 | #ifdef __cplusplus 82 | } 83 | #endif 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /firmware/platform/common/SConscript: -------------------------------------------------------------------------------- 1 | from building import * 2 | 3 | cwd = GetCurrentDir() 4 | src = Glob('*.c') 5 | 6 | group = DefineGroup('Platform', src, depend = ['']) 7 | 8 | Return('group') 9 | -------------------------------------------------------------------------------- /firmware/platform/common/chkenv.c: -------------------------------------------------------------------------------- 1 | /* 2 | * File : chkenv.c 3 | * This file is part of FH8620 BSP for RT-Thread distribution. 4 | * 5 | * Copyright (c) 2016 Shanghai Fullhan Microelectronics Co., Ltd. 6 | * All rights reserved 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License along 19 | * with this program; if not, write to the Free Software Foundation, Inc., 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | * 22 | * Visit http://www.fullhan.com to get contact with Fullhan. 23 | * 24 | * Change Logs: 25 | * Date Author Notes 26 | */ 27 | 28 | /***************************************************************************** 29 | * Include Section 30 | * add all #include here 31 | * those macro below should define.... 32 | * or the dsp or isp lib will not be supported 33 | *****************************************************************************/ 34 | #include 35 | 36 | //#pragma comment ( linker, "/EXPORT: MyExportFunction = _MyExportFunctio" ) 37 | //#pragma message 38 | //#warning RT_NAME_MAX=32 39 | //#error .... 40 | 41 | //#define yu_error(macro) #error ##macro 42 | 43 | /************************** 44 | * 45 | * 46 | * define value below. 47 | * 48 | * 49 | **************************/ 50 | #if RT_NAME_MAX != 16 51 | #error "define RT_NAME_MAX 16" 52 | #endif 53 | 54 | #if RT_TICK_PER_SECOND != 100 55 | #warning "RT_TICK_PER_SECOND = 100" 56 | #endif 57 | 58 | #if RT_ALIGN_SIZE != 4 59 | #error "define RT_ALIGN_SIZE 4" 60 | #endif 61 | 62 | /************************** 63 | * 64 | * 65 | * should define below.. 66 | * 67 | * 68 | **************************/ 69 | #ifndef RT_USING_SEMAPHORE 70 | #error need define "RT_USING_SEMAPHORE" 71 | #endif 72 | 73 | #ifndef RT_USING_MUTEX 74 | #error need define "RT_USING_MUTEX" 75 | #endif 76 | 77 | #ifndef RT_USING_EVENT 78 | #error need define "RT_USING_EVENT" 79 | #endif 80 | 81 | #ifndef RT_USING_MAILBOX 82 | #error need define "RT_USING_MAILBOX" 83 | #endif 84 | 85 | #ifndef RT_USING_MESSAGEQUEUE 86 | #warning need define "RT_USING_MESSAGEQUEUE" 87 | #endif 88 | 89 | #ifndef RT_USING_MEMPOOL 90 | #warning need define "RT_USING_MEMPOOL" 91 | #endif 92 | 93 | #ifndef RT_USING_HEAP 94 | #error need define "RT_USING_HEAP" 95 | #endif 96 | 97 | #ifndef RT_USING_MEMHEAP 98 | #warning need define "RT_USING_MEMHEAP" 99 | #endif 100 | 101 | #ifndef RT_USING_MODULE 102 | #error need define "RT_USING_MODULE" 103 | #endif 104 | 105 | #ifndef RT_USING_DEVICE 106 | #error need define "RT_USING_DEVICE" 107 | #endif 108 | 109 | #ifndef RT_USING_CONSOLE 110 | #error need define "RT_USING_CONSOLE" 111 | #endif 112 | 113 | #ifndef RT_USING_FINSH 114 | #error need define "RT_USING_FINSH" 115 | #endif 116 | 117 | #ifndef RT_USING_I2C 118 | #error need define "RT_USING_I2C" 119 | #endif 120 | -------------------------------------------------------------------------------- /firmware/platform/fh8620/SConscript: -------------------------------------------------------------------------------- 1 | # RT-Thread building script for bridge 2 | 3 | import os 4 | from building import * 5 | 6 | cwd = GetCurrentDir() 7 | objs = [] 8 | list = os.listdir(cwd) 9 | 10 | for d in list: 11 | path = os.path.join(cwd, d) 12 | if os.path.isfile(os.path.join(path, 'SConscript')): 13 | objs = objs + SConscript(os.path.join(d, 'SConscript')) 14 | 15 | Return('objs') 16 | -------------------------------------------------------------------------------- /firmware/platform/fh8620/arch.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File : arch.h 3 | * This file is part of FH8620 BSP for RT-Thread distribution. 4 | * 5 | * Copyright (c) 2016 Shanghai Fullhan Microelectronics Co., Ltd. 6 | * All rights reserved 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License along 19 | * with this program; if not, write to the Free Software Foundation, Inc., 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | * 22 | * Visit http://www.fullhan.com to get contact with Fullhan. 23 | * 24 | * Change Logs: 25 | * Date Author Notes 26 | */ 27 | 28 | #ifndef ARCH_H_ 29 | #define ARCH_H_ 30 | 31 | /*****************************/ 32 | /* BSP CONTROLLER BASE */ 33 | /*****************************/ 34 | #define INTC_REG_BASE (0xE0200000) 35 | #define SDC0_REG_BASE (0xE2000000) 36 | #define SDC1_REG_BASE (0xE2100000) 37 | #define TVE_REG_BASE (0xE8000000) 38 | #define VOU_REG_BASE (0xE8100000) 39 | #define AES_REG_BASE (0xE8200000) 40 | #define JPEG_REG_BASE (0xE8300000) 41 | #define ISPB_REG_BASE (0xEA000000) 42 | #define ISPF_REG_BASE (0xEA100000) 43 | #define VPU_REG_BASE (0xEC000000) 44 | #define VCU_REG_BASE (0xEC100000) 45 | #define DDRC_REG_BASE (0xED000000) 46 | #define DMAC_REG_BASE (0xEE000000) 47 | #define GMAC_REG_BASE (0xEF000000) 48 | #define PMU_REG_BASE (0xF0000000) 49 | #define I2C0_REG_BASE (0xF0200000) 50 | #define GPIO0_REG_BASE (0xF0300000) 51 | #define GPIO1_REG_BASE (0xf4000000) 52 | #define PWM_REG_BASE (0xF0400000) 53 | #define SPI0_REG_BASE (0xF0500000) 54 | #define SPI1_REG_BASE (0xF0600000) 55 | #define UART0_REG_BASE (0xF0700000) 56 | #define UART1_REG_BASE (0xF0800000) 57 | #define I2S_REG_BASE (0xF0900000) 58 | #define ACODEC_REG_BASE (0xF0A00000) 59 | #define I2C1_REG_BASE (0xF0B00000) 60 | #define TMR_REG_BASE (0xF0C00000) 61 | #define WDT_REG_BASE (0xF0D00000) 62 | #define DPHY_REG_BASE (0xF1000000) 63 | #define MIPIC_REG_BASE (0xF1100000) 64 | #define SADC_REG_BASE (0xF1200000) 65 | 66 | typedef enum IRQn { 67 | PAE_IRQn = 0, 68 | VPU_IRQn = 1, 69 | ISP_F_IRQn = 2, 70 | ISP_B_IRQn = 3, 71 | VOU_IRQn = 4, 72 | JPEG_IRQn = 5, 73 | TVE_IRQn = 6, 74 | TOE_IRQn = 7, 75 | DDRC_IRQn = 8, 76 | DMAC_IRQn = 9, 77 | AES_IRQn = 10, 78 | MIPIC_IRQn = 11, 79 | MIPI_WRAP_IRQn = 12, 80 | PMU_IRQn = 13, 81 | EMAC_IRQn = 14, 82 | AXIC0_IRQn = 16, 83 | AXIC1_IRQn = 17, 84 | X2H0_IRQn = 18, 85 | X2H1_IRQn = 19, 86 | AHBC0_IRQn = 20, 87 | AHBC1_IRQn = 21, 88 | SADC_IRQn = 23, 89 | SDC0_IRQn = 24, 90 | SDC1_IRQn = 25, 91 | ACW_IRQn = 26, 92 | WDT_IRQn = 27, 93 | SPI0_IRQn = 28, 94 | SPI1_IRQn = 29, 95 | UART0_IRQn = 30, 96 | UART1_IRQn = 31, 97 | I2S0_IRQn = 32, 98 | I2S1_IRQn = 33, 99 | RTC_IRQn = 34, 100 | PWM_IRQn = 35, 101 | TMR0_IRQn = 36, 102 | TMR1_IRQn = 37, 103 | USB0_IRQn = 38, 104 | USB1_IRQn = 39, 105 | GPIO0_IRQn = 40, 106 | GPIO1_IRQn = 41, 107 | I2C0_IRQn = 42, 108 | I2C1_IRQn = 43, 109 | 110 | } IRQn_Type; 111 | 112 | #endif /* ARCH_H_ */ 113 | -------------------------------------------------------------------------------- /firmware/platform/fh8620/iot_cam/SConscript: -------------------------------------------------------------------------------- 1 | from building import * 2 | 3 | cwd = GetCurrentDir() 4 | src = Glob('*.c') 5 | path = [cwd, cwd + '/..'] 6 | 7 | group = DefineGroup('Platform', src, depend = ['CONFIG_BOARD_IOTCAM', 'CONFIG_CHIP_FH8620'], CPPPATH = path) 8 | 9 | Return('group') 10 | -------------------------------------------------------------------------------- /firmware/platform/fh8620/iot_cam/board_def.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File : board_def.h 3 | * This file is part of FH8620 BSP for RT-Thread distribution. 4 | * 5 | * Copyright (c) 2016 Shanghai Fullhan Microelectronics Co., Ltd. 6 | * All rights reserved 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License along 19 | * with this program; if not, write to the Free Software Foundation, Inc., 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | * 22 | * Visit http://www.fullhan.com to get contact with Fullhan. 23 | * 24 | * Change Logs: 25 | * Date Author Notes 26 | */ 27 | 28 | #ifndef BOARD_DEF_H_ 29 | #define BOARD_DEF_H_ 30 | 31 | #define RT_USING_CALIBRATE 32 | // #define RT_USING_VFP 33 | 34 | /* *********************** 35 | * SECTION: DRIVE 36 | * ***********************/ 37 | // Basic drive.. 38 | 39 | #ifndef FH_DDR_START 40 | #define FH_DDR_START 0xA0000000 41 | #define FH_DDR_END 0xA1000000 42 | 43 | #define FH_RTT_OS_MEM_SIZE 0x00600000 44 | #define FH_DMA_MEM_SIZE 0x20000 /* 128k */ 45 | 46 | #define FH_RTT_OS_MEM_END (FH_DDR_START + FH_RTT_OS_MEM_SIZE) 47 | #define FH_SDK_MEM_START (FH_RTT_OS_MEM_END + FH_DMA_MEM_SIZE) 48 | #define FH_RTT_OS_HEAP_END FH_SDK_MEM_START 49 | #define FH_SDK_MEM_SIZE (FH_DDR_END - FH_SDK_MEM_START) 50 | 51 | #define MMC_USE_INTERNAL_BUF 52 | #define MMC_INTERNAL_DMA_BUF_SIZE (16 * 1024) 53 | #endif 54 | /* *********************** 55 | * SECTION: DRIVE COMPONENT 56 | * ***********************/ 57 | #define UART_NAME "uart1" 58 | #define RT_USING_DMA_MEM 59 | 60 | #define RT_USING_MCI0 61 | #define RT_USING_GD 62 | #define RT_USING_FLASH_DEFAULT 63 | #define RT_USING_FH_FLASH_ADAPT 64 | 65 | #endif /* BOARD_H_ */ 66 | -------------------------------------------------------------------------------- /firmware/platform/fh8620/iot_cam/readme: -------------------------------------------------------------------------------- 1 | IoT Camera 2 | powered by RT-Thread 3 | V1.0 4 | 2016-3-14 -------------------------------------------------------------------------------- /firmware/platform/fh8620/iot_cam/startup.c: -------------------------------------------------------------------------------- 1 | /* 2 | * File : startup.c 3 | * This file is part of FH8620 BSP for RT-Thread distribution. 4 | * 5 | * Copyright (c) 2016 Shanghai Fullhan Microelectronics Co., Ltd. 6 | * All rights reserved 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License along 19 | * with this program; if not, write to the Free Software Foundation, Inc., 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | * 22 | * Visit http://www.fullhan.com to get contact with Fullhan. 23 | * 24 | * Change Logs: 25 | * Date Author Notes 26 | */ 27 | 28 | #include 29 | #include 30 | #include 31 | 32 | -------------------------------------------------------------------------------- /firmware/platform/fh_arch.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File : fh_arch.h 3 | * This file is part of FH8620 BSP for RT-Thread distribution. 4 | * 5 | * Copyright (c) 2016 Shanghai Fullhan Microelectronics Co., Ltd. 6 | * All rights reserved 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License along 19 | * with this program; if not, write to the Free Software Foundation, Inc., 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | * 22 | * Visit http://www.fullhan.com to get contact with Fullhan. 23 | * 24 | * Change Logs: 25 | * Date Author Notes 26 | */ 27 | 28 | #ifndef FH_ARCH_H_ 29 | #define FH_ARCH_H_ 30 | 31 | #ifdef CONFIG_CHIP_FH8620 32 | #include "plat-v2/arch.h" 33 | #endif 34 | 35 | #ifdef CONFIG_CHIP_FH8620G 36 | #include "plat-v2/arch.h" 37 | #endif 38 | 39 | #ifdef CONFIG_CHIP_FH8810 40 | #include "plat-v2/arch.h" 41 | #endif 42 | 43 | #endif /* FH_ARCH_H_ */ 44 | -------------------------------------------------------------------------------- /firmware/platform/fh_def.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File : fh_def.h 3 | * This file is part of FH8620 BSP for RT-Thread distribution. 4 | * 5 | * Copyright (c) 2016 Shanghai Fullhan Microelectronics Co., Ltd. 6 | * All rights reserved 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License along 19 | * with this program; if not, write to the Free Software Foundation, Inc., 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | * 22 | * Visit http://www.fullhan.com to get contact with Fullhan. 23 | * 24 | * Change Logs: 25 | * Date Author Notes 26 | */ 27 | 28 | #ifndef FH_DEF_H_ 29 | #define FH_DEF_H_ 30 | 31 | #define MIN(a, b) ((a) < (b) ? (a) : (b)) 32 | #define MAX(a, b) ((a) > (b) ? (a) : (b)) 33 | 34 | typedef char SINT8; 35 | typedef short SINT16; 36 | typedef int SINT32; 37 | typedef long long SINT64; 38 | typedef unsigned char UINT8; 39 | typedef unsigned short UINT16; 40 | typedef unsigned int UINT32; 41 | typedef unsigned long long UINT64; 42 | 43 | #ifndef TYPE_DEFINED 44 | typedef unsigned char uchar; 45 | typedef signed char int8; 46 | typedef unsigned char uint8; 47 | typedef signed short int16; 48 | typedef unsigned short uint16; 49 | typedef signed int int32; 50 | typedef unsigned int uint32; 51 | typedef signed long long int64; 52 | typedef unsigned long long uint64; 53 | typedef float ieee_single; 54 | typedef double ieee_double; 55 | 56 | typedef unsigned char boolean; 57 | 58 | #define TYPE_DEFINED 59 | 60 | #endif 61 | 62 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) 63 | 64 | #define reg_read(addr) (*((volatile UINT32 *)(addr))) 65 | #define reg_write(addr, value) (*(volatile UINT32 *)(addr) = (value)) 66 | 67 | #define GET_REG(addr) reg_read(addr) 68 | #define SET_REG(addr, value) reg_write(addr, value) 69 | #define SET_REG_M(addr, value, mask) \ 70 | reg_write(addr, (reg_read(addr) & (~(mask))) | ((value) & (mask))) 71 | #define SET_REG_B(addr, element, highbit, lowbit) \ 72 | SET_REG_M((addr), ((element) << (lowbit)), \ 73 | (((1 << ((highbit) - (lowbit) + 1)) - 1) << (lowbit))) 74 | 75 | #define GET_REG8(addr) (*((volatile UINT8 *)(addr))) 76 | #define SET_REG8(addr, value) (*(volatile UINT8 *)(addr) = (value)) 77 | 78 | #define read_reg(addr) (*((volatile uint32 *)(addr))) 79 | #define write_reg(addr, reg) (*((volatile uint32 *)(addr))) = (uint32)(reg) 80 | #define inw(addr) (*((volatile uint32 *)(addr))) 81 | #define outw(addr, reg) (*((volatile uint32 *)(addr))) = (uint32)(reg) 82 | #ifndef BIT 83 | #define BIT(nr) (1UL << (nr)) 84 | #endif 85 | 86 | typedef volatile const unsigned int 87 | RoReg; /**< Read only 32-bit register (volatile const unsigned int) */ 88 | typedef volatile unsigned int 89 | WoReg; /**< Write only 32-bit register (volatile unsigned int) */ 90 | typedef volatile unsigned int 91 | RwReg; /**< Read-Write 32-bit register (volatile unsigned int) */ 92 | 93 | #endif /* FH_DEF_H_ */ 94 | -------------------------------------------------------------------------------- /firmware/platform/plat-v2/SConscript: -------------------------------------------------------------------------------- 1 | from building import * 2 | 3 | cwd = GetCurrentDir() 4 | src = Glob('*.c') 5 | 6 | path = [cwd, cwd + '/..'] 7 | 8 | group = DefineGroup('Platform', src, depend = [], CPPPATH = path) 9 | 10 | Return('group') 11 | -------------------------------------------------------------------------------- /firmware/platform/plat-v2/arch.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File : arch.h 3 | * This file is part of FH8620 BSP for RT-Thread distribution. 4 | * 5 | * Copyright (c) 2016 Shanghai Fullhan Microelectronics Co., Ltd. 6 | * All rights reserved 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License along 19 | * with this program; if not, write to the Free Software Foundation, Inc., 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | * 22 | * Visit http://www.fullhan.com to get contact with Fullhan. 23 | * 24 | * Change Logs: 25 | * Date Author Notes 26 | */ 27 | 28 | #ifndef ARCH_H_ 29 | #define ARCH_H_ 30 | 31 | /*****************************/ 32 | /* BSP CONTROLLER BASE */ 33 | /*****************************/ 34 | #define INTC_REG_BASE (0xE0200000) 35 | #define SDC0_REG_BASE (0xE2000000) 36 | #define SDC1_REG_BASE (0xE2100000) 37 | #define TVE_REG_BASE (0xE8000000) 38 | #define VOU_REG_BASE (0xE8100000) 39 | #define AES_REG_BASE (0xE8200000) 40 | /* 41 | #define JPEG_REG_BASE (0xE8300000) 42 | #define ISPB_REG_BASE (0xEA000000) 43 | #define ISPF_REG_BASE (0xEA100000) 44 | #define VPU_REG_BASE (0xEC000000) 45 | #define VCU_REG_BASE (0xEC100000) 46 | #define DDRC_REG_BASE (0xED000000) 47 | */ 48 | #define DMAC_REG_BASE (0xEE000000) 49 | #define GMAC_REG_BASE (0xEF000000) 50 | #define PMU_REG_BASE (0xF0000000) 51 | #define I2C0_REG_BASE (0xF0200000) 52 | #define GPIO0_REG_BASE (0xF0300000) 53 | #define GPIO1_REG_BASE (0xf4000000) 54 | #define PWM_REG_BASE (0xF0400000) 55 | #define SPI0_REG_BASE (0xF0500000) 56 | #define SPI1_REG_BASE (0xF0600000) 57 | #define UART0_REG_BASE (0xF0700000) 58 | #define UART1_REG_BASE (0xF0800000) 59 | /*#define I2S_REG_BASE (0xF0900000)*/ 60 | #define ACODEC_REG_BASE (0xF0A00000) 61 | #define I2C1_REG_BASE (0xF0B00000) 62 | #define TMR_REG_BASE (0xF0C00000) 63 | #define WDT_REG_BASE (0xF0D00000) 64 | /* 65 | #define DPHY_REG_BASE (0xF1000000) 66 | #define MIPIC_REG_BASE (0xF1100000) 67 | */ 68 | #define SADC_REG_BASE (0xF1200000) 69 | 70 | typedef enum IRQn { 71 | PAE_IRQn = 0, 72 | VPU_IRQn = 1, 73 | ISP_F_IRQn = 2, 74 | ISP_B_IRQn = 3, 75 | VOU_IRQn = 4, 76 | JPEG_IRQn = 5, 77 | TVE_IRQn = 6, 78 | TOE_IRQn = 7, 79 | DDRC_IRQn = 8, 80 | DMAC_IRQn = 9, 81 | AES_IRQn = 10, 82 | MIPIC_IRQn = 11, 83 | MIPI_WRAP_IRQn = 12, 84 | PMU_IRQn = 13, 85 | EMAC_IRQn = 14, 86 | AXIC0_IRQn = 16, 87 | AXIC1_IRQn = 17, 88 | X2H0_IRQn = 18, 89 | X2H1_IRQn = 19, 90 | AHBC0_IRQn = 20, 91 | AHBC1_IRQn = 21, 92 | SADC_IRQn = 23, 93 | SDC0_IRQn = 24, 94 | SDC1_IRQn = 25, 95 | ACW_IRQn = 26, 96 | WDT_IRQn = 27, 97 | SPI0_IRQn = 28, 98 | SPI1_IRQn = 29, 99 | UART0_IRQn = 30, 100 | UART1_IRQn = 31, 101 | I2S0_IRQn = 32, 102 | I2S1_IRQn = 33, 103 | RTC_IRQn = 34, 104 | PWM_IRQn = 35, 105 | TMR0_IRQn = 36, 106 | TMR1_IRQn = 37, 107 | USB0_IRQn = 38, 108 | USB1_IRQn = 39, 109 | GPIO0_IRQn = 40, 110 | GPIO1_IRQn = 41, 111 | I2C0_IRQn = 42, 112 | I2C1_IRQn = 43, 113 | 114 | } IRQn_Type; 115 | 116 | #endif /* ARCH_H_ */ 117 | -------------------------------------------------------------------------------- /firmware/platform/plat-v2/calibrate.c: -------------------------------------------------------------------------------- 1 | #include "fh_def.h" 2 | #include 3 | #include 4 | 5 | #if defined(FH_CALIBRATE_DEBUG) && defined(RT_DEBUG) 6 | #define FH_CALIBRATE_DEBUG(fmt, args...) \ 7 | do \ 8 | { \ 9 | rt_kprintf("FH_CALIBRATE_DEBUG: "); \ 10 | rt_kprintf(fmt, ##args); \ 11 | } while (0) 12 | #else 13 | #define FH_CALIBRATE_DEBUG(fmt, args...) \ 14 | do \ 15 | { \ 16 | } while (0) 17 | #endif 18 | 19 | unsigned long lpj_fine; 20 | unsigned long preset_lpj; 21 | unsigned long loops_per_jiffy = (1 << 12); 22 | static unsigned long calibrate_delay_converge(void); 23 | 24 | /* 25 | * This is the number of bits of precision for the loops_per_jiffy. Each 26 | * time we refine our estimate after the first takes 1.5/HZ seconds, so try 27 | * to start with a good estimate. 28 | * For the boot cpu we can skip the delay calibration and assign it a value 29 | * calculated based on the timer frequency. 30 | * For the rest of the CPUs we cannot assume that the timer frequency is same as 31 | * the cpu frequency, hence do the calibration for those. 32 | */ 33 | #define LPS_PREC 8 34 | 35 | static unsigned long calibrate_delay_converge(void) 36 | { 37 | /* First stage - slowly accelerate to find initial bounds */ 38 | unsigned long lpj, lpj_base, ticks, loopadd, loopadd_base, chop_limit; 39 | int trials = 0, band = 0, trial_in_band = 0; 40 | 41 | lpj = (1 << 12); 42 | 43 | /* wait for "start of" clock tick */ 44 | ticks = rt_tick_get(); 45 | while (ticks == rt_tick_get()) 46 | ; /* nothing */ 47 | /* Go .. */ 48 | ticks = rt_tick_get(); 49 | do 50 | { 51 | if (++trial_in_band == (1 << band)) 52 | { 53 | ++band; 54 | trial_in_band = 0; 55 | } 56 | __delay(lpj * band); 57 | trials += band; 58 | } while (ticks == rt_tick_get()); 59 | /* 60 | * We overshot, so retreat to a clear underestimate. Then estimate 61 | * the largest likely undershoot. This defines our chop bounds. 62 | */ 63 | trials -= band; 64 | loopadd_base = lpj * band; 65 | lpj_base = lpj * trials; 66 | 67 | FH_CALIBRATE_DEBUG("trials: %d, loopadd_base: %lu, lpj_base: %lu\n", trials, 68 | loopadd_base, lpj_base); 69 | 70 | recalibrate: 71 | lpj = lpj_base; 72 | loopadd = loopadd_base; 73 | 74 | /* 75 | * Do a binary approximation to get lpj set to 76 | * equal one clock (up to LPS_PREC bits) 77 | */ 78 | chop_limit = lpj >> LPS_PREC; 79 | while (loopadd > chop_limit) 80 | { 81 | lpj += loopadd; 82 | ticks = rt_tick_get(); 83 | while (ticks == rt_tick_get()) 84 | ; /* nothing */ 85 | ticks = rt_tick_get(); 86 | __delay(lpj); 87 | if (rt_tick_get() != ticks) /* longer than 1 tick */ 88 | lpj -= loopadd; 89 | loopadd >>= 1; 90 | } 91 | /* 92 | * If we incremented every single time possible, presume we've 93 | * massively underestimated initially, and retry with a higher 94 | * start, and larger range. (Only seen on x86_64, due to SMIs) 95 | */ 96 | if (lpj + loopadd * 2 == lpj_base + loopadd_base * 2) 97 | { 98 | lpj_base = lpj; 99 | loopadd_base <<= 2; 100 | goto recalibrate; 101 | } 102 | 103 | return lpj; 104 | } 105 | 106 | void calibrate_delay(void) 107 | { 108 | unsigned long lpj; 109 | static rt_bool_t printed; 110 | 111 | if (preset_lpj) 112 | { 113 | lpj = preset_lpj; 114 | if (!printed) 115 | FH_CALIBRATE_DEBUG( 116 | "Calibrating delay loop (skipped) " 117 | "preset value.. "); 118 | } 119 | else if ((!printed) && lpj_fine) 120 | { 121 | lpj = lpj_fine; 122 | FH_CALIBRATE_DEBUG( 123 | "Calibrating delay loop (skipped), " 124 | "value calculated using timer frequency.. "); 125 | } 126 | else 127 | { 128 | if (!printed) FH_CALIBRATE_DEBUG("Calibrating delay loop... "); 129 | lpj = calibrate_delay_converge(); 130 | } 131 | 132 | if (!printed) 133 | FH_CALIBRATE_DEBUG("%lu.%02lu BogoMIPS (lpj=%lu)\n", 134 | lpj / (500000 / RT_TICK_PER_SECOND), 135 | (lpj / (5000 / RT_TICK_PER_SECOND)) % 100, lpj); 136 | 137 | loops_per_jiffy = lpj; 138 | printed = RT_TRUE; 139 | } 140 | -------------------------------------------------------------------------------- /firmware/platform/plat-v2/calibrate.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void calibrate_delay(void); 4 | -------------------------------------------------------------------------------- /firmware/platform/plat-v2/clock.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File : clock.h 3 | * This file is part of FH8620 BSP for RT-Thread distribution. 4 | * 5 | * Copyright (c) 2016 Shanghai Fullhan Microelectronics Co., Ltd. 6 | * All rights reserved 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License along 19 | * with this program; if not, write to the Free Software Foundation, Inc., 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | * 22 | * Visit http://www.fullhan.com to get contact with Fullhan. 23 | * 24 | * Change Logs: 25 | * Date Author Notes 26 | */ 27 | 28 | #ifndef CLOCK_H_ 29 | #define CLOCK_H_ 30 | 31 | #include 32 | 33 | void rt_hw_clock_init(void); 34 | void rt_hw_get_clock(void); 35 | void rt_hw_set_dividor(rt_uint8_t hdivn, rt_uint8_t pdivn); 36 | void rt_hw_set_clock(rt_uint8_t sdiv, rt_uint8_t pdiv, rt_uint8_t mdiv); 37 | 38 | struct fh_clk; 39 | /* 40 | void fh_pmu_open(void); 41 | void fh_pmu_close(void); 42 | */ 43 | 44 | #define DIFF_SDC_REFCLK_0 (0) 45 | #define DIFF_SDC_REFCLK_90 (1) 46 | #define DIFF_SDC_REFCLK_180 (2) 47 | #define DIFF_SDC_REFCLK_270 (3) 48 | #define SDC_CLK_PARA_ERROR (0xffff0000) 49 | #define SDC_CLK_PARA_OK (0) 50 | 51 | void clk_gate(struct fh_clk *p_clk); 52 | void clk_ungate(struct fh_clk *p_clk); 53 | struct fh_clk *clk_get(const char *name); 54 | rt_uint32_t clk_get_rate(struct fh_clk *p_clk); 55 | void clk_set_rate(struct fh_clk *p_clk, rt_uint32_t rate_value); 56 | rt_uint32_t sdc_get_phase(struct fh_clk *p_clk); 57 | rt_uint32_t sdc_set_phase(struct fh_clk *p_clk, rt_uint32_t phase); 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /firmware/platform/plat-v2/fh_pmu.c: -------------------------------------------------------------------------------- 1 | /* 2 | * File : fh_pmu.c 3 | * This file is part of FH8620 BSP for RT-Thread distribution. 4 | * 5 | * Copyright (c) 2016 Shanghai Fullhan Microelectronics Co., Ltd. 6 | * All rights reserved 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License along 19 | * with this program; if not, write to the Free Software Foundation, Inc., 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | * 22 | * Visit http://www.fullhan.com to get contact with Fullhan. 23 | * 24 | * Change Logs: 25 | * Date Author Notes 26 | */ 27 | 28 | #include "rtthread.h" 29 | #include "rtdebug.h" 30 | #include "arch.h" 31 | #include "fh_pmu.h" 32 | #include "fh_def.h" 33 | 34 | #define FH_PMU_WRITEL(offset, value) SET_REG((PMU_REG_BASE + offset), value) 35 | #define FH_PMU_WRITEL_MASK(offset, value, mask) \ 36 | SET_REG_M((PMU_REG_BASE + offset), value, mask) 37 | #define FH_PMU_READL(offset) GET_REG((PMU_REG_BASE + offset)) 38 | 39 | #define PMU_OFFSET_MAX 0x1d0 40 | 41 | int fh_pmu_read(rt_uint32_t offset, rt_uint32_t *value) 42 | { 43 | RT_ASSERT(offset < PMU_OFFSET_MAX); 44 | 45 | *value = FH_PMU_READL(offset); 46 | return 0; 47 | } 48 | 49 | int fh_pmu_write(rt_uint32_t offset, const rt_uint32_t value) 50 | { 51 | RT_ASSERT(offset < PMU_OFFSET_MAX); 52 | 53 | FH_PMU_WRITEL(offset, value); 54 | return 0; 55 | } 56 | 57 | int fh_pmu_write_mask(rt_uint32_t offset, const rt_uint32_t value, 58 | const rt_uint32_t mask) 59 | { 60 | RT_ASSERT(offset < PMU_OFFSET_MAX); 61 | 62 | FH_PMU_WRITEL_MASK(offset, value, mask); 63 | return 0; 64 | } 65 | -------------------------------------------------------------------------------- /firmware/platform/plat-v2/fh_pmu.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File : fh_pmu.h 3 | * This file is part of FH8620 BSP for RT-Thread distribution. 4 | * 5 | * Copyright (c) 2016 Shanghai Fullhan Microelectronics Co., Ltd. 6 | * All rights reserved 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License along 19 | * with this program; if not, write to the Free Software Foundation, Inc., 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | * 22 | * Visit http://www.fullhan.com to get contact with Fullhan. 23 | * 24 | * Change Logs: 25 | * Date Author Notes 26 | */ 27 | 28 | #ifndef FH_PMU_H_ 29 | #define FH_PMU_H_ 30 | 31 | #include 32 | 33 | #define REG_PMU_CHIP_ID (0x000) 34 | #define REG_PMU_IP_VER (0x004) 35 | #define REG_PMU_FW_VER (0x008) 36 | #define REG_PMU_SYS_CTRL (0x00c) 37 | #define REG_PMU_PLL0_CTRL (0x010) 38 | #define REG_PMU_PLL1_CTRL (0x014) 39 | #define REG_PMU_ARC_CLK_GATE (0x018) 40 | #define REG_PMU_CLK_GATE (0x01c) 41 | #define REG_PMU_CLK_SEL (0x020) 42 | #define REG_PMU_CLK_DIV0 (0x024) 43 | #define REG_PMU_CLK_DIV1 (0x028) 44 | #define REG_PMU_CLK_DIV2 (0x02c) 45 | #define REG_PMU_CLK_DIV3 (0x030) 46 | #define REG_PMU_CLK_DIV4 (0x034) 47 | #define REG_PMU_CLK_DIV5 (0x038) 48 | #define REG_PMU_CLK_DIV6 (0x03c) 49 | #define REG_PMU_SWRST_MAIN_CTRL (0x040) 50 | #define REG_PMU_SWRST_AXI_CTRL (0x044) 51 | #define REG_PMU_SWRST_AHB_CTRL (0x048) 52 | #define REG_PMU_SWRST_APB_CTRL (0x04c) 53 | #define REG_PMU_VDAC_CTRL (0x050) 54 | #define REG_PMU_MAC_REF_CLK_CFG (0x0a4) 55 | #define REG_PMU_PAD_MAC_TXER_CFG (0x1cc) 56 | 57 | int fh_pmu_read(rt_uint32_t offset, rt_uint32_t *value); 58 | int fh_pmu_write(rt_uint32_t offset, const rt_uint32_t value); 59 | int fh_pmu_write_mask(rt_uint32_t offset, const rt_uint32_t value, 60 | const rt_uint32_t mask); 61 | 62 | #endif /* FH_PMU_H_ */ 63 | -------------------------------------------------------------------------------- /firmware/platform/plat-v2/reset.c: -------------------------------------------------------------------------------- 1 | /* 2 | * File : reset.c 3 | * This file is part of FH8620 BSP for RT-Thread distribution. 4 | * 5 | * Copyright (c) 2016 Shanghai Fullhan Microelectronics Co., Ltd. 6 | * All rights reserved 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License along 19 | * with this program; if not, write to the Free Software Foundation, Inc., 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | * 22 | * Visit http://www.fullhan.com to get contact with Fullhan. 23 | * 24 | * Change Logs: 25 | * Date Author Notes 26 | */ 27 | 28 | #include 29 | #include 30 | #include "fh_pmu.h" 31 | #include "fh_def.h" 32 | #include "fh_arch.h" 33 | 34 | void machine_reset(void) { fh_pmu_write(REG_PMU_SWRST_MAIN_CTRL, 0x7fffffff); } 35 | void machine_shutdown(void) 36 | { 37 | while (1) 38 | ; 39 | } 40 | 41 | #ifdef RT_USING_FINSH 42 | #include 43 | FINSH_FUNCTION_EXPORT_ALIAS(rt_hw_cpu_reset, reset, system reset); 44 | #endif 45 | 46 | /*@}*/ 47 | -------------------------------------------------------------------------------- /firmware/platform/plat-v2/timer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File : timer.h 3 | * This file is part of FH8620 BSP for RT-Thread distribution. 4 | * 5 | * Copyright (c) 2016 Shanghai Fullhan Microelectronics Co., Ltd. 6 | * All rights reserved 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License along 19 | * with this program; if not, write to the Free Software Foundation, Inc., 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | * 22 | * Visit http://www.fullhan.com to get contact with Fullhan. 23 | * 24 | * Change Logs: 25 | * Date Author Notes 26 | */ 27 | 28 | #ifndef TIMER_H_ 29 | #define TIMER_H_ 30 | 31 | #include 32 | 33 | struct fh_timer 34 | { 35 | struct rt_object parent; /**< inherit from rt_object */ 36 | 37 | rt_list_t list; 38 | 39 | void (*timeout_func)(void *parameter); /**< timeout function */ 40 | void *parameter; /**< timeout function's parameter */ 41 | 42 | rt_uint32_t init_cycle; /**< timer inited cycle */ 43 | rt_uint32_t timeout_tick; /**< timeout cycle*/ 44 | }; 45 | 46 | void rt_hw_timer_init(void); 47 | void clocksource_pts_register(void); 48 | void clockevent_timer0_register(void); 49 | #endif 50 | -------------------------------------------------------------------------------- /firmware/platform/platform_def.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File : platform_def.h 3 | * This file is part of FH8620 BSP for RT-Thread distribution. 4 | * 5 | * Copyright (c) 2016 Shanghai Fullhan Microelectronics Co., Ltd. 6 | * All rights reserved 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License along 19 | * with this program; if not, write to the Free Software Foundation, Inc., 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | * 22 | * Visit http://www.fullhan.com to get contact with Fullhan. 23 | * 24 | * Change Logs: 25 | * Date Author Notes 26 | */ 27 | 28 | #ifndef PLATFORM_DEF_H_ 29 | #define PLATFORM_DEF_H_ 30 | 31 | #ifdef CONFIG_CHIP_FH8620 32 | #ifdef CONFIG_BOARD_DEV 33 | #include "fh8620/dev_board/board_def.h" 34 | #endif 35 | #endif 36 | 37 | #ifdef CONFIG_CHIP_FH8620 38 | #ifdef CONFIG_BOARD_TEST 39 | #include "fh8620/test_board/board_def.h" 40 | #endif 41 | #endif 42 | 43 | #ifdef CONFIG_CHIP_FH8620 44 | #ifdef CONFIG_BOARD_IOTCAM 45 | #include "fh8620/iot_cam/board_def.h" 46 | #endif 47 | #endif 48 | 49 | #ifdef CONFIG_CHIP_FH8620G 50 | #ifdef CONFIG_BOARD_DEV 51 | #include "fh8620g/dev_board/board_def.h" 52 | #endif 53 | #endif 54 | 55 | #ifdef CONFIG_CHIP_FH8620G 56 | #ifdef CONFIG_BOARD_TEST 57 | #include "fh8620g/test_board/board_def.h" 58 | #endif 59 | #endif 60 | 61 | #ifdef CONFIG_CHIP_FH8810 62 | #ifdef CONFIG_BOARD_DEV 63 | #include "fh8810/dev_board/board_def.h" 64 | #endif 65 | #endif 66 | 67 | #ifdef CONFIG_CHIP_FH8810 68 | #ifdef CONFIG_BOARD_TEST 69 | #include "fh8810/test_board/board_def.h" 70 | #endif 71 | #endif 72 | 73 | #endif /* TEST_H_ */ 74 | -------------------------------------------------------------------------------- /firmware/rtconfig.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | import re 4 | 5 | # toolchains options 6 | ARCH = 'arm' 7 | CPU = 'armv6' 8 | OUTPUT_NAME = 'rtthread' 9 | CROSS_TOOL = 'gcc' # we use gcc compiler always 10 | PLATFORM = 'gcc' 11 | LD_NAME = 'link' 12 | 13 | EXEC_PATH = r'arm-2014.05/bin' 14 | if os.getenv('RTT_EXEC_PATH'): 15 | EXEC_PATH = os.getenv('RTT_EXEC_PATH') 16 | 17 | if os.getenv('RTT_ROOT'): 18 | RTT_ROOT = os.getenv('RTT_ROOT') 19 | 20 | BUILD = 'release' 21 | 22 | if PLATFORM == 'gcc': 23 | # toolchains 24 | PREFIX = 'arm-none-eabi-' 25 | CC = PREFIX + 'gcc' 26 | CXX = PREFIX + 'g++' 27 | AS = PREFIX + 'gcc' 28 | AR = PREFIX + 'ar' 29 | LINK = PREFIX + 'g++' 30 | TARGET_EXT = '.elf' 31 | SIZE = PREFIX + 'size' 32 | OBJDUMP = PREFIX + 'objdump' 33 | OBJCPY = PREFIX + 'objcopy' 34 | STRIP = PREFIX + 'strip' 35 | 36 | DEVICE = ' -mcpu=arm1176jzf-s -mfpu=vfp -mfloat-abi=soft' 37 | CFLAGS = DEVICE + ' -mno-unaligned-access -Wall' 38 | CFLAGS += ' -Wno-error=sequence-point ' 39 | CFLAGS += ' -fno-strict-aliasing ' 40 | CFLAGS += ' -Wno-address ' 41 | AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp -D__ASSEMBLY__' 42 | LFLAGS = DEVICE + ' -nostartfiles -Wl,--gc-sections,-Map='+ OUTPUT_NAME +'.map,-cref,-u,_start -T' + LD_NAME +'.ld' 43 | CPATH = '' 44 | LPATH = '' 45 | if BUILD == 'debug': 46 | CFLAGS += ' -O0 -gdwarf-2 ' 47 | AFLAGS += ' -gdwarf-2' 48 | else: 49 | CFLAGS += ' -O2' 50 | 51 | CXXFLAGS = CFLAGS 52 | POST_ACTION = OBJCPY + ' -O binary $TARGET '+ OUTPUT_NAME +'.bin\n' + SIZE + ' $TARGET \n' 53 | 54 | M_CFLAGS = CFLAGS.replace('-O0 -gdwarf-2', '-O2') + ' -mlong-calls -fPIC ' 55 | M_CXXFLAGS = CXXFLAGS.replace('-O0 -gdwarf-2', '-O2') + ' -mlong-calls -fPIC' 56 | M_LFLAGS = DEVICE + CXXFLAGS + ' -Wl,--gc-sections,-z,max-page-size=0x4' +\ 57 | ' -shared -fPIC -nostartfiles -static-libgcc' 58 | M_POST_ACTION = STRIP + ' -R .hash $TARGET\n' + SIZE + ' $TARGET \n' 59 | -------------------------------------------------------------------------------- /hardware/README.md: -------------------------------------------------------------------------------- 1 | # Hardware information 2 | -------------------------------------------------------------------------------- /icons/copy_rtt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RT-Thread/IoT_Camera/1d4eccb6468556a79ebae1b311bf7bd0817ba3b6/icons/copy_rtt.png -------------------------------------------------------------------------------- /icons/fb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RT-Thread/IoT_Camera/1d4eccb6468556a79ebae1b311bf7bd0817ba3b6/icons/fb.png -------------------------------------------------------------------------------- /icons/menuconfig_add_wifi.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RT-Thread/IoT_Camera/1d4eccb6468556a79ebae1b311bf7bd0817ba3b6/icons/menuconfig_add_wifi.gif -------------------------------------------------------------------------------- /icons/scons.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RT-Thread/IoT_Camera/1d4eccb6468556a79ebae1b311bf7bd0817ba3b6/icons/scons.gif --------------------------------------------------------------------------------