├── .gitignore ├── AUTHORS ├── COPYING ├── Dockerfile ├── Makefile ├── README.md ├── board_defs.mk ├── build.sh ├── firmware ├── Interfaces │ ├── APP │ │ ├── ADC │ │ │ ├── ADC.c │ │ │ └── ADC.h │ │ ├── BDM │ │ │ ├── BDM.c │ │ │ └── BDM.h │ │ ├── C2 │ │ │ ├── C2.c │ │ │ └── C2.h │ │ ├── CLKO │ │ │ ├── CLKO.c │ │ │ └── CLKO.h │ │ ├── DUSI │ │ │ ├── DUSI.c │ │ │ └── DUSI.h │ │ ├── EBI │ │ │ ├── EBI.c │ │ │ └── EBI.h │ │ ├── GPIO │ │ │ ├── GPIO.c │ │ │ └── GPIO.h │ │ ├── IIC │ │ │ ├── EMIIC_MOD.h │ │ │ ├── IIC.c │ │ │ ├── IIC.h │ │ │ └── IIC_MOD_Common.h │ │ ├── ISSP │ │ │ ├── ISSP.c │ │ │ └── ISSP.h │ │ ├── JTAG │ │ │ ├── JTAG_TAP.c │ │ │ └── JTAG_TAP.h │ │ ├── LPC_ICP │ │ │ ├── LPC_ICP.c │ │ │ └── LPC_ICP.h │ │ ├── MSP430_JTAG │ │ │ ├── MSP430_JTAG.c │ │ │ └── MSP430_JTAG.h │ │ ├── MicroWire │ │ │ ├── MicroWire.c │ │ │ └── MicroWire.h │ │ ├── PWM │ │ │ ├── PWM.c │ │ │ └── PWM.h │ │ ├── PowerExt │ │ │ ├── PowerExt.c │ │ │ └── PowerExt.h │ │ ├── SDIO │ │ │ ├── SDIO.c │ │ │ └── SDIO.h │ │ ├── SPI │ │ │ ├── SPI.c │ │ │ └── SPI.h │ │ ├── SWD │ │ │ ├── SWD.c │ │ │ └── SWD.h │ │ ├── SWIM │ │ │ ├── SWIM.c │ │ │ └── SWIM.h │ │ └── USART │ │ │ ├── USART.c │ │ │ └── USART.h │ ├── app_interfaces.c │ ├── app_interfaces.h │ └── app_interfaces_const.h ├── Projects │ ├── VSFCore │ │ └── app_cfg.h │ ├── Versaloon │ │ ├── app_cfg.h │ │ ├── port.c │ │ ├── port.h │ │ └── vsf_cfg │ │ │ ├── dal_cfg.h │ │ │ ├── interfaces_cfg.h │ │ │ └── vsf_usbd_cfg.h │ └── hw_cfg_MiniRelease1.h ├── README.md ├── USB_TO_XXX │ ├── CommandProcessor.c │ ├── CommandProcessor.h │ ├── USB_TO_ADC.c │ ├── USB_TO_BDM.c │ ├── USB_TO_C2.c │ ├── USB_TO_CLKO.c │ ├── USB_TO_DAC.c │ ├── USB_TO_DUSI.c │ ├── USB_TO_EBI.c │ ├── USB_TO_GPIO.c │ ├── USB_TO_IIC.c │ ├── USB_TO_ISSP.c │ ├── USB_TO_JTAG_HL.c │ ├── USB_TO_JTAG_LL.c │ ├── USB_TO_JTAG_RAW.c │ ├── USB_TO_LPCICP.c │ ├── USB_TO_MICROWIRE.c │ ├── USB_TO_MSP430_JTAG.c │ ├── USB_TO_POWER.c │ ├── USB_TO_PWM.c │ ├── USB_TO_SPI.c │ ├── USB_TO_SWD.c │ ├── USB_TO_SWIM.c │ ├── USB_TO_USART.c │ ├── USB_TO_XXX.c │ └── USB_TO_XXX.h ├── app_err.h ├── app_io.c ├── app_io.h ├── app_log.h ├── app_type.h ├── license ├── main.c ├── stlink │ ├── stlink.c │ └── stlink.h ├── usb_protocol.h ├── usb_protocol_CDCACM.c ├── usb_protocol_MSC.c ├── usb_protocol_Versaloon.c ├── usb_protocol_stlink.c └── versaloon_usb │ ├── vsfusbd_Versaloon.c │ └── vsfusbd_Versaloon.h ├── flash.sh ├── ld ├── COMMON.ld ├── DEF_CLOAD.ld ├── sections_FLASH.ld └── versaloonSTM32.ld ├── my_vsllink.cfg └── vsf ├── app_type.h ├── compiler ├── ARMGCC │ ├── compiler.h │ ├── compiler_string.c │ └── syscall.c └── GCC │ └── compiler.h ├── dal ├── cfi │ ├── cfi_drv.c │ └── cfi_drv.h ├── dal.c ├── dal.h ├── df25xx │ ├── df25xx_drv.c │ ├── df25xx_drv.h │ └── df25xx_drv_cfg.h ├── df45xx │ ├── df45xx_drv.c │ ├── df45xx_drv.h │ └── df45xx_drv_cfg.h ├── ee24cxx │ ├── ee24cxx_drv.c │ ├── ee24cxx_drv.h │ └── ee24cxx_drv_cfg.h ├── ee93cx6 │ ├── ee93cx6_drv.c │ ├── ee93cx6_drv.h │ └── ee93cx6_drv_cfg.h ├── mal │ ├── mal.c │ ├── mal.h │ └── mal_driver.h ├── mic2826 │ ├── mic2826_drv.c │ ├── mic2826_drv.h │ └── mic2826_drv_cfg.h ├── nand │ ├── nand_drv.c │ └── nand_drv.h ├── nrf24l01 │ ├── nrf24l01_drv.c │ ├── nrf24l01_drv.h │ └── nrf24l01_drv_cfg.h ├── s6b0724 │ ├── s6b0724_drv.c │ ├── s6b0724_drv.h │ └── s6b0724_drv_cfg.h ├── sd │ ├── sd_common.c │ ├── sd_common.h │ ├── sd_sdio_drv.c │ ├── sd_sdio_drv.h │ ├── sd_spi_drv.c │ ├── sd_spi_drv.h │ └── sd_spi_drv_cfg.h ├── sst32hfxx │ ├── sst32hfxx_drv.c │ └── sst32hfxx_drv.h ├── stream │ ├── stream.c │ └── stream.h └── usart_stream │ ├── usart_stream.c │ └── usart_stream.h ├── interfaces ├── cpu │ ├── pc │ │ ├── app_err.h │ │ ├── app_interfaces.h │ │ ├── app_io.h │ │ ├── app_log.c │ │ ├── app_log.h │ │ ├── app_string.h │ │ ├── driver │ │ │ ├── port.h │ │ │ └── usb │ │ │ │ ├── usbapi.c │ │ │ │ └── usbapi.h │ │ ├── interfaces_const.h │ │ ├── usbtoxxx │ │ │ ├── usbtoadc.c │ │ │ ├── usbtoclko.c │ │ │ ├── usbtoebi.c │ │ │ ├── usbtogpio.c │ │ │ ├── usbtoi2c.c │ │ │ ├── usbtomicrowire.c │ │ │ ├── usbtonand.c │ │ │ ├── usbtopwm.c │ │ │ ├── usbtospi.c │ │ │ ├── usbtousart.c │ │ │ ├── usbtoxxx.c │ │ │ ├── usbtoxxx.h │ │ │ └── usbtoxxx_internal.h │ │ ├── versaloon.c │ │ ├── versaloon.h │ │ ├── versaloon_include.h │ │ ├── versaloon_internal.h │ │ ├── versaloon_libusb.c │ │ ├── versaloon_libusb.h │ │ └── vsf_basetype.h │ └── stm32 │ │ ├── adc │ │ ├── STM32_ADC.c │ │ └── STM32_ADC.h │ │ ├── clko │ │ ├── STM32_CLKO.c │ │ └── STM32_CLKO.h │ │ ├── core.c │ │ ├── core.h │ │ ├── ebi │ │ ├── STM32_EBI.c │ │ └── STM32_EBI.h │ │ ├── eint │ │ ├── STM32_EINT.c │ │ └── STM32_EINT.h │ │ ├── flash │ │ ├── STM32_FLASH.c │ │ └── STM32_FLASH.h │ │ ├── gpio │ │ ├── STM32_GPIO.c │ │ └── STM32_GPIO.h │ │ ├── hw │ │ ├── STM32F10x_Lib │ │ │ └── Libraries │ │ │ │ ├── CMSIS │ │ │ │ ├── CM3 │ │ │ │ │ ├── CoreSupport │ │ │ │ │ │ ├── core_cm3.c │ │ │ │ │ │ └── core_cm3.h │ │ │ │ │ └── DeviceSupport │ │ │ │ │ │ └── ST │ │ │ │ │ │ ├── Release_Notes_for_STM32F10x_CMSIS.html │ │ │ │ │ │ └── STM32F10x │ │ │ │ │ │ ├── startup │ │ │ │ │ │ ├── TrueSTUDIO │ │ │ │ │ │ │ ├── startup_stm32f10x_cl.s │ │ │ │ │ │ │ ├── startup_stm32f10x_hd.s │ │ │ │ │ │ │ ├── startup_stm32f10x_ld.s │ │ │ │ │ │ │ ├── startup_stm32f10x_ld_vl.s │ │ │ │ │ │ │ ├── startup_stm32f10x_md.s │ │ │ │ │ │ │ ├── startup_stm32f10x_md_vl.s │ │ │ │ │ │ │ └── startup_stm32f10x_xl.s │ │ │ │ │ │ ├── arm │ │ │ │ │ │ │ ├── startup_stm32f10x_cl.s │ │ │ │ │ │ │ ├── startup_stm32f10x_hd.s │ │ │ │ │ │ │ ├── startup_stm32f10x_ld.s │ │ │ │ │ │ │ ├── startup_stm32f10x_ld_vl.s │ │ │ │ │ │ │ ├── startup_stm32f10x_md.s │ │ │ │ │ │ │ ├── startup_stm32f10x_md_vl.s │ │ │ │ │ │ │ └── startup_stm32f10x_xl.s │ │ │ │ │ │ ├── gcc_ride7 │ │ │ │ │ │ │ ├── startup_stm32f10x_cl.s │ │ │ │ │ │ │ ├── startup_stm32f10x_hd.s │ │ │ │ │ │ │ ├── startup_stm32f10x_ld.s │ │ │ │ │ │ │ ├── startup_stm32f10x_ld_vl.s │ │ │ │ │ │ │ ├── startup_stm32f10x_md.s │ │ │ │ │ │ │ ├── startup_stm32f10x_md_vl.s │ │ │ │ │ │ │ └── startup_stm32f10x_xl.s │ │ │ │ │ │ └── iar │ │ │ │ │ │ │ ├── startup_stm32f10x_cl.s │ │ │ │ │ │ │ ├── startup_stm32f10x_hd.s │ │ │ │ │ │ │ ├── startup_stm32f10x_ld.s │ │ │ │ │ │ │ ├── startup_stm32f10x_ld_vl.s │ │ │ │ │ │ │ ├── startup_stm32f10x_md.s │ │ │ │ │ │ │ ├── startup_stm32f10x_md_vl.s │ │ │ │ │ │ │ └── startup_stm32f10x_xl.s │ │ │ │ │ │ ├── stm32f10x.h │ │ │ │ │ │ ├── system_stm32f10x.c │ │ │ │ │ │ └── system_stm32f10x.h │ │ │ │ ├── CMSIS debug support.htm │ │ │ │ ├── CMSIS_changes.htm │ │ │ │ ├── Documentation │ │ │ │ │ └── CMSIS_Core.htm │ │ │ │ └── License.doc │ │ │ │ ├── STM32F10x_StdPeriph_Driver │ │ │ │ ├── Release_Notes_for_STM32F10x_StdPeriph_Driver.html │ │ │ │ ├── inc │ │ │ │ │ ├── misc.h │ │ │ │ │ ├── stm32f10x_adc.h │ │ │ │ │ ├── stm32f10x_bkp.h │ │ │ │ │ ├── stm32f10x_can.h │ │ │ │ │ ├── stm32f10x_cec.h │ │ │ │ │ ├── stm32f10x_crc.h │ │ │ │ │ ├── stm32f10x_dac.h │ │ │ │ │ ├── stm32f10x_dbgmcu.h │ │ │ │ │ ├── stm32f10x_dma.h │ │ │ │ │ ├── stm32f10x_exti.h │ │ │ │ │ ├── stm32f10x_flash.h │ │ │ │ │ ├── stm32f10x_fsmc.h │ │ │ │ │ ├── stm32f10x_gpio.h │ │ │ │ │ ├── stm32f10x_i2c.h │ │ │ │ │ ├── stm32f10x_iwdg.h │ │ │ │ │ ├── stm32f10x_pwr.h │ │ │ │ │ ├── stm32f10x_rcc.h │ │ │ │ │ ├── stm32f10x_rtc.h │ │ │ │ │ ├── stm32f10x_sdio.h │ │ │ │ │ ├── stm32f10x_spi.h │ │ │ │ │ ├── stm32f10x_tim.h │ │ │ │ │ ├── stm32f10x_usart.h │ │ │ │ │ └── stm32f10x_wwdg.h │ │ │ │ └── src │ │ │ │ │ ├── misc.c │ │ │ │ │ ├── stm32f10x_adc.c │ │ │ │ │ ├── stm32f10x_bkp.c │ │ │ │ │ ├── stm32f10x_can.c │ │ │ │ │ ├── stm32f10x_cec.c │ │ │ │ │ ├── stm32f10x_crc.c │ │ │ │ │ ├── stm32f10x_dac.c │ │ │ │ │ ├── stm32f10x_dbgmcu.c │ │ │ │ │ ├── stm32f10x_dma.c │ │ │ │ │ ├── stm32f10x_exti.c │ │ │ │ │ ├── stm32f10x_flash.c │ │ │ │ │ ├── stm32f10x_fsmc.c │ │ │ │ │ ├── stm32f10x_gpio.c │ │ │ │ │ ├── stm32f10x_i2c.c │ │ │ │ │ ├── stm32f10x_iwdg.c │ │ │ │ │ ├── stm32f10x_pwr.c │ │ │ │ │ ├── stm32f10x_rcc.c │ │ │ │ │ ├── stm32f10x_rtc.c │ │ │ │ │ ├── stm32f10x_sdio.c │ │ │ │ │ ├── stm32f10x_spi.c │ │ │ │ │ ├── stm32f10x_tim.c │ │ │ │ │ ├── stm32f10x_usart.c │ │ │ │ │ └── stm32f10x_wwdg.c │ │ │ │ └── STM32_USB-FS-Device_Driver │ │ │ │ ├── inc │ │ │ │ ├── usb_mem.h │ │ │ │ └── usb_regs.h │ │ │ │ └── src │ │ │ │ ├── usb_mem.c │ │ │ │ └── usb_regs.c │ │ └── stm32f10x_conf.h │ │ ├── interfaces_const.h │ │ ├── sdio │ │ ├── STM32_SDIO.c │ │ └── STM32_SDIO.h │ │ ├── spi │ │ ├── STM32_SPI.c │ │ └── STM32_SPI.h │ │ ├── timer │ │ ├── STM32_TIM.c │ │ └── STM32_TIM.h │ │ ├── usart │ │ ├── STM32_USART.c │ │ └── STM32_USART.h │ │ ├── usbd │ │ ├── STM32_USBD.c │ │ └── STM32_USBD.h │ │ └── vsf_basetype.h ├── interfaces.c └── interfaces.h ├── stack └── usb_device │ ├── class │ ├── CDC │ │ ├── vsfusbd_CDC.c │ │ ├── vsfusbd_CDC.h │ │ ├── vsfusbd_CDCACM.c │ │ └── vsfusbd_CDCACM.h │ ├── HID │ │ ├── vsfusbd_HID.c │ │ └── vsfusbd_HID.h │ └── MSC │ │ ├── SCSI.c │ │ ├── SCSI.h │ │ ├── vsfusbd_MSC_BOT.c │ │ └── vsfusbd_MSC_BOT.h │ ├── vsf_usbd.c │ ├── vsf_usbd.h │ └── vsf_usbd_const.h ├── tool ├── buffer │ ├── buffer.c │ └── buffer.h ├── crc │ ├── crc.c │ └── crc.h ├── fakefat32 │ ├── fakefat32.c │ └── fakefat32.h ├── list │ └── list.h ├── mal_embflash │ ├── mal_embflash.c │ └── mal_embflash.h ├── mal_in_mal │ ├── mal_in_mal.c │ └── mal_in_mal.h └── vsfui_fb │ ├── vsfui_fb.c │ └── vsfui_fb.h └── vsf_err.h /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.bin 3 | *.elf 4 | *.hex 5 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Authors of vsprog: 2 | 3 | SimonQian 4 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:18.04 2 | MAINTAINER Benjamin Henrion 3 | LABEL Description="This image builds a JTAG Versaloon firmware for the STM32 Bluepill board." 4 | 5 | RUN DEBIAN_FRONTEND=noninteractive apt-get update -y -q 6 | RUN DEBIAN_FRONTEND=noninteractive apt-get install -y -q make gcc-arm-none-eabi binutils sudo stm32flash 7 | 8 | ENV user versaloon 9 | RUN useradd -d /home/$user -m -s /bin/bash $user 10 | RUN echo "$user ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/$user 11 | RUN chmod 0440 /etc/sudoers.d/$user 12 | 13 | USER $user 14 | WORKDIR /home/$user 15 | RUN mkdir -pv code 16 | COPY . ./code/ 17 | RUN sudo chown $user.$user -R /home/$user/code 18 | WORKDIR /home/$user/code/ 19 | RUN make 20 | -------------------------------------------------------------------------------- /board_defs.mk: -------------------------------------------------------------------------------- 1 | ######################################################################## 2 | ifeq ($(HW_BOARD),STM32F103C8_BluePill) 3 | ######################################################################## 4 | _HARDWARE_VER = 0x15 5 | FLASH_LOAD_OFFSET = 0x0 6 | HSE_VALUE = 8000000 7 | LD_FILE = ld/versaloonSTM32.ld 8 | TARGET_CHIP = stm32 9 | TARGET_STM32 = XLDensity 10 | USR_DEFS += -DCORE_DEBUG=STM32_DBG_NONE 11 | endif 12 | 13 | USR_DEFS += -DHSE_VALUE=$(HSE_VALUE)UL -DHW_BOARD=$(HW_BOARDà) -D_HARDWARE_VER=$(_HARDWARE_VER) 14 | USR_DEFS += -DFLASH_LOAD_OFFSET=$(FLASH_LOAD_OFFSET) 15 | USR_DEFS += -D__TARGET_CHIP__=$(TARGET_CHIP) 16 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | PROJECT="versaloon" 4 | docker build -t $PROJECT . 5 | docker run -v $PWD:/mnt $PROJECT bash -c "sudo cp -v /home/versaloon/code/*.bin /mnt" 6 | -------------------------------------------------------------------------------- /firmware/Interfaces/APP/ADC/ADC.c: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * Copyright (C) 2008 - 2010 by Simon Qian * 3 | * SimonQian@SimonQian.com * 4 | * * 5 | * Project: Versaloon * 6 | * File: ADC.c * 7 | * Author: SimonQian * 8 | * Versaion: See changelog * 9 | * Purpose: SPI interface implementation file * 10 | * License: See license * 11 | *------------------------------------------------------------------------* 12 | * Change Log: * 13 | * YYYY-MM-DD: What(by Who) * 14 | * 2008-11-07: created(by SimonQian) * 15 | **************************************************************************/ 16 | 17 | #include "app_cfg.h" 18 | #if INTERFACE_ADC_EN 19 | 20 | #include "app_interfaces.h" 21 | #include "ADC.h" 22 | 23 | vsf_err_t adc_init(uint8_t index) 24 | { 25 | switch (index) 26 | { 27 | case 0: 28 | return VSFERR_NONE; 29 | default: 30 | return VSFERR_NOT_SUPPORT; 31 | } 32 | } 33 | 34 | vsf_err_t adc_fini(uint8_t index) 35 | { 36 | switch (index) 37 | { 38 | case 0: 39 | return VSFERR_NONE; 40 | default: 41 | return VSFERR_NOT_SUPPORT; 42 | } 43 | } 44 | 45 | vsf_err_t adc_config(uint8_t index, uint32_t clock_hz, uint8_t mode) 46 | { 47 | switch (index) 48 | { 49 | case 0: 50 | return VSFERR_NONE; 51 | default: 52 | return VSFERR_NOT_SUPPORT; 53 | } 54 | } 55 | 56 | vsf_err_t adc_config_channel(uint8_t index, uint8_t channel, uint8_t cycles) 57 | { 58 | switch (index) 59 | { 60 | case 0: 61 | return VSFERR_NONE; 62 | default: 63 | return VSFERR_NOT_SUPPORT; 64 | } 65 | } 66 | 67 | uint32_t adc_get_max_value(uint8_t index) 68 | { 69 | return 3300; 70 | } 71 | 72 | vsf_err_t adc_calibrate(uint8_t index, uint8_t channel) 73 | { 74 | switch (index) 75 | { 76 | case 0: 77 | return VSFERR_NONE; 78 | default: 79 | return VSFERR_NOT_SUPPORT; 80 | } 81 | } 82 | 83 | vsf_err_t adc_start(uint8_t index, uint8_t channel) 84 | { 85 | switch (index) 86 | { 87 | case 0: 88 | return VSFERR_NONE; 89 | default: 90 | return VSFERR_NOT_SUPPORT; 91 | } 92 | } 93 | 94 | vsf_err_t adc_isready(uint8_t index, uint8_t channel) 95 | { 96 | switch (index) 97 | { 98 | case 0: 99 | return VSFERR_NONE; 100 | default: 101 | return VSFERR_NOT_SUPPORT; 102 | } 103 | } 104 | 105 | uint32_t adc_get(uint8_t index, uint8_t channel) 106 | { 107 | switch (index) 108 | { 109 | case 0: 110 | return 0; 111 | default: 112 | return 0; 113 | } 114 | } 115 | 116 | vsf_err_t adc_sample(uint8_t index, uint8_t channel, uint32_t *voltage) 117 | { 118 | switch (index) 119 | { 120 | case 0: 121 | if (voltage != NULL) 122 | { 123 | *voltage = 0; 124 | } 125 | return VSFERR_NONE; 126 | default: 127 | return VSFERR_NOT_SUPPORT; 128 | } 129 | } 130 | 131 | #endif 132 | -------------------------------------------------------------------------------- /firmware/Interfaces/APP/ADC/ADC.h: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * Copyright (C) 2008 - 2010 by Simon Qian * 3 | * SimonQian@SimonQian.com * 4 | * * 5 | * Project: Versaloon * 6 | * File: ADC.h * 7 | * Author: SimonQian * 8 | * Versaion: See changelog * 9 | * Purpose: ADC interface header file * 10 | * License: See license * 11 | *------------------------------------------------------------------------* 12 | * Change Log: * 13 | * YYYY-MM-DD: What(by Who) * 14 | * 2008-11-07: created(by SimonQian) * 15 | **************************************************************************/ 16 | 17 | vsf_err_t adc_init(uint8_t index); 18 | vsf_err_t adc_fini(uint8_t index); 19 | vsf_err_t adc_config(uint8_t index, uint32_t clock_hz, uint8_t mode); 20 | vsf_err_t adc_config_channel(uint8_t index, uint8_t channel, uint8_t cycles); 21 | uint32_t adc_get_max_value(uint8_t index); 22 | vsf_err_t adc_calibrate(uint8_t index, uint8_t channel); 23 | vsf_err_t adc_start(uint8_t index, uint8_t channel); 24 | vsf_err_t adc_isready(uint8_t index, uint8_t channel); 25 | uint32_t adc_get(uint8_t index, uint8_t channel); 26 | vsf_err_t adc_sample(uint8_t index, uint8_t channel, uint32_t *voltage); 27 | -------------------------------------------------------------------------------- /firmware/Interfaces/APP/BDM/BDM.h: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * Copyright (C) 2008 - 2010 by Simon Qian * 3 | * SimonQian@SimonQian.com * 4 | * * 5 | * Project: Versaloon * 6 | * File: BDM.h * 7 | * Author: SimonQian * 8 | * Versaion: See changelog * 9 | * Purpose: BDM interface header file * 10 | * License: See license * 11 | *------------------------------------------------------------------------* 12 | * Change Log: * 13 | * YYYY-MM-DD: What(by Who) * 14 | * 2008-11-07: created(by SimonQian) * 15 | **************************************************************************/ 16 | 17 | #define BDM_OUT_LEN(token) (((token) & 0x000F) >> 0) 18 | #define BDM_OUT_DLY_CNT(token) (((token) & 0x00C0) >> 6) 19 | #define BDM_IN_LEN(token) (((token) & 0x0F00) >> 8) 20 | #define BDM_ACK(token) (((token) & 0x8000) != 0) 21 | 22 | vsf_err_t bdm_init(uint8_t index); 23 | vsf_err_t bdm_fini(uint8_t index); 24 | vsf_err_t bdm_sync(uint8_t index, uint16_t *khz); 25 | vsf_err_t bdm_transact(uint8_t index, uint8_t *out, uint8_t outlen, uint8_t *in, 26 | uint8_t inlen, uint8_t delay, uint8_t ack); 27 | -------------------------------------------------------------------------------- /firmware/Interfaces/APP/C2/C2.h: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * Copyright (C) 2008 - 2010 by Simon Qian * 3 | * SimonQian@SimonQian.com * 4 | * * 5 | * Project: Versaloon * 6 | * File: C2.h * 7 | * Author: SimonQian * 8 | * Versaion: See changelog * 9 | * Purpose: C2 interface header file * 10 | * License: See license * 11 | *------------------------------------------------------------------------* 12 | * Change Log: * 13 | * YYYY-MM-DD: What(by Who) * 14 | * 2008-11-07: created(by SimonQian) * 15 | **************************************************************************/ 16 | 17 | vsf_err_t c2_init(uint8_t index); 18 | vsf_err_t c2_fini(uint8_t index); 19 | vsf_err_t c2_addr_write(uint8_t index, uint8_t addr); 20 | vsf_err_t c2_addr_read(uint8_t index, uint8_t *data); 21 | vsf_err_t c2_data_read(uint8_t index, uint8_t *data, uint8_t len); 22 | vsf_err_t c2_data_write(uint8_t index, uint8_t *data, uint8_t len); 23 | -------------------------------------------------------------------------------- /firmware/Interfaces/APP/CLKO/CLKO.c: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * Copyright (C) 2008 - 2010 by Simon Qian * 3 | * SimonQian@SimonQian.com * 4 | * * 5 | * Project: Versaloon * 6 | * File: ADC.c * 7 | * Author: SimonQian * 8 | * Versaion: See changelog * 9 | * Purpose: SPI interface implementation file * 10 | * License: See license * 11 | *------------------------------------------------------------------------* 12 | * Change Log: * 13 | * YYYY-MM-DD: What(by Who) * 14 | * 2008-11-07: created(by SimonQian) * 15 | **************************************************************************/ 16 | 17 | #include "app_cfg.h" 18 | #if INTERFACE_CLKO_EN 19 | 20 | #include "app_interfaces.h" 21 | #include "CLKO.h" 22 | 23 | vsf_err_t clko_init(uint8_t index) 24 | { 25 | switch (index) 26 | { 27 | case 0: 28 | return core_interfaces.clko.init(0); 29 | default: 30 | return VSFERR_NOT_SUPPORT; 31 | } 32 | } 33 | 34 | vsf_err_t clko_fini(uint8_t index) 35 | { 36 | switch (index) 37 | { 38 | case 0: 39 | return core_interfaces.clko.fini(0); 40 | default: 41 | return VSFERR_NOT_SUPPORT; 42 | } 43 | } 44 | 45 | vsf_err_t clko_config(uint8_t index, uint32_t kHz) 46 | { 47 | switch (index) 48 | { 49 | case 0: 50 | return core_interfaces.clko.config(0, kHz); 51 | default: 52 | return VSFERR_NOT_SUPPORT; 53 | } 54 | } 55 | 56 | vsf_err_t clko_enable(uint8_t index) 57 | { 58 | switch (index) 59 | { 60 | case 0: 61 | return core_interfaces.clko.enable(0); 62 | default: 63 | return VSFERR_NOT_SUPPORT; 64 | } 65 | } 66 | 67 | vsf_err_t clko_disable(uint8_t index) 68 | { 69 | switch (index) 70 | { 71 | case 0: 72 | return core_interfaces.clko.disable(0); 73 | default: 74 | return VSFERR_NOT_SUPPORT; 75 | } 76 | } 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /firmware/Interfaces/APP/CLKO/CLKO.h: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * Copyright (C) 2008 - 2010 by Simon Qian * 3 | * SimonQian@SimonQian.com * 4 | * * 5 | * Project: Versaloon * 6 | * File: ADC.h * 7 | * Author: SimonQian * 8 | * Versaion: See changelog * 9 | * Purpose: ADC interface header file * 10 | * License: See license * 11 | *------------------------------------------------------------------------* 12 | * Change Log: * 13 | * YYYY-MM-DD: What(by Who) * 14 | * 2008-11-07: created(by SimonQian) * 15 | **************************************************************************/ 16 | 17 | vsf_err_t clko_init(uint8_t index); 18 | vsf_err_t clko_fini(uint8_t index); 19 | vsf_err_t clko_config(uint8_t index, uint32_t kHz); 20 | vsf_err_t clko_enable(uint8_t index); 21 | vsf_err_t clko_disable(uint8_t index); 22 | -------------------------------------------------------------------------------- /firmware/Interfaces/APP/DUSI/DUSI.h: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * Copyright (C) 2008 - 2010 by Simon Qian * 3 | * SimonQian@SimonQian.com * 4 | * * 5 | * Project: Versaloon * 6 | * File: DUSI.h * 7 | * Author: SimonQian * 8 | * Versaion: See changelog * 9 | * Purpose: DUSI interface header file * 10 | * License: See license * 11 | *------------------------------------------------------------------------* 12 | * Change Log: * 13 | * YYYY-MM-DD: What(by Who) * 14 | * 2008-11-07: created(by SimonQian) * 15 | **************************************************************************/ 16 | 17 | vsf_err_t dusi_init(uint8_t index); 18 | vsf_err_t dusi_fini(uint8_t index); 19 | vsf_err_t dusi_io(uint8_t index, uint8_t *mo, uint8_t *mi, uint8_t *so, 20 | uint8_t *si, uint32_t bitlen); 21 | vsf_err_t dusi_config(uint8_t index, uint32_t kHz, uint8_t mode); 22 | -------------------------------------------------------------------------------- /firmware/Interfaces/APP/EBI/EBI.c: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * Copyright (C) 2008 - 2010 by Simon Qian * 3 | * SimonQian@SimonQian.com * 4 | * * 5 | * Project: Versaloon * 6 | * File: SPI.c * 7 | * Author: SimonQian * 8 | * Versaion: See changelog * 9 | * Purpose: SPI interface implementation file * 10 | * License: See license * 11 | *------------------------------------------------------------------------* 12 | * Change Log: * 13 | * YYYY-MM-DD: What(by Who) * 14 | * 2008-11-07: created(by SimonQian) * 15 | **************************************************************************/ 16 | 17 | #include "app_cfg.h" 18 | #if INTERFACE_EBI_EN 19 | 20 | #include "app_interfaces.h" 21 | #include "EBI.h" 22 | 23 | vsf_err_t ebi_init(uint8_t index) 24 | { 25 | switch (index) 26 | { 27 | case 0: 28 | return core_interfaces.ebi.init(0); 29 | default: 30 | return VSFERR_NOT_SUPPORT; 31 | } 32 | } 33 | 34 | vsf_err_t ebi_fini(uint8_t index) 35 | { 36 | switch (index) 37 | { 38 | case 0: 39 | return core_interfaces.ebi.fini(0); 40 | default: 41 | return VSFERR_NOT_SUPPORT; 42 | } 43 | } 44 | 45 | vsf_err_t ebi_config(uint8_t index, uint8_t target_index, void *param) 46 | { 47 | switch (index) 48 | { 49 | case 0: 50 | return core_interfaces.ebi.config(0, target_index, param); 51 | default: 52 | return VSFERR_NOT_SUPPORT; 53 | } 54 | } 55 | 56 | vsf_err_t ebi_read(uint8_t index, uint8_t target_index, uint32_t address, 57 | uint8_t data_size, uint8_t *buff, uint32_t count) 58 | { 59 | switch (index) 60 | { 61 | case 0: 62 | return core_interfaces.ebi.read(0, target_index, address, data_size, 63 | buff, count); 64 | default: 65 | return VSFERR_NOT_SUPPORT; 66 | } 67 | } 68 | 69 | vsf_err_t ebi_write(uint8_t index, uint8_t target_index, uint32_t address, 70 | uint8_t data_size, uint8_t *buff, uint32_t count) 71 | { 72 | switch (index) 73 | { 74 | case 0: 75 | return core_interfaces.ebi.write(0, target_index, address, data_size, 76 | buff, count); 77 | default: 78 | return VSFERR_NOT_SUPPORT; 79 | } 80 | } 81 | 82 | vsf_err_t ebi_isready(uint8_t index, uint8_t target_index) 83 | { 84 | switch (index) 85 | { 86 | case 0: 87 | return core_interfaces.ebi.isready(0, target_index); 88 | default: 89 | return VSFERR_NOT_SUPPORT; 90 | } 91 | } 92 | 93 | #endif 94 | -------------------------------------------------------------------------------- /firmware/Interfaces/APP/EBI/EBI.h: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * Copyright (C) 2008 - 2010 by Simon Qian * 3 | * SimonQian@SimonQian.com * 4 | * * 5 | * Project: Versaloon * 6 | * File: SPI.h * 7 | * Author: SimonQian * 8 | * Versaion: See changelog * 9 | * Purpose: SPI interface header file * 10 | * License: See license * 11 | *------------------------------------------------------------------------* 12 | * Change Log: * 13 | * YYYY-MM-DD: What(by Who) * 14 | * 2008-11-07: created(by SimonQian) * 15 | **************************************************************************/ 16 | 17 | vsf_err_t ebi_init(uint8_t index); 18 | vsf_err_t ebi_fini(uint8_t index); 19 | vsf_err_t ebi_config(uint8_t index, uint8_t target_index, void *param); 20 | vsf_err_t ebi_isready(uint8_t index, uint8_t target_index); 21 | vsf_err_t ebi_read(uint8_t index, uint8_t target_index, uint32_t address, 22 | uint8_t data_size, uint8_t *buff, uint32_t count); 23 | vsf_err_t ebi_write(uint8_t index, uint8_t target_index, uint32_t address, 24 | uint8_t data_size, uint8_t *buff, uint32_t count); 25 | -------------------------------------------------------------------------------- /firmware/Interfaces/APP/GPIO/GPIO.h: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * Copyright (C) 2008 - 2010 by Simon Qian * 3 | * SimonQian@SimonQian.com * 4 | * * 5 | * Project: Versaloon * 6 | * File: GPIO.h * 7 | * Author: SimonQian * 8 | * Versaion: See changelog * 9 | * Purpose: GPIO interface header file * 10 | * License: See license * 11 | *------------------------------------------------------------------------* 12 | * Change Log: * 13 | * YYYY-MM-DD: What(by Who) * 14 | * 2008-11-07: created(by SimonQian) * 15 | **************************************************************************/ 16 | 17 | #define GPIO_DIR_MSK 0x01 18 | #define GPIO_SRST (1 << 0) 19 | #define GPIO_TRST (1 << 1) 20 | #if JTAG_HAS_USER_PIN 21 | # define GPIO_USR1 (1 << 2) 22 | # define GPIO_USR2 (1 << 3) 23 | #else 24 | # define GPIO_USR1 0 25 | # define GPIO_USR2 0 26 | #endif 27 | #define GPIO_TCK (1 << 4) 28 | #define GPIO_TDO (1 << 5) 29 | #define GPIO_TDI (1 << 6) 30 | #define GPIO_RTCK (1 << 7) 31 | #define GPIO_TMS (1 << 8) 32 | #define GPIO_SYNCSWPWM_GPIO (1 << 9) 33 | #define GPIO_OUT_MSK (GPIO_SRST | GPIO_TRST | GPIO_USR1 | GPIO_USR2 | GPIO_TCK | GPIO_TDI | GPIO_TMS | GPIO_SYNCSWPWM_GPIO) 34 | #define GPIO_IN_MSK (GPIO_SRST | GPIO_TRST | GPIO_USR1 | GPIO_USR2 | GPIO_TDO | GPIO_RTCK | GPIO_TMS | GPIO_SYNCSWPWM_GPIO) 35 | #define GPIO_MSK (GPIO_OUT_MSK | GPIO_IN_MSK) 36 | 37 | vsf_err_t gpio_init(uint8_t index); 38 | vsf_err_t gpio_fini(uint8_t index); 39 | vsf_err_t gpio_config(uint8_t index, uint32_t pin_mask, uint32_t io, 40 | uint32_t pull_en_mask, uint32_t input_pull_mask); 41 | vsf_err_t gpio_set(uint8_t index, uint32_t pin_mask); 42 | vsf_err_t gpio_clear(uint8_t index, uint32_t pin_mask); 43 | vsf_err_t gpio_out(uint8_t index, uint32_t pin_mask, uint32_t value); 44 | vsf_err_t gpio_in(uint8_t index, uint32_t pin_mask, uint32_t *value); 45 | -------------------------------------------------------------------------------- /firmware/Interfaces/APP/IIC/IIC.h: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * Copyright (C) 2008 - 2010 by Simon Qian * 3 | * SimonQian@SimonQian.com * 4 | * * 5 | * Project: Versaloon * 6 | * File: IIC.h * 7 | * Author: SimonQian * 8 | * Versaion: See changelog * 9 | * Purpose: IIC interface header file * 10 | * License: See license * 11 | *------------------------------------------------------------------------* 12 | * Change Log: * 13 | * YYYY-MM-DD: What(by Who) * 14 | * 2008-11-07: created(by SimonQian) * 15 | **************************************************************************/ 16 | 17 | vsf_err_t iic_init(uint8_t index); 18 | vsf_err_t iic_fini(uint8_t index); 19 | vsf_err_t iic_config(uint8_t index, uint16_t kHz, uint16_t byte_interval, 20 | uint16_t max_dly); 21 | vsf_err_t iic_read(uint8_t index, uint16_t chip_addr, uint8_t *data, 22 | uint16_t data_len, uint8_t stop, bool nacklast); 23 | vsf_err_t iic_write(uint8_t index, uint16_t chip_addr, uint8_t *data, 24 | uint16_t data_len, uint8_t stop); 25 | -------------------------------------------------------------------------------- /firmware/Interfaces/APP/IIC/IIC_MOD_Common.h: -------------------------------------------------------------------------------- 1 | #ifndef __IIC_MOD_COMMON_INCLUDED__ 2 | #define __IIC_MOD_COMMON_INCLUDED__ 3 | 4 | typedef enum IIC_MOD_RESULT 5 | { 6 | IIC_MOD_ACK = 0, 7 | IIC_MOD_NACK, 8 | IIC_MOD_TO, 9 | IIC_MOD_ADDR_NO_RESPONSE 10 | }IIC_MOD_RESULT_t; 11 | 12 | typedef enum IIC_STOP 13 | { 14 | IIC_NOSTOP = 0, 15 | IIC_FORCESTOP 16 | }IIC_STOP_t; 17 | 18 | #endif /* __IIC_MOD_COMMON_INCLUDED__ */ 19 | -------------------------------------------------------------------------------- /firmware/Interfaces/APP/ISSP/ISSP.h: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * Copyright (C) 2008 - 2010 by Simon Qian * 3 | * SimonQian@SimonQian.com * 4 | * * 5 | * Project: Versaloon * 6 | * File: ISSP.h * 7 | * Author: SimonQian * 8 | * Versaion: See changelog * 9 | * Purpose: ISSP interface header file * 10 | * License: See license * 11 | *------------------------------------------------------------------------* 12 | * Change Log: * 13 | * YYYY-MM-DD: What(by Who) * 14 | * 2008-11-07: created(by SimonQian) * 15 | **************************************************************************/ 16 | 17 | #define ISSP_OPERATE_BANK (1 << 0) 18 | #define ISSP_OPERATE_READ (1 << 1) 19 | #define ISSP_OPERATE_APPENDBIT (1 << 2) 20 | #define ISSP_OPERATE_0s (1 << 3) 21 | 22 | vsf_err_t issp_vector(uint8_t index, uint8_t operate, uint8_t addr, 23 | uint8_t data, uint8_t *buf); 24 | vsf_err_t issp_enter_program_mode(uint8_t index, uint8_t mode); 25 | vsf_err_t issp_leave_program_mode(uint8_t index, uint8_t mode); 26 | vsf_err_t issp_wait_and_poll(uint8_t index); 27 | vsf_err_t issp_init(uint8_t index); 28 | vsf_err_t issp_fini(uint8_t index); 29 | -------------------------------------------------------------------------------- /firmware/Interfaces/APP/JTAG/JTAG_TAP.h: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * Copyright (C) 2008 - 2010 by Simon Qian * 3 | * SimonQian@SimonQian.com * 4 | * * 5 | * Project: Versaloon * 6 | * File: JTAG_TAP.h * 7 | * Author: SimonQian * 8 | * Versaion: See changelog * 9 | * Purpose: JTAG interface header file * 10 | * License: See license * 11 | *------------------------------------------------------------------------* 12 | * Change Log: * 13 | * YYYY-MM-DD: What(by Who) * 14 | * 2008-11-07: created(by SimonQian) * 15 | **************************************************************************/ 16 | 17 | vsf_err_t jtaghl_init(uint8_t index); 18 | vsf_err_t jtaghl_fini(uint8_t index); 19 | vsf_err_t jtaghl_config_speed(uint8_t index, uint32_t kHz); 20 | vsf_err_t jtaghl_config_daisychain(uint8_t index, struct jtag_pos_t *jtag_pos); 21 | vsf_err_t jtaghl_config(uint8_t index, uint32_t kHz, struct jtag_pos_t *jtag_pos); 22 | vsf_err_t jtaghl_tms(uint8_t index, uint8_t* tms, uint16_t bitlen); 23 | vsf_err_t jtaghl_runtest(uint8_t index, uint32_t cycles); 24 | vsf_err_t jtaghl_ir(uint8_t index, uint8_t *ir, uint16_t bitlen, uint8_t idle, 25 | uint8_t want_ret); 26 | vsf_err_t jtaghl_dr(uint8_t index, uint8_t *dr, uint16_t bitlen, uint8_t idle, 27 | uint8_t want_ret); 28 | vsf_err_t jtaghl_register_callback(uint8_t index, jtag_callback_t send_callback, 29 | jtag_callback_t receive_callback); 30 | 31 | vsf_err_t jtagll_init(uint8_t index); 32 | vsf_err_t jtagll_fini(uint8_t index); 33 | vsf_err_t jtagll_config(uint8_t index, uint32_t kHz); 34 | vsf_err_t jtagll_tms(uint8_t index, uint8_t *tms, uint8_t bytelen); 35 | vsf_err_t jtagll_tms_clocks(uint8_t index, uint32_t bytelen, uint8_t tms); 36 | vsf_err_t jtagll_scan(uint8_t index, uint8_t* data, uint16_t bitlen, 37 | uint8_t tms_before_valid, uint8_t tms_before, 38 | uint8_t tms_after0, uint8_t tms_after1); 39 | 40 | vsf_err_t jtagraw_init(uint8_t index); 41 | vsf_err_t jtagraw_fini(uint8_t index); 42 | vsf_err_t jtagraw_config(uint8_t index, uint32_t kHz); 43 | vsf_err_t jtagraw_execute(uint8_t index, uint8_t* tdi, uint8_t* tms, 44 | uint8_t *tdo, uint32_t bitlen); 45 | -------------------------------------------------------------------------------- /firmware/Interfaces/APP/LPC_ICP/LPC_ICP.h: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * Copyright (C) 2008 - 2010 by Simon Qian * 3 | * SimonQian@SimonQian.com * 4 | * * 5 | * Project: Versaloon * 6 | * File: LPC_ICP.h * 7 | * Author: SimonQian * 8 | * Versaion: See changelog * 9 | * Purpose: LPC_ICP interface header file * 10 | * License: See license * 11 | *------------------------------------------------------------------------* 12 | * Change Log: * 13 | * YYYY-MM-DD: What(by Who) * 14 | * 2008-11-07: created(by SimonQian) * 15 | **************************************************************************/ 16 | 17 | #define LPCICP_POLL_ON_SET 0 18 | #define LPCICP_POLL_ON_CLEAR 1 19 | #define LPCICP_POLL_TIME_OUT 2 20 | 21 | vsf_err_t lpcicp_init(uint8_t index); 22 | vsf_err_t lpcicp_fini(uint8_t index); 23 | vsf_err_t lpcicp_enter_program_mode(uint8_t index); 24 | vsf_err_t lpcicp_in(uint8_t index, uint8_t *buff, uint16_t len); 25 | vsf_err_t lpcicp_out(uint8_t index, uint8_t *buff, uint16_t len); 26 | vsf_err_t lpcicp_poll_ready(uint8_t index, uint8_t data, uint8_t *ret, 27 | uint8_t setmask, uint8_t clearmask, uint16_t pollcnt); 28 | -------------------------------------------------------------------------------- /firmware/Interfaces/APP/MSP430_JTAG/MSP430_JTAG.h: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * Copyright (C) 2008 - 2010 by Simon Qian * 3 | * SimonQian@SimonQian.com * 4 | * * 5 | * Project: Versaloon * 6 | * File: MSP430_JTAG.c * 7 | * Author: SimonQian * 8 | * Versaion: See changelog * 9 | * Purpose: MSP430_JTAG interface header file * 10 | * License: See license * 11 | *------------------------------------------------------------------------* 12 | * Change Log: * 13 | * YYYY-MM-DD: What(by Who) * 14 | * 2008-11-07: created(by SimonQian) * 15 | **************************************************************************/ 16 | 17 | vsf_err_t msp430jtag_init(uint8_t index); 18 | vsf_err_t msp430jtag_fini(uint8_t index); 19 | vsf_err_t msp430jtag_config(uint8_t index, uint8_t has_test); 20 | vsf_err_t msp430jtag_ir(uint8_t index, uint8_t *ir, uint8_t want_ret); 21 | vsf_err_t msp430jtag_dr(uint8_t index, uint32_t *dr, uint8_t bitlen, 22 | uint8_t want_ret); 23 | vsf_err_t msp430jtag_tclk(uint8_t index, uint8_t value); 24 | vsf_err_t msp430jtag_tclk_strobe(uint8_t index, uint16_t cnt); 25 | vsf_err_t msp430jtag_reset(uint8_t index); 26 | vsf_err_t msp430jtag_poll(uint8_t index, uint32_t dr, uint32_t mask, 27 | uint32_t value, uint8_t len, uint16_t poll_cnt, uint8_t toggle_tclk); 28 | -------------------------------------------------------------------------------- /firmware/Interfaces/APP/MicroWire/MicroWire.h: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * Copyright (C) 2008 - 2010 by Simon Qian * 3 | * SimonQian@SimonQian.com * 4 | * * 5 | * Project: Versaloon * 6 | * File: MicroWire.h * 7 | * Author: SimonQian * 8 | * Versaion: See changelog * 9 | * Purpose: MicroWire interface header file * 10 | * License: See license * 11 | *------------------------------------------------------------------------* 12 | * Change Log: * 13 | * YYYY-MM-DD: What(by Who) * 14 | * 2008-11-07: created(by SimonQian) * 15 | **************************************************************************/ 16 | 17 | vsf_err_t microwire_init(uint8_t index); 18 | vsf_err_t microwire_fini(uint8_t index); 19 | vsf_err_t microwire_config(uint8_t index, uint16_t kHz, uint8_t sel_polarity); 20 | vsf_err_t microwire_transport(uint8_t index, uint32_t opcode, 21 | uint8_t opcode_bitlen, uint32_t addr, uint8_t addr_bitlen, 22 | uint32_t data, uint8_t data_bitlen, uint8_t *ret, uint8_t ret_bitlen); 23 | vsf_err_t microwire_poll(uint8_t index, uint16_t interval_us, 24 | uint16_t retry_cnt); 25 | -------------------------------------------------------------------------------- /firmware/Interfaces/APP/PWM/PWM.h: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * Copyright (C) 2008 - 2010 by Simon Qian * 3 | * SimonQian@SimonQian.com * 4 | * * 5 | * Project: Versaloon * 6 | * File: PWM.h * 7 | * Author: SimonQian * 8 | * Versaion: See changelog * 9 | * Purpose: PWM header file * 10 | * License: See license * 11 | *------------------------------------------------------------------------* 12 | * Change Log: * 13 | * YYYY-MM-DD: What(by Who) * 14 | * 2011-03-06: created(by SimonQian) * 15 | **************************************************************************/ 16 | 17 | vsf_err_t pwm_init(uint8_t index); 18 | vsf_err_t pwm_fini(uint8_t index); 19 | vsf_err_t pwm_config_mode(uint8_t index, uint8_t mode); 20 | vsf_err_t pwm_config_freq(uint8_t index, uint16_t kHz); 21 | vsf_err_t pwm_out(uint8_t index, uint16_t count, uint16_t *rate); 22 | vsf_err_t pwm_in(uint8_t index, uint16_t count, uint16_t *rate); 23 | -------------------------------------------------------------------------------- /firmware/Interfaces/APP/PowerExt/PowerExt.h: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * Copyright (C) 2008 - 2010 by Simon Qian * 3 | * SimonQian@SimonQian.com * 4 | * * 5 | * Project: Versaloon * 6 | * File: PowerExt.h * 7 | * Author: SimonQian * 8 | * Versaion: See changelog * 9 | * Purpose: Power output interface header file * 10 | * License: See license * 11 | *------------------------------------------------------------------------* 12 | * Change Log: * 13 | * YYYY-MM-DD: What(by Who) * 14 | * 2009-06-20: created(by SimonQian) * 15 | **************************************************************************/ 16 | 17 | void PWREXT_Acquire(void); 18 | void PWREXT_Release(void); 19 | void PWREXT_ForceRelease(void); 20 | uint8_t PWREXT_GetState(void); 21 | 22 | vsf_err_t target_voltage_set(uint8_t index, uint16_t voltage); 23 | vsf_err_t target_voltage_get(uint8_t index, uint16_t *voltage); 24 | vsf_err_t target_voltage_poll(uint8_t index); 25 | -------------------------------------------------------------------------------- /firmware/Interfaces/APP/SDIO/SDIO.h: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * Copyright (C) 2008 - 2010 by Simon Qian * 3 | * SimonQian@SimonQian.com * 4 | * * 5 | * Project: Versaloon * 6 | * File: SDIO.h * 7 | * Author: SimonQian * 8 | * Versaion: See changelog * 9 | * Purpose: SPI interface header file * 10 | * License: See license * 11 | *------------------------------------------------------------------------* 12 | * Change Log: * 13 | * YYYY-MM-DD: What(by Who) * 14 | * 2012-01-24: created(by SimonQian) * 15 | **************************************************************************/ 16 | 17 | vsf_err_t sdio_init(uint8_t index); 18 | vsf_err_t sdio_fini(uint8_t index); 19 | vsf_err_t sdio_config(uint8_t index, uint16_t kHz, uint8_t buswidth); 20 | vsf_err_t sdio_start(uint8_t index); 21 | vsf_err_t sdio_stop(uint8_t index); 22 | vsf_err_t sdio_send_cmd(uint8_t index, uint8_t cmd, uint32_t arg, uint8_t resp); 23 | vsf_err_t sdio_send_cmd_isready(uint8_t index, uint8_t resp); 24 | vsf_err_t sdio_get_resp(uint8_t index, uint8_t *cresp, uint32_t *resp, 25 | uint8_t resp_num); 26 | vsf_err_t sdio_data_tx(uint8_t index, uint32_t timeout, uint32_t size, 27 | uint32_t block_size); 28 | vsf_err_t sdio_data_tx_isready(uint8_t index, uint32_t size, uint8_t *buffer); 29 | vsf_err_t sdio_data_rx(uint8_t index, uint32_t timeout, uint32_t size, 30 | uint32_t block_size); 31 | vsf_err_t sdio_data_rx_isready(uint8_t index, uint32_t size, uint8_t *buffer); -------------------------------------------------------------------------------- /firmware/Interfaces/APP/SPI/SPI.h: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * Copyright (C) 2008 - 2010 by Simon Qian * 3 | * SimonQian@SimonQian.com * 4 | * * 5 | * Project: Versaloon * 6 | * File: SPI.h * 7 | * Author: SimonQian * 8 | * Versaion: See changelog * 9 | * Purpose: SPI interface header file * 10 | * License: See license * 11 | *------------------------------------------------------------------------* 12 | * Change Log: * 13 | * YYYY-MM-DD: What(by Who) * 14 | * 2008-11-07: created(by SimonQian) * 15 | **************************************************************************/ 16 | 17 | // Only Support Master Mode 18 | vsf_err_t spi_init(uint8_t index); 19 | vsf_err_t spi_fini(uint8_t index); 20 | vsf_err_t spi_io(uint8_t index, uint8_t *out, uint8_t *in, uint32_t len); 21 | vsf_err_t spi_config(uint8_t index, uint32_t kHz, uint8_t mode); 22 | vsf_err_t spi_select(uint8_t index, uint8_t cs); 23 | vsf_err_t spi_deselect(uint8_t index, uint8_t cs); 24 | -------------------------------------------------------------------------------- /firmware/Interfaces/APP/SWD/SWD.h: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * Copyright (C) 2008 - 2010 by Simon Qian * 3 | * SimonQian@SimonQian.com * 4 | * * 5 | * Project: Versaloon * 6 | * File: SWD.h * 7 | * Author: SimonQian * 8 | * Versaion: See changelog * 9 | * Purpose: SWD interface header file * 10 | * License: See license * 11 | *------------------------------------------------------------------------* 12 | * Change Log: * 13 | * YYYY-MM-DD: What(by Who) * 14 | * 2008-11-07: created(by SimonQian) * 15 | **************************************************************************/ 16 | 17 | vsf_err_t swd_init(uint8_t index); 18 | vsf_err_t swd_fini(uint8_t index); 19 | vsf_err_t swd_config(uint8_t index, uint8_t trn, uint16_t retry, uint16_t dly); 20 | vsf_err_t swd_seqout(uint8_t index, uint8_t *data, uint16_t bitlen); 21 | vsf_err_t swd_seqin(uint8_t index, uint8_t *data, uint16_t bitlen); 22 | vsf_err_t swd_transact(uint8_t index, uint8_t request, uint32_t *data, 23 | uint8_t *ack); 24 | -------------------------------------------------------------------------------- /firmware/Interfaces/APP/SWIM/SWIM.h: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * Copyright (C) 2008 - 2010 by Simon Qian * 3 | * SimonQian@SimonQian.com * 4 | * * 5 | * Project: Versaloon * 6 | * File: SWIM.h * 7 | * Author: SimonQian * 8 | * Versaion: See changelog * 9 | * Purpose: SWIM interface header file * 10 | * License: See license * 11 | *------------------------------------------------------------------------* 12 | * Change Log: * 13 | * YYYY-MM-DD: What(by Who) * 14 | * 2008-11-07: created(by SimonQian) * 15 | **************************************************************************/ 16 | 17 | vsf_err_t swim_init(uint8_t index); 18 | vsf_err_t swim_fini(uint8_t index); 19 | vsf_err_t swim_config(uint8_t index, uint8_t mHz, uint8_t cnt0, uint8_t cnt1); 20 | vsf_err_t swim_srst(uint8_t index); 21 | vsf_err_t swim_wotf(uint8_t index, uint8_t *data, uint16_t bytelen, 22 | uint32_t addr); 23 | vsf_err_t swim_rotf(uint8_t index, uint8_t *data, uint16_t bytelen, 24 | uint32_t addr); 25 | vsf_err_t swim_sync(uint8_t index, uint8_t mHz); 26 | vsf_err_t swim_enable(uint8_t index); 27 | -------------------------------------------------------------------------------- /firmware/Interfaces/APP/USART/USART.h: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * Copyright (C) 2008 - 2010 by Simon Qian * 3 | * SimonQian@SimonQian.com * 4 | * * 5 | * Project: Versaloon * 6 | * File: USART.h * 7 | * Author: SimonQian * 8 | * Versaion: See changelog * 9 | * Purpose: USART interface header file * 10 | * License: See license * 11 | *------------------------------------------------------------------------* 12 | * Change Log: * 13 | * YYYY-MM-DD: What(by Who) * 14 | * 2008-11-07: created(by SimonQian) * 15 | **************************************************************************/ 16 | 17 | vsf_err_t usart_init(uint8_t index); 18 | vsf_err_t usart_fini(uint8_t index); 19 | vsf_err_t usart_config(uint8_t index, uint32_t baudrate, uint8_t datalength, 20 | uint8_t mode); 21 | vsf_err_t usart_send(uint8_t index, uint8_t *buf, uint16_t len); 22 | vsf_err_t usart_receive(uint8_t index, uint8_t *buf, uint16_t len); 23 | vsf_err_t usart_status(uint8_t index, struct usart_status_t *status); 24 | vsf_err_t usart_poll(uint8_t index); 25 | -------------------------------------------------------------------------------- /firmware/Projects/VSFCore/app_cfg.h: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * Copyright (C) 2008 - 2012 by Simon Qian * 3 | * SimonQian@SimonQian.com * 4 | * * 5 | * Project: VSF * 6 | * File: app_cfg.h * 7 | * Author: SimonQian * 8 | * Versaion: See changelog * 9 | * Purpose: configuration file * 10 | * License: See license * 11 | *------------------------------------------------------------------------* 12 | * Change Log: * 13 | * YYYY-MM-DD: What(by Who) * 14 | * 2008-11-07: created(by SimonQian) * 15 | * 2011-01-09: Add stmxx-discovery (by Bingo) * 16 | **************************************************************************/ 17 | 18 | // hardware config file 19 | #include "hw_cfg_VSFCore_STM32.h" 20 | 21 | // compiler config 22 | #include "compiler.h" 23 | 24 | #define USB_TO_XXX_EN 1 25 | #define USB_TO_USART_EN (0 && HW_HAS_USART) 26 | #define USB_TO_SPI_EN (1 && HW_HAS_SPI) 27 | #define USB_TO_IIC_EN (1 && HW_HAS_IIC) 28 | #define USB_TO_GPIO_EN (1 && HW_HAS_GPIO) 29 | #define USB_TO_CAN_EN (0 && HW_HAS_CAN) 30 | #define USB_TO_PWM_EN (1 && HW_HAS_PWM) 31 | #define USB_TO_ADC_EN (1 && HW_HAS_ADC) 32 | #define USB_TO_DAC_EN (0 && HW_HAS_DAC) 33 | #define USB_TO_EBI_EN (1 && HW_HAS_EBI) 34 | 35 | /***************************** Buffer ****************************/ 36 | #define USB_DATA_BUFF_SIZE (8 * 1024) 37 | #define ASYN_DATA_BUFF_SIZE (4 * 1024) 38 | 39 | /**************************** Checks ****************************/ 40 | #define _HARDWARE_VER_STR make_ver(_HARDWARE_VER) 41 | #define make_ver(v) make_str(v) 42 | #define make_str(s) # s 43 | 44 | #define INTERFACE_IIC_EN 1 45 | #define INTERFACE_SPI_EN 1 46 | #define INTERFACE_SDIO_EN 1 47 | #define INTERFACE_USART_EN 1 48 | #define INTERFACE_GPIO_EN 1 49 | #define INTERFACE_PWM_EN 0 50 | #define INTERFACE_EBI_EN 1 51 | #define INTERFACE_ADC_EN 1 52 | -------------------------------------------------------------------------------- /firmware/Projects/Versaloon/port.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 - 2010 by Simon Qian * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 18 | ***************************************************************************/ 19 | #ifdef HAVE_CONFIG_H 20 | #include "config.h" 21 | #endif 22 | 23 | #include "app_type.h" 24 | 25 | #include "port.h" 26 | 27 | -------------------------------------------------------------------------------- /firmware/Projects/Versaloon/port.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 - 2010 by Simon Qian * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 18 | ***************************************************************************/ 19 | #ifndef __PORT_H_INCLUDED__ 20 | #define __PORT_H_INCLUDED__ 21 | 22 | #ifdef HAVE_CONFIG_H 23 | #include "config.h" 24 | #endif 25 | 26 | #define sleep_ms(ms) interfaces->delay.delayms(ms) 27 | #define clock() interfaces->tickclk.get_count() 28 | #define CLOCKS_PER_SEC 1000 29 | 30 | #ifndef MAX_PATH 31 | # define MAX_PATH 260 32 | #endif 33 | 34 | #endif /* __PORT_H_INCLUDED__ */ 35 | 36 | -------------------------------------------------------------------------------- /firmware/Projects/Versaloon/vsf_cfg/dal_cfg.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 - 2010 by Simon Qian * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 18 | ***************************************************************************/ 19 | 20 | #define DAL_INTERFACE_PARSER_EN 1 21 | 22 | #define DAL_MIC2826_EN 0 23 | #define DAL_NRF24L01_EN 0 24 | 25 | #define DAL_MAL_EN 1 26 | #define DAL_EE93CX6_EN INTERFACE_MICROWIRE_EN 27 | #define DAL_EE24CXX_EN INTERFACE_IIC_EN 28 | #define DAL_DF25XX_EN INTERFACE_SPI_EN 29 | #define DAL_DF45XX_EN INTERFACE_SPI_EN 30 | #define DAL_SD_SPI_EN INTERFACE_SPI_EN 31 | #define DAL_SD_SDIO_EN INTERFACE_SDIO_EN 32 | #define DAL_CFI_EN INTERFACE_EBI_EN 33 | #define DAL_NAND_EN INTERFACE_EBI_EN 34 | #define DAL_SST32HFXX_EN INTERFACE_EBI_EN 35 | #define DAL_MAL_EMPTY_EN 0 36 | #define DAL_S6B0724_EN INTERFACE_EBI_EN 37 | 38 | -------------------------------------------------------------------------------- /firmware/Projects/Versaloon/vsf_cfg/vsf_usbd_cfg.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 - 2010 by Simon Qian * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 18 | ***************************************************************************/ 19 | 20 | #define VSFUSBD_CFG_MAX_IN_EP 8 21 | #define VSFUSBD_CFG_MAX_OUT_EP 8 22 | 23 | #define VSFUSBD_CFG_AUTOSETUP 1 24 | #define VSFUSBD_CFG_DBUFFER_EN 1 25 | #define VSFUSBD_CFG_DATATOGGLE_CTRL 1 26 | #define VSFUSBD_CFG_EP_ISO_EN 0 27 | 28 | -------------------------------------------------------------------------------- /firmware/README.md: -------------------------------------------------------------------------------- 1 | About CDC firmware 2 | ================== 3 | 4 | This firmware is currently for Mini-Versalon ONLY. 5 | 6 | This CDC tool implements 1 CDC interface and 1 MSC interface, both can be operated at the same time. 7 | 8 | Resources 9 | ========= 10 | 11 | * about 8K for flash, 2K + USB and UART buffer for SRAM 12 | * about 10.5K for flash, 3K + USB and UART buffer for SRAM 13 | * 2 GPIOs for LEDs, USART0, USB 14 | * External oscillator should be 8M/12M/16M 15 | 16 | Build 17 | ===== 18 | 19 | To build with GCC, just make in Projects/CDC/GCC. 20 | 21 | Configuration 22 | ============= 23 | 24 | * Modify NVIC_Configuration function in HW/HW.c to configure the flash start address. 25 | * Modify HSE_Value definitation in stm3210x.h in HW/lib/CMSIS/Core/CM3/stm32f10x.h to the real frequency of external oscillator, available values are 8000000/12000000/16000000. 26 | 27 | 28 | 2. functionality(in Projects/CDC/app_cfg.h) 29 | MSC enable: USB_WITH_MASSSTORAGE, if defined as 0, MSC is disabled; if defined as 1, MSC is enabled. 30 | udisk start address: MSD_MEMORY_START_ADDR, it should start after firmware and aligned to flash block size of target chip. 31 | USB buffer size: USB_DATA_BUFF_SIZE, as much as possilbe, 32 | UART buffer size: ASYN_DATA_BUFF_SIZE, 1K is enough(UART will receive less than 1K in 10ms under 921600bps). 33 | 3. MSC udisk configuration: 34 | MSC udisk image is ../udisk/image(1024).bin, FAT12 specification. The 16-bit value start from the 11th byte in the image is sector size, which should be the same as MSD_MEMORY_BLOCK_SIZE in app_cfg.h. The 16-bit value start from 19th byte in the image is the sector number. 35 | Sector size should the same as the flash block size of the target chip, and sector number should be the flash block number available for udisk. 36 | 4. driver(using IAD for multiple devices) 37 | Windows: 38 | without MSC: ../driver/win32/stmcdc.inf 39 | with MSC: ../driver/win32/stmcdc_with_MSC.inf for CDC, and MSC can be installed automatically. 40 | Linux(Tested on Ubuntu 8.04LTS, Linux kernel later than 2.6.21.3 supports IAD): 41 | No driver needed. 42 | 5. image generation 43 | simple load the firmware to the defined flash start address, and load udisk image to the address defined by MSD_MEMORY_START_ADDR. 44 | 6. ...... 45 | MSC implementation will not check accessablity of the required flash address, so if the sector size and sector number defined in BOOT section of udisk image execeed the internal flash, firmware will still proceed. And actually, there is a change to get 128K flash out of a chip with 64K flash. 46 | Caution: If access to unavailable address because of wrong udisk configuration, content of the target chip maybe erased, then you should program the flash again. For example, for STM32F103C8T6(64K flash), there is a chance to use 128K flash, but if accessing flash after 128K, all flash will be erased. 47 | 7. Note 48 | Do not use Windows to format the udisk, Windows will take more 20K bytes. 49 | -------------------------------------------------------------------------------- /firmware/USB_TO_XXX/CommandProcessor.h: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * Copyright (C) 2008 - 2010 by Simon Qian * 3 | * SimonQian@SimonQian.com * 4 | * * 5 | * Project: Versaloon * 6 | * File: CommandProcesor.h * 7 | * Author: SimonQian * 8 | * Versaion: See changelog * 9 | * Purpose: header of CommandProcesor for Versaloon/USB_TO_XXX * 10 | * License: See license * 11 | *------------------------------------------------------------------------* 12 | * Change Log: * 13 | * YYYY-MM-DD: What(by Who) * 14 | * 2010-08-30: created(by SimonQian) * 15 | **************************************************************************/ 16 | 17 | // Common Commands 18 | #define VERSALOON_COMMON_CMD_START 0x00 19 | #define VERSALOON_COMMON_CMD_END 0x0F 20 | 21 | #define VERSALOON_GET_INFO 0x00 22 | #define VERSALOON_GET_TVCC 0x01 23 | #define VERSALOON_GET_HARDWARE 0x02 24 | #define VERSALOON_FW_UPDATE 0x0F 25 | 26 | // USB_TO_XXX Commands 27 | #define VERSALOON_USB_TO_XXX_CMD_START 0x20 28 | #define VERSALOON_USB_TO_XXX_CMD_END 0x7F 29 | 30 | // REPLY 31 | #define VERSALOON_REP_ZLP 0x00010000 32 | 33 | void ProcessCommand(uint8_t *dat, uint16_t len); 34 | -------------------------------------------------------------------------------- /firmware/USB_TO_XXX/USB_TO_CLKO.c: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * Copyright (C) 2008 - 2010 by Simon Qian * 3 | * SimonQian@SimonQian.com * 4 | * * 5 | * Project: Versaloon * 6 | * File: USB_TO_ADC.c * 7 | * Author: SimonQian * 8 | * Versaion: See changelog * 9 | * Purpose: implementation file for USB_TO_ADC * 10 | * License: See license * 11 | *------------------------------------------------------------------------* 12 | * Change Log: * 13 | * YYYY-MM-DD: What(by Who) * 14 | * 2008-11-07: created(by SimonQian) * 15 | **************************************************************************/ 16 | 17 | #include "app_cfg.h" 18 | #if USB_TO_CLKO_EN 19 | 20 | #include "USB_TO_XXX.h" 21 | #include "app_interfaces.h" 22 | 23 | void USB_TO_CLKO_ProcessCmd(uint8_t *dat, uint16_t len) 24 | { 25 | uint16_t index, length; 26 | uint8_t command, device_idx; 27 | 28 | uint32_t kHz; 29 | 30 | index = 0; 31 | while(index < len) 32 | { 33 | command = dat[index] & USB_TO_XXX_CMDMASK; 34 | device_idx = dat[index] & USB_TO_XXX_IDXMASK; 35 | length = GET_LE_U16(&dat[index + 1]); 36 | index += 3; 37 | 38 | switch(command) 39 | { 40 | case USB_TO_XXX_INIT: 41 | if (0 == device_idx) 42 | { 43 | interfaces->clko.init(0); 44 | buffer_reply[rep_len++] = USB_TO_XXX_OK; 45 | } 46 | else 47 | { 48 | buffer_reply[rep_len++] = USB_TO_XXX_FAILED; 49 | } 50 | break; 51 | case USB_TO_XXX_CONFIG: 52 | if (0 == device_idx) 53 | { 54 | kHz = GET_LE_U32(&dat[index]); 55 | interfaces->clko.config(0, kHz); 56 | buffer_reply[rep_len++] = USB_TO_XXX_OK; 57 | } 58 | else 59 | { 60 | buffer_reply[rep_len++] = USB_TO_XXX_FAILED; 61 | } 62 | break; 63 | case USB_TO_XXX_FINI: 64 | if (0 == device_idx) 65 | { 66 | interfaces->clko.fini(0); 67 | buffer_reply[rep_len++] = USB_TO_XXX_OK; 68 | } 69 | else 70 | { 71 | buffer_reply[rep_len++] = USB_TO_XXX_FAILED; 72 | } 73 | break; 74 | case USB_TO_XXX_ENABLE: 75 | if (0 == device_idx) 76 | { 77 | interfaces->clko.enable(0); 78 | buffer_reply[rep_len++] = USB_TO_XXX_OK; 79 | } 80 | else 81 | { 82 | buffer_reply[rep_len++] = USB_TO_XXX_FAILED; 83 | } 84 | break; 85 | case USB_TO_XXX_DISABLE: 86 | if (0 == device_idx) 87 | { 88 | interfaces->clko.disable(0); 89 | buffer_reply[rep_len++] = USB_TO_XXX_OK; 90 | } 91 | else 92 | { 93 | buffer_reply[rep_len++] = USB_TO_XXX_FAILED; 94 | } 95 | break; 96 | default: 97 | buffer_reply[rep_len++] = USB_TO_XXX_CMD_NOT_SUPPORT; 98 | break; 99 | } 100 | index += length; 101 | } 102 | } 103 | 104 | #endif 105 | -------------------------------------------------------------------------------- /firmware/USB_TO_XXX/USB_TO_DAC.c: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * Copyright (C) 2008 - 2010 by Simon Qian * 3 | * SimonQian@SimonQian.com * 4 | * * 5 | * Project: Versaloon * 6 | * File: USB_TO_DAC.c * 7 | * Author: SimonQian * 8 | * Versaion: See changelog * 9 | * Purpose: implementation file for USB_TO_DAC * 10 | * License: See license * 11 | *------------------------------------------------------------------------* 12 | * Change Log: * 13 | * YYYY-MM-DD: What(by Who) * 14 | * 2008-11-07: created(by SimonQian) * 15 | **************************************************************************/ 16 | 17 | #include "app_cfg.h" 18 | #if USB_TO_DAC_EN 19 | 20 | #include "USB_TO_XXX.h" 21 | 22 | void USB_TO_DAC_ProcessCmd(uint8_t *dat, uint16_t len) 23 | { 24 | } 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /firmware/USB_TO_XXX/USB_TO_JTAG_RAW.c: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * Copyright (C) 2008 - 2010 by Simon Qian * 3 | * SimonQian@SimonQian.com * 4 | * * 5 | * Project: Versaloon * 6 | * File: USB_TO_JTAG_RAW.c * 7 | * Author: SimonQian * 8 | * Versaion: See changelog * 9 | * Purpose: implementation file for USB_TO_JTAG_RAW * 10 | * License: See license * 11 | *------------------------------------------------------------------------* 12 | * Change Log: * 13 | * YYYY-MM-DD: What(by Who) * 14 | * 2008-11-07: created(by SimonQian) * 15 | **************************************************************************/ 16 | 17 | #include "app_cfg.h" 18 | #if USB_TO_JTAG_RAW_EN 19 | 20 | #include "USB_TO_XXX.h" 21 | #include "app_interfaces.h" 22 | 23 | void USB_TO_JTAG_RAW_ProcessCmd(uint8_t *dat, uint16_t len) 24 | { 25 | uint16_t index, length; 26 | uint8_t command, device_idx; 27 | 28 | uint32_t num_of_bits, num_of_databyte; 29 | 30 | index = 0; 31 | while(index < len) 32 | { 33 | command = dat[index] & USB_TO_XXX_CMDMASK; 34 | device_idx = dat[index] & USB_TO_XXX_IDXMASK; 35 | length = GET_LE_U16(&dat[index + 1]); 36 | index += 3; 37 | 38 | switch(command) 39 | { 40 | case USB_TO_XXX_INIT: 41 | if (app_interfaces.jtag_raw.init(device_idx)) 42 | { 43 | buffer_reply[rep_len++] = USB_TO_XXX_FAILED; 44 | } 45 | else 46 | { 47 | buffer_reply[rep_len++] = USB_TO_XXX_OK; 48 | } 49 | break; 50 | case USB_TO_XXX_CONFIG: 51 | if (app_interfaces.jtag_raw.config(device_idx, 52 | GET_LE_U32(&dat[index]))) 53 | { 54 | buffer_reply[rep_len++] = USB_TO_XXX_FAILED; 55 | } 56 | else 57 | { 58 | buffer_reply[rep_len++] = USB_TO_XXX_OK; 59 | } 60 | break; 61 | case USB_TO_XXX_FINI: 62 | if (app_interfaces.jtag_raw.fini(device_idx)) 63 | { 64 | buffer_reply[rep_len++] = USB_TO_XXX_FAILED; 65 | } 66 | else 67 | { 68 | buffer_reply[rep_len++] = USB_TO_XXX_OK; 69 | } 70 | break; 71 | case USB_TO_XXX_IN_OUT: 72 | num_of_bits = GET_LE_U32(&dat[index]); 73 | num_of_databyte = ((num_of_bits + 7) >> 3); 74 | 75 | if (app_interfaces.jtag_raw.execute(device_idx, &dat[index + 4], 76 | &dat[index + 4 + num_of_databyte], 77 | &buffer_reply[rep_len + 1], num_of_bits)) 78 | { 79 | buffer_reply[rep_len++] = USB_TO_XXX_FAILED; 80 | } 81 | else 82 | { 83 | buffer_reply[rep_len++] = USB_TO_XXX_OK; 84 | } 85 | rep_len += num_of_databyte; 86 | break; 87 | default: 88 | buffer_reply[rep_len++] = USB_TO_XXX_CMD_NOT_SUPPORT; 89 | break; 90 | } 91 | index += length; 92 | } 93 | } 94 | 95 | #endif 96 | -------------------------------------------------------------------------------- /firmware/USB_TO_XXX/USB_TO_POWER.c: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * Copyright (C) 2008 - 2010 by Simon Qian * 3 | * SimonQian@SimonQian.com * 4 | * * 5 | * Project: Versaloon * 6 | * File: USB_TO_POWER.c * 7 | * Author: SimonQian * 8 | * Versaion: See changelog * 9 | * Purpose: implementation file for USB_TO_POWER * 10 | * License: See license * 11 | *------------------------------------------------------------------------* 12 | * Change Log: * 13 | * YYYY-MM-DD: What(by Who) * 14 | * 2008-11-07: created(by SimonQian) * 15 | **************************************************************************/ 16 | 17 | #include "app_cfg.h" 18 | #if USB_TO_POWER_EN 19 | 20 | #include "USB_TO_XXX.h" 21 | #include "app_interfaces.h" 22 | 23 | void USB_TO_POWER_ProcessCmd(uint8_t *dat, uint16_t len) 24 | { 25 | uint16_t index, length; 26 | uint8_t command, device_idx; 27 | 28 | uint16_t voltage; 29 | 30 | index = 0; 31 | while(index < len) 32 | { 33 | command = dat[index] & USB_TO_XXX_CMDMASK; 34 | device_idx = dat[index] & USB_TO_XXX_IDXMASK; 35 | length = GET_LE_U16(&dat[index + 1]); 36 | index += 3; 37 | 38 | switch(command) 39 | { 40 | case USB_TO_XXX_INIT: 41 | if (0 == device_idx) 42 | { 43 | buffer_reply[rep_len++] = USB_TO_XXX_OK; 44 | } 45 | else 46 | { 47 | buffer_reply[rep_len++] = USB_TO_XXX_FAILED; 48 | } 49 | break; 50 | case USB_TO_XXX_CONFIG: 51 | if (0 == device_idx) 52 | { 53 | buffer_reply[rep_len++] = USB_TO_XXX_OK; 54 | } 55 | else 56 | { 57 | buffer_reply[rep_len++] = USB_TO_XXX_FAILED; 58 | } 59 | break; 60 | case USB_TO_XXX_FINI: 61 | if (0 == device_idx) 62 | { 63 | buffer_reply[rep_len++] = USB_TO_XXX_OK; 64 | } 65 | else 66 | { 67 | buffer_reply[rep_len++] = USB_TO_XXX_FAILED; 68 | } 69 | break; 70 | case USB_TO_XXX_IN: 71 | if (app_interfaces.target_voltage.get(device_idx, &voltage)) 72 | { 73 | buffer_reply[rep_len++] = USB_TO_XXX_FAILED; 74 | voltage = 0; 75 | } 76 | else 77 | { 78 | buffer_reply[rep_len++] = USB_TO_XXX_OK; 79 | } 80 | SET_LE_U16(&buffer_reply[rep_len], voltage); 81 | rep_len += 2; 82 | break; 83 | case USB_TO_XXX_OUT: 84 | voltage = GET_LE_U16(&dat[index]); 85 | if (app_interfaces.target_voltage.set(device_idx, voltage)) 86 | { 87 | buffer_reply[rep_len++] = USB_TO_XXX_FAILED; 88 | } 89 | else 90 | { 91 | buffer_reply[rep_len++] = USB_TO_XXX_OK; 92 | } 93 | break; 94 | default: 95 | buffer_reply[rep_len++] = USB_TO_XXX_CMD_NOT_SUPPORT; 96 | break; 97 | } 98 | index += length; 99 | } 100 | } 101 | 102 | #endif 103 | -------------------------------------------------------------------------------- /firmware/app_io.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 - 2010 by Simon Qian * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 18 | ***************************************************************************/ 19 | #ifndef __APP_IO_H_INCLUDED__ 20 | #define __APP_IO_H_INCLUDED__ 21 | 22 | #include 23 | #include "app_type.h" 24 | 25 | extern struct vss_cmd_list_t appio_cmd_list; 26 | 27 | void APP_IO_INIT(void); 28 | void APP_IO_FINI(void); 29 | 30 | FILE *FOPEN(const char *filename, const char *mode); 31 | int FCLOSE(FILE *f); 32 | int FEOF(FILE *f); 33 | void REWIND(FILE *f); 34 | int FFLUSH(FILE *f); 35 | 36 | int FGETC(FILE *f); 37 | int GETCHAR(void); 38 | char* FGETS(char *buf, int count, FILE *f); 39 | 40 | int FPRINTF(FILE *f, const char *format, ...); 41 | int PRINTF(const char *format, ...); 42 | #define SNPRINTF snprintf 43 | 44 | #endif // __APP_IO_H_INCLUDED__ 45 | 46 | -------------------------------------------------------------------------------- /firmware/main.c: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * Copyright (C) 2008 - 2010 by Simon Qian * 3 | * SimonQian@SimonQian.com * 4 | * * 5 | * Project: Versaloon * 6 | * File: main.c * 7 | * Author: SimonQian * 8 | * Versaion: See changelog * 9 | * Purpose: main.c file * 10 | * License: See license * 11 | *------------------------------------------------------------------------* 12 | * Change Log: * 13 | * YYYY-MM-DD: What(by Who) * 14 | * 2008-11-07: created(by SimonQian) * 15 | **************************************************************************/ 16 | 17 | /* Includes ------------------------------------------------------------------*/ 18 | #include "app_cfg.h" 19 | #include "interfaces.h" 20 | 21 | #include "usb_protocol.h" 22 | 23 | #if SCRIPTS_EN 24 | # include "app_io.h" 25 | # include "app_log.h" 26 | # include "scripts.h" 27 | # include "vsprog.h" 28 | # include "target_data.h" 29 | #endif 30 | 31 | /* Private typedef -----------------------------------------------------------*/ 32 | /* Private define ------------------------------------------------------------*/ 33 | /* Private macro -------------------------------------------------------------*/ 34 | /* Private variables ---------------------------------------------------------*/ 35 | /* Private function prototypes -----------------------------------------------*/ 36 | /* Private functions ---------------------------------------------------------*/ 37 | int main(void) 38 | { 39 | #if SCRIPTS_EN 40 | FILE *script_file = NULL; 41 | #endif 42 | 43 | core_interfaces.core.init(NULL); 44 | interfaces->tickclk.init(); 45 | interfaces->tickclk.start(); 46 | usb_protocol_init(); 47 | 48 | #if SCRIPTS_EN 49 | run: 50 | KEY_Init(); 51 | #endif 52 | while (1 53 | #if SCRIPTS_EN 54 | && !KEY_IsDown() 55 | #endif 56 | ) 57 | { 58 | usb_protocol_poll(); 59 | } 60 | 61 | #if SCRIPTS_EN 62 | target_init_slots(); 63 | APP_IO_INIT(); 64 | vss_init(); 65 | vss_register_cmd_list(&appio_cmd_list); 66 | vss_register_cmd_list(&vsprog_cmd_list); 67 | 68 | script_file = FOPEN(EVSPROG_SCRIPT_FILE, "rt"); 69 | if (script_file != NULL) 70 | { 71 | FCLOSE(script_file); 72 | script_file = NULL; 73 | if (!usb_device.configured) 74 | { 75 | vss_run_script("dummy 1"); 76 | } 77 | vss_run_script("run " EVSPROG_SCRIPT_FILE); 78 | } 79 | else 80 | { 81 | vss_run_script("shell"); 82 | } 83 | APP_IO_FINI(); 84 | vss_fini(); 85 | goto run; 86 | #endif // if SCRIPTS_EN 87 | } 88 | 89 | /******************* (C) COPYRIGHT 2007 STMicroelectronics *****END OF FILE****/ 90 | -------------------------------------------------------------------------------- /firmware/stlink/stlink.h: -------------------------------------------------------------------------------- 1 | // STLINK Commands 2 | #define STLINK_CMD_START 0xF1 3 | #define STLINK_CMD_END 0XF7 4 | 5 | uint16_t stlink_getpkgsize(uint8_t *cmd, uint16_t len); 6 | uint16_t stlink_process(uint8_t *cmd, uint16_t len); 7 | -------------------------------------------------------------------------------- /firmware/usb_protocol.h: -------------------------------------------------------------------------------- 1 | #ifndef __USB_PROTOCOL_H_INCLUDED__ 2 | #define __USB_PROTOCOL_H_INCLUDED__ 3 | 4 | #include "vsf_usbd_cfg.h" 5 | 6 | #include "stack/usb_device/vsf_usbd_const.h" 7 | #include "stack/usb_device/vsf_usbd.h" 8 | 9 | #include "stack/usb_device/class/CDC/vsfusbd_CDCACM.h" 10 | #include "stack/usb_device/class/HID/vsfusbd_HID.h" 11 | #include "stack/usb_device/class/MSC/vsfusbd_MSC_BOT.h" 12 | 13 | #include "vsfusbd_Versaloon.h" 14 | 15 | extern struct vsfusbd_device_t usb_device; 16 | extern volatile uint32_t rep_len; 17 | 18 | vsf_err_t usb_protocol_init(void); 19 | vsf_err_t usb_protocol_poll(void); 20 | 21 | #endif // __USB_PROTOCOL_H_INCLUDED__ 22 | -------------------------------------------------------------------------------- /firmware/versaloon_usb/vsfusbd_Versaloon.h: -------------------------------------------------------------------------------- 1 | struct vsfusbd_Versaloon_param_t 2 | { 3 | uint8_t ep_out; 4 | uint8_t ep_in; 5 | 6 | bool dbuffer_en; 7 | }; 8 | 9 | extern const struct vsfusbd_class_protocol_t vsfusbd_Versaloon_class; 10 | -------------------------------------------------------------------------------- /flash.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | DEVICE="/dev/ttyUSB0" 3 | FILE="Versaloon-STM32F103C8_BluePill.bin" 4 | docker run --privileged -v $DEVICE:$DEVICE -v $PWD:/mnt zoobab/stm32flash-docker -w /mnt/$FILE -v -g 0x8000000 $DEVICE 5 | EXITCODE="$?" 6 | if [ $EXITCODE -eq 0 ]; then 7 | echo "OK, flashing is successful!" 8 | else 9 | echo "ERROR, there was a flashing error :-(" 10 | fi 11 | -------------------------------------------------------------------------------- /ld/DEF_CLOAD.ld: -------------------------------------------------------------------------------- 1 | /* 2 | Linker subscript for STM32F103 definitions with 32K Flash and 20K RAM 3 | Copyright RAISONANCE 2007-2009 4 | !!! This file is automatically generated by Ride !!! 5 | Do not modify it, as it will be erased at every link. 6 | You can use, copy and distribute this file freely, but without any waranty. 7 | */ 8 | 9 | /* Memory Spaces Definitions */ 10 | 11 | MEMORY 12 | { 13 | RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 20K 14 | FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 128K 15 | FLASHPATCH (r) : ORIGIN = 0x00000000, LENGTH = 0 16 | ENDFLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0 17 | FLASHB1 (rx) : ORIGIN = 0x00000000, LENGTH = 0 18 | EXTMEMB0 (rx) : ORIGIN = 0x00000000, LENGTH = 0 19 | EXTMEMB1 (rx) : ORIGIN = 0x00000000, LENGTH = 0 20 | EXTMEMB2 (rx) : ORIGIN = 0x00000000, LENGTH = 0 21 | EXTMEMB3 (rx) : ORIGIN = 0x00000000, LENGTH = 0 22 | } 23 | 24 | /* higher address of the user mode stack */ 25 | _estack = 0x20005000; 26 | -------------------------------------------------------------------------------- /ld/versaloonSTM32.ld: -------------------------------------------------------------------------------- 1 | /* 2 | Default secondary/main linker script for STM32F103_32K_20K 3 | Copyright RAISONANCE S.A.S. 2007-2009 4 | 5 | !!! This file is automatically generated by Ride if the default linker script option is active !!! 6 | 7 | Do not modify it if the option is set, as it will be erased at every link. 8 | If you need to use your own script please configure your Ride7 project linker options to use your custom linker script 9 | You can take this one as example for wrting your custom linker script 10 | You can use, copy and distribute this file freely, but without any waranty.*/ 11 | 12 | SEARCH_DIR("./tools/make/F103/linker") 13 | 14 | /* include the common STMxxx sub-script */ 15 | INCLUDE "COMMON.ld" 16 | 17 | /* include the memory spaces definitions sub-script */ 18 | INCLUDE "DEF_CLOAD.ld" 19 | 20 | /* include the sections management sub-script for FLASH mode */ 21 | INCLUDE "sections_FLASH.ld" -------------------------------------------------------------------------------- /my_vsllink.cfg: -------------------------------------------------------------------------------- 1 | interface vsllink 2 | adapter_khz 100 3 | transport select jtag 4 | -------------------------------------------------------------------------------- /vsf/compiler/ARMGCC/compiler.h: -------------------------------------------------------------------------------- 1 | #ifndef __COMPILER_H_INCLUDED__ 2 | #define __COMPILER_H_INCLUDED__ 3 | 4 | //#define USE_BUILDIN_STRING_H 5 | 6 | #ifdef USE_BUILDIN_STRING_H 7 | #include 8 | #else 9 | extern void* memcpy(void *m0, const void *m1, int len); 10 | extern int memcmp(const void *m0, const void *m1, int len); 11 | extern void *memset(void *m, int c, int len); 12 | 13 | int strlen(const char *str); 14 | int strcmp(const char *str0, const char *str1); 15 | char* strcpy(char *dest, const char *source); 16 | char* strncpy(char *dest, const char *source, int len); 17 | char* strcat(char *dest, const char *source); 18 | char* strncat(char *dest, const char *source, int len); 19 | char* strchr(const char *str, int c); 20 | char* strstr(const char *str, const char *substr); 21 | char* strdup(const char *source); 22 | #endif 23 | 24 | #define __VSF_FUNCNAME__ __func__ 25 | 26 | #define ROOTFUNC 27 | #define PACKED_HEAD 28 | #define PACKED_MID __attribute__ ((packed)) 29 | #define PACKED_TAIL 30 | 31 | #endif // __COMPILER_H_INCLUDED__ 32 | -------------------------------------------------------------------------------- /vsf/compiler/ARMGCC/compiler_string.c: -------------------------------------------------------------------------------- 1 | #include "app_cfg.h" 2 | 3 | #include 4 | 5 | #ifndef USE_BUILDIN_STRING_H 6 | 7 | 8 | int strlen(const char *str) 9 | { 10 | const char *p = str; 11 | 12 | while (*p)p++; 13 | return (int)(p - str); 14 | } 15 | 16 | int strcmp(const char *str0, const char *str1) 17 | { 18 | for (; *str0 && *str1 && *str0 == *str1; str0++, str1++); 19 | return (*str0 - *str1); 20 | } 21 | 22 | char* strcpy(char *dest, const char *source) 23 | { 24 | char *p = dest; 25 | 26 | if (*source) 27 | { 28 | while ((*p++ = *source++)); 29 | *p = '\0'; 30 | } 31 | return dest; 32 | } 33 | 34 | char* strncpy(char *dest, const char *source, int len) 35 | { 36 | char *p = dest; 37 | 38 | if (*source) 39 | { 40 | while (len-- && (*p++ = *source++)); 41 | *p = '\0'; 42 | } 43 | return dest; 44 | } 45 | 46 | char* strchr(const char *str, int c) 47 | { 48 | while (*str && *str != (char)c) str++; 49 | return (*str == (char)c) ? (char *)str : (char *)NULL; 50 | } 51 | 52 | char* strstr(const char *str, const char *substr) 53 | { 54 | char *pstr, *psub; 55 | 56 | if (!*substr) 57 | return (char *)NULL; 58 | while (*str) 59 | { 60 | pstr = (char *)str; 61 | psub = (char *)substr; 62 | do { 63 | if (!*psub) return pstr; 64 | } while (*pstr++ == *psub++); 65 | str++; 66 | } 67 | return (char *)NULL; 68 | } 69 | 70 | char* strcat(char *dest, const char *source) 71 | { 72 | char *p = dest; 73 | 74 | while (*p)p++; 75 | while ((*p++ = *source++)); 76 | return dest; 77 | } 78 | 79 | char* strncat(char *dest, const char *source, int len) 80 | { 81 | char *p = dest; 82 | 83 | while (*p)p++; 84 | while (len-- && (*p++ = *source++)); 85 | return dest; 86 | } 87 | 88 | char* strdup(const char *source) 89 | { 90 | char *p = (char *)malloc(strlen(source) + 1); 91 | return strcpy(p, source); 92 | } 93 | 94 | void* memcpy(void *dest, const void *source, int len) 95 | { 96 | char *p = dest; 97 | 98 | while(len--) 99 | *(char*)p++ = *(char*)source++; 100 | return dest; 101 | } 102 | 103 | int memcmp(const void *m0, const void *m1, int len) 104 | { 105 | const char *u8_0 = (const char *)m0; 106 | const char *u8_1 = (const char *)m1; 107 | 108 | for (; len > 0; ++u8_0, ++u8_1, --len) 109 | if (*u8_0 != *u8_1) 110 | return (*u8_0 - *u8_1); 111 | return 0; 112 | } 113 | 114 | void *memset(void *m, int c, int len) 115 | { 116 | char *p = (char *)m; 117 | 118 | for (; len > 0; len--) 119 | *p++ = (char)c; 120 | return m; 121 | } 122 | 123 | #endif 124 | -------------------------------------------------------------------------------- /vsf/compiler/ARMGCC/syscall.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | static char *heap = NULL; 5 | caddr_t _sbrk(int incr) 6 | { 7 | extern char _ebss; 8 | char *prev_heap; 9 | 10 | if (heap == NULL) 11 | { 12 | heap = &_ebss; 13 | } 14 | prev_heap = heap; 15 | 16 | heap += incr; 17 | return (caddr_t)prev_heap; 18 | } 19 | 20 | int _open(const char *name, int flags, int mode) 21 | { 22 | return -1; 23 | } 24 | 25 | int _close(int fd) 26 | { 27 | return 0; 28 | } 29 | 30 | int _fstat(int fd, struct stat *st) 31 | { 32 | st->st_mode = S_IFCHR; 33 | return 0; 34 | } 35 | 36 | int _isatty(int fd) 37 | { 38 | return 1; 39 | } 40 | 41 | int _lseek(int fd, int ptr, int dir) 42 | { 43 | return 0; 44 | } 45 | 46 | int _read(int fd, char *buf, int len) 47 | { 48 | return 0; 49 | } 50 | 51 | int _write(int fd, const void *buf, int len) 52 | { 53 | return len; 54 | } 55 | 56 | -------------------------------------------------------------------------------- /vsf/compiler/GCC/compiler.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 - 2010 by Simon Qian * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 18 | ***************************************************************************/ 19 | 20 | #ifndef __COMPILER_H_INCLUDED__ 21 | #define __COMPILER_H_INCLUDED__ 22 | 23 | #include 24 | 25 | #define __VSF_FUNCNAME__ __func__ 26 | 27 | #define ROOTFUNC 28 | #define PACKED_HEAD 29 | #define PACKED_MID __attribute__ ((packed)) 30 | #define PACKED_TAIL 31 | 32 | #endif // __COMPILER_H_INCLUDED__ 33 | -------------------------------------------------------------------------------- /vsf/dal/cfi/cfi_drv.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 - 2010 by Simon Qian * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 18 | ***************************************************************************/ 19 | 20 | #ifndef __CFI_DRV_H_INCLUDED__ 21 | #define __CFI_DRV_H_INCLUDED__ 22 | 23 | struct cfi_drv_param_t 24 | { 25 | struct ebi_sram_psram_nor_info_t nor_info; 26 | uint32_t base_addr; 27 | }; 28 | 29 | struct cfi_drv_info_t 30 | { 31 | uint8_t die_num; 32 | uint8_t manufacturer_id; 33 | uint16_t device_id[3]; 34 | }; 35 | 36 | struct cfi_drv_interface_t 37 | { 38 | uint8_t ebi_port; 39 | uint8_t nor_index; 40 | }; 41 | 42 | extern const struct mal_driver_t cfi_drv; 43 | 44 | #endif /* __CFI_DRV_H_INCLUDED__ */ 45 | 46 | -------------------------------------------------------------------------------- /vsf/dal/dal.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 - 2010 by Simon Qian * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 18 | ***************************************************************************/ 19 | 20 | #ifndef __DAL_H_INCLUDED__ 21 | #define __DAL_H_INCLUDED__ 22 | 23 | #include "app_cfg.h" 24 | #include "app_type.h" 25 | #include "dal_cfg.h" 26 | #include "interfaces.h" 27 | 28 | struct dal_info_t 29 | { 30 | void *ifs; 31 | void *param; 32 | void *info; 33 | void *extra; 34 | }; 35 | 36 | struct dal_driver_t 37 | { 38 | char *name; 39 | #if DAL_INTERFACE_PARSER_EN 40 | char *ifs_format; 41 | vsf_err_t (*parse_interface)(struct dal_info_t *info, uint8_t *buff); 42 | #endif 43 | }; 44 | 45 | extern struct dal_driver_t *dal_drivers[]; 46 | 47 | #endif // __DAL_H_INCLUDED__ 48 | -------------------------------------------------------------------------------- /vsf/dal/df25xx/df25xx_drv.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 - 2010 by Simon Qian * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 18 | ***************************************************************************/ 19 | 20 | #ifndef __DF25XX_DRV_H_INCLUDED__ 21 | #define __DF25XX_DRV_H_INCLUDED__ 22 | 23 | struct df25xx_drv_param_t 24 | { 25 | uint16_t spi_khz; 26 | }; 27 | 28 | struct df25xx_drv_info_t 29 | { 30 | uint8_t manufacturer_id; 31 | uint16_t device_id; 32 | }; 33 | 34 | struct df25xx_drv_interface_t 35 | { 36 | uint8_t cs_port; 37 | uint32_t cs_pin; 38 | uint8_t spi_port; 39 | }; 40 | 41 | extern const struct mal_driver_t df25xx_drv; 42 | 43 | #endif /* __DF25XX_DRV_H_INCLUDED__ */ 44 | 45 | -------------------------------------------------------------------------------- /vsf/dal/df25xx/df25xx_drv_cfg.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 - 2010 by Simon Qian * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 18 | ***************************************************************************/ 19 | 20 | 21 | -------------------------------------------------------------------------------- /vsf/dal/df45xx/df45xx_drv.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 - 2010 by Simon Qian * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 18 | ***************************************************************************/ 19 | 20 | #ifndef __DF45XX_DRV_H_INCLUDED__ 21 | #define __DF45XX_DRV_H_INCLUDED__ 22 | 23 | struct df45xx_drv_param_t 24 | { 25 | uint16_t spi_khz; 26 | }; 27 | 28 | struct df45xx_drv_interface_t 29 | { 30 | uint8_t cs_port; 31 | uint32_t cs_pin; 32 | uint8_t spi_port; 33 | }; 34 | 35 | extern const struct mal_driver_t df45xx_drv; 36 | 37 | #endif // __DF45XX_DRV_H_INCLUDED__ 38 | 39 | -------------------------------------------------------------------------------- /vsf/dal/df45xx/df45xx_drv_cfg.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 - 2010 by Simon Qian * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 18 | ***************************************************************************/ 19 | 20 | -------------------------------------------------------------------------------- /vsf/dal/ee24cxx/ee24cxx_drv.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 - 2010 by Simon Qian * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 18 | ***************************************************************************/ 19 | 20 | #ifndef __EE24CXX_DRV_H_INCLUDED__ 21 | #define __EE24CXX_DRV_H_INCLUDED__ 22 | 23 | struct ee24cxx_drv_param_t 24 | { 25 | uint16_t iic_khz; 26 | uint8_t iic_addr; 27 | }; 28 | 29 | struct ee24cxx_drv_interface_t 30 | { 31 | uint8_t iic_port; 32 | }; 33 | 34 | extern const struct mal_driver_t ee24cxx_drv; 35 | 36 | #endif /* __EE24CXX_DRV_H_INCLUDED__ */ 37 | 38 | -------------------------------------------------------------------------------- /vsf/dal/ee24cxx/ee24cxx_drv_cfg.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 - 2010 by Simon Qian * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 18 | ***************************************************************************/ 19 | 20 | 21 | -------------------------------------------------------------------------------- /vsf/dal/ee93cx6/ee93cx6_drv.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 - 2010 by Simon Qian * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 18 | ***************************************************************************/ 19 | 20 | #ifndef __EE93CX6_DRV_H_INCLUDED__ 21 | #define __EE93CX6_DRV_H_INCLUDED__ 22 | 23 | #define EE93CX6_ORIGINATION_BYTE 0 24 | #define EE93CX6_ORIGINATION_WORD 1 25 | 26 | struct ee93cx6_drv_param_t 27 | { 28 | uint16_t iic_khz; 29 | uint8_t addr_bitlen; 30 | uint8_t cmd_bitlen; 31 | uint8_t origination_mode; 32 | }; 33 | 34 | struct ee93cx6_drv_interface_t 35 | { 36 | uint8_t mw_port; 37 | }; 38 | 39 | extern const struct mal_driver_t ee93cx6_drv; 40 | 41 | #endif /* __EE93CX6_DRV_H_INCLUDED__ */ 42 | 43 | -------------------------------------------------------------------------------- /vsf/dal/ee93cx6/ee93cx6_drv_cfg.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 - 2010 by Simon Qian * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 18 | ***************************************************************************/ 19 | 20 | 21 | #define EE93CX6_POLL_INTERVAL_US 10 22 | #define EE93CX6_POLL_RETRY_CNT 1000 23 | 24 | -------------------------------------------------------------------------------- /vsf/dal/mic2826/mic2826_drv.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 - 2010 by Simon Qian * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 18 | ***************************************************************************/ 19 | 20 | #ifndef __MIC2826_DRV_H_INCLUDED__ 21 | #define __MIC2826_DRV_H_INCLUDED__ 22 | 23 | #include "dal_cfg.h" 24 | #include "../dal.h" 25 | 26 | #define MIC2826_CHANNEL_DCDC 0 27 | #define MIC2826_CHANNEL_LDO1 1 28 | #define MIC2826_CHANNEL_LDO2 2 29 | #define MIC2826_CHANNEL_LDO3 3 30 | 31 | struct mic2826_drv_t 32 | { 33 | struct dal_driver_t driver; 34 | vsf_err_t (*init)(struct dal_info_t *info); 35 | vsf_err_t (*fini)(struct dal_info_t *info); 36 | vsf_err_t (*config)(struct dal_info_t *info, uint16_t DCDC_mV, 37 | uint16_t LDO1_mV, uint16_t LDO2_mV, uint16_t LDO3_mV); 38 | }; 39 | 40 | struct mic2826_drv_interface_t 41 | { 42 | uint8_t iic_port; 43 | }; 44 | 45 | struct mic2826_drv_param_t 46 | { 47 | uint16_t kHz; 48 | }; 49 | 50 | extern const struct mic2826_drv_t mic2826_drv; 51 | 52 | #endif // __MIC2826_DRV_H_INCLUDED__ 53 | 54 | -------------------------------------------------------------------------------- /vsf/dal/mic2826/mic2826_drv_cfg.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 - 2010 by Simon Qian * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 18 | ***************************************************************************/ 19 | 20 | #define MIC2826_HAS_LDO3 0 21 | 22 | -------------------------------------------------------------------------------- /vsf/dal/nand/nand_drv.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 - 2010 by Simon Qian * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 18 | ***************************************************************************/ 19 | 20 | #ifndef __NAND_DRV_H_INCLUDED__ 21 | #define __NAND_DRV_H_INCLUDED__ 22 | 23 | struct nand_drv_param_t 24 | { 25 | struct ebi_nand_info_t nand_info; 26 | bool block_read_en; 27 | uint8_t col_addr_size; 28 | uint8_t col_addr_msb; 29 | uint8_t row_addr_lsb; 30 | uint8_t row_addr_size; 31 | // private 32 | bool addr_loadded; 33 | }; 34 | 35 | struct nand_drv_info_t 36 | { 37 | uint8_t manufacturer_id; 38 | uint16_t device_id[3]; 39 | }; 40 | 41 | struct nand_drv_interface_t 42 | { 43 | uint8_t ebi_port; 44 | uint8_t nand_index; 45 | }; 46 | 47 | extern const struct mal_driver_t nand_drv; 48 | 49 | #endif /* __NAND_DRV_H_INCLUDED__ */ 50 | 51 | -------------------------------------------------------------------------------- /vsf/dal/nrf24l01/nrf24l01_drv_cfg.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 - 2010 by Simon Qian * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 18 | ***************************************************************************/ 19 | 20 | -------------------------------------------------------------------------------- /vsf/dal/s6b0724/s6b0724_drv.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 - 2010 by Simon Qian * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 18 | ***************************************************************************/ 19 | 20 | #ifndef __S6B0724_DRV_H_INCLUDED__ 21 | #define __S6B0724_DRV_H_INCLUDED__ 22 | 23 | struct s6b0724_drv_param_t 24 | { 25 | struct ebi_sram_psram_nor_info_t nor_info; 26 | }; 27 | 28 | struct s6b0724_drv_interface_t 29 | { 30 | uint8_t ebi_port; 31 | uint8_t lcd_index; 32 | 33 | uint32_t cmd_addr; 34 | uint32_t data_addr; 35 | }; 36 | 37 | extern const struct mal_driver_t s6b0724_drv; 38 | 39 | #endif // __S6B0724_DRV_H_INCLUDED__ 40 | 41 | -------------------------------------------------------------------------------- /vsf/dal/s6b0724/s6b0724_drv_cfg.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 - 2010 by Simon Qian * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 18 | ***************************************************************************/ 19 | 20 | -------------------------------------------------------------------------------- /vsf/dal/sd/sd_common.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 - 2010 by Simon Qian * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 18 | ***************************************************************************/ 19 | 20 | #include "app_cfg.h" 21 | #include "app_type.h" 22 | 23 | #include "../mal/mal.h" 24 | #include "../mal/mal_driver.h" 25 | 26 | #if DAL_SD_SPI_EN || DAL_SD_SDIO_EN 27 | 28 | #include "sd_common.h" 29 | 30 | uint8_t sd_spi_cmd_chksum(uint8_t *data, uint32_t num) 31 | { 32 | uint8_t crc, mask, i; 33 | uint32_t j; 34 | 35 | crc = 0; 36 | for (j = 0; j < num; j++) 37 | { 38 | mask = data[j] & 0x80 ? 0x40 : 0x00; 39 | if ((crc & 0x40) ^ mask) 40 | { 41 | crc <<= 1; 42 | crc ^= SD_CRC7_POLY; 43 | } 44 | else 45 | { 46 | crc <<= 1; 47 | } 48 | crc ^= data[j]; 49 | 50 | for (i = 0; i < 7; i++) 51 | { 52 | if (crc & 0x40) 53 | { 54 | crc <<= 1; 55 | crc ^= SD_CRC7_POLY; 56 | } 57 | else 58 | { 59 | crc <<= 1; 60 | } 61 | } 62 | } 63 | return crc & 0x7F; 64 | } 65 | 66 | vsf_err_t sd_parse_csd(uint8_t *csd, struct sd_info_t *info) 67 | { 68 | struct mal_capacity_t tmp_cap; 69 | uint32_t c_size, c_size_mult, bl_len; 70 | 71 | tmp_cap.block_size = 512; 72 | if (csd[0] & 0x40) 73 | { 74 | // csd 2.0 75 | tmp_cap.block_number = ((((csd[7] & 0xFC) << 16) | 76 | ((csd[8] & 0xFF) << 8) | ((csd[9] & 0xFF) << 0)) + 1) * 1024; 77 | } 78 | else 79 | { 80 | // csd 1.0 81 | c_size = csd[6] & 0x03; 82 | c_size <<= 8; 83 | c_size += csd[7]; 84 | c_size <<= 2; 85 | c_size += ((csd[8] & 0xc0) >> 6); 86 | c_size_mult = csd[9] & 0x03; 87 | c_size_mult <<= 1; 88 | c_size_mult += ((csd[10] & 0x80) >> 7); 89 | bl_len = csd[5] & 0x0F; 90 | tmp_cap.block_number = (c_size + 1) * (1 << (c_size_mult + 2)) * 91 | (1 << bl_len) / tmp_cap.block_size; 92 | } 93 | if (info != NULL) 94 | { 95 | info->capacity = tmp_cap; 96 | } 97 | return VSFERR_NONE; 98 | } 99 | 100 | #endif 101 | -------------------------------------------------------------------------------- /vsf/dal/sd/sd_sdio_drv.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 - 2010 by Simon Qian * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 18 | ***************************************************************************/ 19 | 20 | #ifndef __SD_SDIO_DRV_H_INCLUDED__ 21 | #define __SD_SDIO_DRV_H_INCLUDED__ 22 | 23 | struct sd_sdio_drv_interface_t 24 | { 25 | uint8_t sdio_port; 26 | uint8_t sdio_bus_width; 27 | }; 28 | 29 | struct sd_sdio_drv_info_t 30 | { 31 | uint16_t rca; 32 | uint64_t scr; 33 | 34 | enum sd_sdio_drv_state_t 35 | { 36 | SD_SDIO_DRV_WAITRESP, 37 | SD_SDIO_DRV_WAITBUSY, 38 | SD_SDIO_DRV_WAITDATATOK, 39 | SD_SDIO_DRV_WAITDATALASTBUSY, 40 | } state; 41 | uint32_t retry; 42 | uint64_t cur_block; 43 | uint64_t total_block; 44 | uint32_t total_size; 45 | }; 46 | 47 | extern const struct mal_driver_t sd_sdio_drv; 48 | 49 | #endif /* __SD_SDIO_DRV_H_INCLUDED__ */ 50 | 51 | -------------------------------------------------------------------------------- /vsf/dal/sd/sd_spi_drv.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 - 2010 by Simon Qian * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 18 | ***************************************************************************/ 19 | 20 | #ifndef __SD_SPI_DRV_H_INCLUDED__ 21 | #define __SD_SPI_DRV_H_INCLUDED__ 22 | 23 | struct sd_spi_drv_interface_t 24 | { 25 | uint8_t cs_port; 26 | uint32_t cs_pin; 27 | uint8_t spi_port; 28 | }; 29 | 30 | struct sd_spi_drv_info_t 31 | { 32 | enum sd_spi_drv_state_t 33 | { 34 | SD_SPI_DRV_WAITRESP, 35 | SD_SPI_DRV_WAITBUSY, 36 | SD_SPI_DRV_WAITDATATOK, 37 | SD_SPI_DRV_WAITDATALASTBUSY, 38 | } state; 39 | uint32_t retry; 40 | uint64_t cur_block; 41 | uint64_t total_block; 42 | }; 43 | 44 | extern const struct mal_driver_t sd_spi_drv; 45 | 46 | #endif /* __SD_SPI_DRV_H_INCLUDED__ */ 47 | 48 | -------------------------------------------------------------------------------- /vsf/dal/sd/sd_spi_drv_cfg.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 - 2010 by Simon Qian * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 18 | ***************************************************************************/ 19 | 20 | #define SD_SPI_CMD_TIMEOUT 32 21 | 22 | -------------------------------------------------------------------------------- /vsf/dal/sst32hfxx/sst32hfxx_drv.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 - 2010 by Simon Qian * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 18 | ***************************************************************************/ 19 | 20 | #ifndef __SST32HFXX_DRV_H_INCLUDED__ 21 | #define __SST32HFXX_DRV_H_INCLUDED__ 22 | 23 | struct sst32hfxx_drv_param_t 24 | { 25 | struct ebi_sram_psram_nor_info_t nor_info; 26 | uint32_t base_addr; 27 | uint16_t delayus; 28 | }; 29 | 30 | struct sst32hfxx_drv_info_t 31 | { 32 | uint8_t manufacturer_id; 33 | uint16_t device_id; 34 | }; 35 | 36 | struct sst32hfxx_drv_interface_t 37 | { 38 | uint8_t ebi_port; 39 | uint8_t nor_index; 40 | }; 41 | 42 | extern const struct mal_driver_t sst32hfxx_nor_drv; 43 | 44 | #endif /* __SST32HFXX_DRV_H_INCLUDED__ */ 45 | 46 | -------------------------------------------------------------------------------- /vsf/dal/stream/stream.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 - 2010 by Simon Qian * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 18 | ***************************************************************************/ 19 | 20 | #include "app_cfg.h" 21 | #include "app_type.h" 22 | 23 | #include "stream.h" 24 | 25 | vsf_err_t stream_init(struct vsf_stream_t *stream) 26 | { 27 | stream->overflow = false; 28 | vsf_fifo_init(&stream->fifo); 29 | return VSFERR_NONE; 30 | } 31 | 32 | vsf_err_t stream_fini(struct vsf_stream_t *stream) 33 | { 34 | REFERENCE_PARAMETER(stream); 35 | return VSFERR_NONE; 36 | } 37 | 38 | uint32_t stream_rx(struct vsf_stream_t *stream, struct vsf_buffer_t *buffer) 39 | { 40 | return vsf_fifo_pop(&stream->fifo, buffer->size, buffer->buffer); 41 | } 42 | 43 | uint32_t stream_tx(struct vsf_stream_t *stream, struct vsf_buffer_t *buffer) 44 | { 45 | uint32_t tx_size; 46 | 47 | tx_size = vsf_fifo_push(&stream->fifo, buffer->size, buffer->buffer); 48 | if (tx_size < buffer->size) 49 | { 50 | stream->overflow = true; 51 | } 52 | return tx_size; 53 | } 54 | 55 | uint32_t stream_get_data_size(struct vsf_stream_t *stream) 56 | { 57 | return vsf_fifo_get_data_length(&stream->fifo); 58 | } 59 | 60 | uint32_t stream_get_free_size(struct vsf_stream_t *stream) 61 | { 62 | return vsf_fifo_get_avail_length(&stream->fifo); 63 | } 64 | -------------------------------------------------------------------------------- /vsf/dal/stream/stream.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 - 2010 by Simon Qian * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 18 | ***************************************************************************/ 19 | 20 | #ifndef __STREAM_H_INCLUDED__ 21 | #define __STREAM_H_INCLUDED__ 22 | 23 | #include "tool/buffer/buffer.h" 24 | 25 | struct vsf_stream_t 26 | { 27 | struct vsf_fifo_t fifo; 28 | bool overflow; 29 | }; 30 | 31 | vsf_err_t stream_init(struct vsf_stream_t *stream); 32 | vsf_err_t stream_fini(struct vsf_stream_t *stream); 33 | uint32_t stream_rx(struct vsf_stream_t *stream, struct vsf_buffer_t *buffer); 34 | uint32_t stream_tx(struct vsf_stream_t *stream, struct vsf_buffer_t *buffer); 35 | uint32_t stream_get_data_size(struct vsf_stream_t *stream); 36 | uint32_t stream_get_free_size(struct vsf_stream_t *stream); 37 | 38 | #endif // __STREAM_H_INCLUDED__ 39 | -------------------------------------------------------------------------------- /vsf/dal/usart_stream/usart_stream.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 - 2010 by Simon Qian * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 18 | ***************************************************************************/ 19 | 20 | #ifndef __USART_STREAM_H_INCLUDED__ 21 | #define __USART_STREAM_H_INCLUDED__ 22 | 23 | #include "dal/stream/stream.h" 24 | 25 | struct usart_info_t 26 | { 27 | uint32_t baudrate; 28 | uint8_t datalength; 29 | uint8_t mode; 30 | }; 31 | 32 | struct usart_stream_info_t 33 | { 34 | uint8_t usart_index; 35 | struct vsf_stream_t stream_tx; 36 | struct vsf_stream_t stream_rx; 37 | struct usart_info_t usart_info; 38 | }; 39 | 40 | vsf_err_t usart_stream_init(struct usart_stream_info_t *usart_stream); 41 | vsf_err_t usart_stream_fini(struct usart_stream_info_t *usart_stream); 42 | vsf_err_t usart_stream_config(struct usart_stream_info_t *usart_stream); 43 | uint32_t usart_stream_rx(struct usart_stream_info_t *usart_stream, 44 | struct vsf_buffer_t *buffer); 45 | uint32_t usart_stream_tx(struct usart_stream_info_t *usart_stream, 46 | struct vsf_buffer_t *buffer); 47 | vsf_err_t usart_stream_poll(struct usart_stream_info_t *usart_stream); 48 | 49 | #endif // __USART_STREAM_H_INCLUDED__ 50 | -------------------------------------------------------------------------------- /vsf/interfaces/cpu/pc/app_interfaces.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 - 2010 by Simon Qian * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 18 | ***************************************************************************/ 19 | #ifndef __APP_INTERFACES_H_INCLUDED__ 20 | #define __APP_INTERFACES_H_INCLUDED__ 21 | 22 | #include "versaloon.h" 23 | 24 | #define interfaces (&versaloon_interfaces) 25 | 26 | #endif 27 | 28 | -------------------------------------------------------------------------------- /vsf/interfaces/cpu/pc/app_io.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 - 2010 by Simon Qian * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 18 | ***************************************************************************/ 19 | #ifndef __APP_IO_H_INCLUDED__ 20 | #define __APP_IO_H_INCLUDED__ 21 | 22 | #include 23 | 24 | #define APP_IO_INIT() 25 | 26 | #define FOPEN fopen 27 | #define FCLOSE fclose 28 | #define FEOF feof 29 | #define REWIND rewind 30 | #define FFLUSH fflush 31 | #define FREAD fread 32 | #define FWRITE fwrite 33 | #define FSEEK fseek 34 | #define FTELL ftell 35 | #define FVALID(f) (f != NULL) 36 | 37 | #define FPRINTF fprintf 38 | #define PRINTF printf 39 | #define SNPRINTF snprintf 40 | 41 | #define FGETS fgets 42 | #define GETCHAR getchar 43 | 44 | #endif // __APP_IO_H_INCLUDED__ 45 | 46 | -------------------------------------------------------------------------------- /vsf/interfaces/cpu/pc/app_log.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 - 2010 by Simon Qian * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 18 | ***************************************************************************/ 19 | #ifdef HAVE_CONFIG_H 20 | #include "config.h" 21 | #endif 22 | 23 | #include "app_log.h" 24 | 25 | int verbosity_pos = 0; 26 | int verbosity = LOG_DEFAULT_LEVEL, verbosity_stack[16]; 27 | 28 | -------------------------------------------------------------------------------- /vsf/interfaces/cpu/pc/app_string.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 - 2010 by Simon Qian * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 18 | ***************************************************************************/ 19 | #ifndef __APP_STRING_H_INCLUDED__ 20 | #define __APP_STRING_H_INCLUDED__ 21 | 22 | #include 23 | #include 24 | 25 | #define MALLOC malloc 26 | #define FREE free 27 | 28 | #define STRDUP strdup 29 | #define STRCPY strcpy 30 | #define STRNCPY strncpy 31 | #define STRCAT strcat 32 | #define STRNCAT strncat 33 | #define STRCMP strcmp 34 | 35 | #endif // __APP_STRING_H_INCLUDED__ 36 | 37 | -------------------------------------------------------------------------------- /vsf/interfaces/cpu/pc/driver/port.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 - 2010 by Simon Qian * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 18 | ***************************************************************************/ 19 | #ifndef __PORT_H_INCLUDED__ 20 | #define __PORT_H_INCLUDED__ 21 | 22 | #ifdef HAVE_CONFIG_H 23 | #include "config.h" 24 | #endif 25 | 26 | #include 27 | 28 | #if IS_WIN32 29 | 30 | #include 31 | 32 | #define FILE_SEPARATOR '\\' 33 | #define sleep_ms(ms) Sleep(ms) 34 | 35 | #else /* !IS_WIN32 */ 36 | 37 | #include 38 | #include 39 | #include 40 | 41 | #define FILE_SEPARATOR '/' 42 | #define sleep_ms(ms) usleep((ms) * 1000) 43 | 44 | #endif /* IS_WIN32 */ 45 | 46 | 47 | 48 | 49 | 50 | #ifndef MAX_PATH 51 | # define MAX_PATH 260 52 | #endif 53 | 54 | #endif /* __PORT_H_INCLUDED__ */ 55 | 56 | -------------------------------------------------------------------------------- /vsf/interfaces/cpu/pc/driver/usb/usbapi.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 - 2010 by Simon Qian * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 18 | ***************************************************************************/ 19 | #ifndef __USBAPI_H_INCLUDED__ 20 | #define __USBAPI_H_INCLUDED__ 21 | 22 | #include "usb.h" 23 | 24 | extern struct vss_cmd_list_t usbapi_cmd_list; 25 | 26 | struct usbapi_param_t 27 | { 28 | uint8_t valid; 29 | uint16_t vid; 30 | uint16_t pid; 31 | uint8_t epin; 32 | uint8_t epout; 33 | uint8_t interface; 34 | char typestring[256]; 35 | char serialstring[256]; 36 | }; 37 | extern struct usbapi_param_t usb_param; 38 | 39 | uint8_t usb_param_valid(void); 40 | uint16_t usb_param_vid(void); 41 | uint16_t usb_param_pid(void); 42 | uint8_t usb_param_epin(void); 43 | uint8_t usb_param_epout(void); 44 | uint8_t usb_param_interface(void); 45 | char *usb_param_type(void); 46 | char *usb_param_serial(void); 47 | void usb_set_param(uint16_t vid, uint16_t pid, uint8_t epin, uint8_t epout, 48 | uint8_t interface); 49 | uint32_t print_usb_devices(uint16_t VID, uint16_t PID, int8_t serialindex, 50 | char *serialstring, int8_t productindex, 51 | char *productstring); 52 | usb_dev_handle* find_usb_device(uint16_t VID, uint16_t PID, uint8_t interface, 53 | int8_t serialindex, char *serialstring, 54 | int8_t productindex, char *productstring); 55 | 56 | #endif /* __USBAPI_H_INCLUDED__ */ 57 | 58 | -------------------------------------------------------------------------------- /vsf/interfaces/cpu/pc/interfaces_const.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 - 2010 by Simon Qian * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 18 | ***************************************************************************/ 19 | #ifndef __PROG_INTERFACE_H_INCLUDED__ 20 | #define __PROG_INTERFACE_H_INCLUDED__ 21 | 22 | // GPIO 23 | #define usbtoxxx_GPIO_DIR_MSK 0x01 24 | #define usbtoxxx_GPIO_OUT usbtoxxx_GPIO_DIR_MSK 25 | #define usbtoxxx_GPIO_IN 0 26 | #define usbtoxxx_GPIO_PULLEN_MSK 0x02 27 | #define usbtoxxx_GPIO_PULLEN usbtoxxx_GPIO_PULLEN_MSK 28 | #define usbtoxxx_GPIO_PULLDIS 0x00 29 | #define usbtoxxx_GPIO_OUT_MSK 0x04 30 | #define usbtoxxx_GPIO_OUT1 usbtoxxx_GPIO_OUT_MSK 31 | #define usbtoxxx_GPIO_OUT0 0x00 32 | 33 | #define usbtoxxx_GPIO_INFLOAT 0 34 | #define usbtoxxx_GPIO_INPU 0x06 35 | #define usbtoxxx_GPIO_INPD 0x02 36 | #define usbtoxxx_GPIO_OUTPP 0x01 37 | #define usbtoxxx_GPIO_OUTOD 0x05 38 | 39 | // ADC 40 | #define usbtoxxx_ADC_ALIGNLEFT 0x08 41 | #define usbtoxxx_ADC_ALIGNRIGHT 0x00 42 | 43 | // SPI 44 | #define usbtoxxx_SPI_MASTER 0x04 45 | #define usbtoxxx_SPI_SLAVE 0x00 46 | #define usbtoxxx_SPI_MODE0 0 47 | #define usbtoxxx_SPI_MODE1 1 48 | #define usbtoxxx_SPI_MODE2 2 49 | #define usbtoxxx_SPI_MODE3 3 50 | #define usbtoxxx_SPI_MSB_FIRST 0x00 51 | #define usbtoxxx_SPI_LSB_FIRST 0x80 52 | 53 | #endif /* __PROG_INTERFACE_H_INCLUDED__ */ 54 | 55 | -------------------------------------------------------------------------------- /vsf/interfaces/cpu/pc/usbtoxxx/usbtoadc.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 - 2010 by Simon Qian * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 18 | ***************************************************************************/ 19 | #ifdef HAVE_CONFIG_H 20 | #include "config.h" 21 | #endif 22 | 23 | #include "compiler.h" 24 | 25 | #include "interfaces.h" 26 | #include "usbtoxxx.h" 27 | #include "usbtoxxx_internal.h" 28 | 29 | vsf_err_t usbtoadc_init(uint8_t index) 30 | { 31 | return usbtoxxx_init_command(USB_TO_ADC, index); 32 | } 33 | 34 | vsf_err_t usbtoadc_fini(uint8_t index) 35 | { 36 | return usbtoxxx_fini_command(USB_TO_ADC, index); 37 | } 38 | 39 | vsf_err_t usbtoadc_config(uint8_t index, uint32_t clock_hz, 40 | uint8_t mode) 41 | { 42 | uint8_t cmdbuf[5]; 43 | 44 | SET_LE_U32(cmdbuf, clock_hz); 45 | cmdbuf[4] = mode; 46 | return usbtoxxx_conf_command(USB_TO_ADC, index, cmdbuf, 5); 47 | } 48 | 49 | vsf_err_t usbtoadc_config_channel(uint8_t index, uint8_t channel, 50 | uint8_t cycles) 51 | { 52 | uint8_t cmdbuf[2]; 53 | 54 | cmdbuf[0] = channel; 55 | cmdbuf[1] = cycles; 56 | return usbtoxxx_out_command(USB_TO_ADC, index, cmdbuf, 2, 0); 57 | } 58 | 59 | vsf_err_t usbtoadc_calibrate(uint8_t index, uint8_t channel) 60 | { 61 | uint8_t cmdbuf[1]; 62 | 63 | cmdbuf[0] = channel; 64 | return usbtoxxx_special_command(USB_TO_ADC, index, cmdbuf, 1, 0, 65 | NULL, 0, 0, 0); 66 | } 67 | 68 | vsf_err_t usbtoadc_sample(uint8_t index, uint8_t channel, 69 | uint32_t *voltage) 70 | { 71 | uint8_t cmdbuf[1]; 72 | 73 | cmdbuf[0] = channel; 74 | return usbtoxxx_inout_command(USB_TO_ADC, index, cmdbuf, 1, 4, 75 | (uint8_t *)voltage, 0, 4, 0); 76 | } 77 | -------------------------------------------------------------------------------- /vsf/interfaces/cpu/pc/usbtoxxx/usbtoclko.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 - 2010 by Simon Qian * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 18 | ***************************************************************************/ 19 | #ifdef HAVE_CONFIG_H 20 | #include "config.h" 21 | #endif 22 | 23 | #include "compiler.h" 24 | 25 | #include "interfaces.h" 26 | #include "usbtoxxx.h" 27 | #include "usbtoxxx_internal.h" 28 | 29 | vsf_err_t usbtoclko_init(uint8_t index) 30 | { 31 | return usbtoxxx_init_command(USB_TO_CLKO, index); 32 | } 33 | 34 | vsf_err_t usbtoclko_fini(uint8_t index) 35 | { 36 | return usbtoxxx_fini_command(USB_TO_CLKO, index); 37 | } 38 | 39 | vsf_err_t usbtoclko_config(uint8_t index, uint32_t kHz) 40 | { 41 | uint8_t cmdbuf[4]; 42 | 43 | SET_LE_U32(cmdbuf, kHz); 44 | return usbtoxxx_conf_command(USB_TO_CLKO, index, cmdbuf, 4); 45 | } 46 | 47 | vsf_err_t usbtoclko_enable(uint8_t index) 48 | { 49 | return usbtoxxx_enable_command(USB_TO_CLKO, index, NULL, 0); 50 | } 51 | 52 | vsf_err_t usbtoclko_disable(uint8_t index) 53 | { 54 | return usbtoxxx_disable_command(USB_TO_CLKO, index, NULL, 0); 55 | } 56 | -------------------------------------------------------------------------------- /vsf/interfaces/cpu/pc/usbtoxxx/usbtousart.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 - 2010 by Simon Qian * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 18 | ***************************************************************************/ 19 | #ifdef HAVE_CONFIG_H 20 | #include "config.h" 21 | #endif 22 | 23 | #include "compiler.h" 24 | 25 | #include "interfaces.h" 26 | #include "usbtoxxx.h" 27 | #include "usbtoxxx_internal.h" 28 | 29 | -------------------------------------------------------------------------------- /vsf/interfaces/cpu/pc/versaloon.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 - 2010 by Simon Qian * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 18 | ***************************************************************************/ 19 | #ifndef __VERSALOON_H_INCLUDED__ 20 | #define __VERSALOON_H_INCLUDED__ 21 | 22 | extern struct interfaces_info_t versaloon_interfaces; 23 | 24 | #endif /* __VERSALOON_H_INCLUDED__ */ 25 | 26 | -------------------------------------------------------------------------------- /vsf/interfaces/cpu/pc/versaloon_include.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 - 2010 by Simon Qian * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 18 | ***************************************************************************/ 19 | // This file is used to include different header and macros 20 | // according to different platform 21 | #include "port.h" 22 | 23 | #include "app_cfg.h" 24 | #include "app_type.h" 25 | #include "app_io.h" 26 | #include "app_err.h" 27 | #include "app_log.h" 28 | -------------------------------------------------------------------------------- /vsf/interfaces/cpu/pc/versaloon_internal.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 - 2010 by Simon Qian * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 18 | ***************************************************************************/ 19 | #ifndef __VERSALOON_INTERNAL_H_INCLUDED__ 20 | #define __VERSALOON_INTERNAL_H_INCLUDED__ 21 | 22 | #define VERSALOON_TIMEOUT 5000 23 | #define VERSALOON_TIMEOUT_LONG 60000 24 | 25 | // USB Commands 26 | // Common Commands 27 | #define VERSALOON_COMMON_CMD_START 0x00 28 | #define VERSALOON_COMMON_CMD_END 0x0F 29 | 30 | #define VERSALOON_GET_INFO 0x00 31 | #define VERSALOON_FW_UPDATE 0x0F 32 | #define VERSALOON_FW_UPDATE_KEY 0xAA 33 | 34 | // USB_TO_XXX Command 35 | #define VERSALOON_USB_TO_XXX_CMD_START 0x20 36 | #define VERSALOON_USB_TO_XXX_CMD_END 0x7F 37 | 38 | #endif /* __VERSALOON_INTERNAL_H_INCLUDED__ */ 39 | 40 | -------------------------------------------------------------------------------- /vsf/interfaces/cpu/pc/versaloon_libusb.h: -------------------------------------------------------------------------------- 1 | #ifndef __VERSALOON_LIBUSB_H_INCLLUDED__ 2 | #define __VERSALOON_LIBUSB_H_INCLUDED__ 3 | 4 | extern struct interfaces_comm_t versaloon_libusb_comm; 5 | 6 | #endif // __VERSALOON_LIBUSB_H_INCLUDED__ 7 | -------------------------------------------------------------------------------- /vsf/interfaces/cpu/pc/vsf_basetype.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __VSF_BASETYPE_H_INCLUDED__ 3 | #define __VSF_BASETYPE_H_INCLUDED__ 4 | 5 | // define the most efficient atom integer 6 | typedef int vsf_int_t; 7 | 8 | #endif // __VSF_BASETYPE_H_INCLUDED__ 9 | -------------------------------------------------------------------------------- /vsf/interfaces/cpu/stm32/adc/STM32_ADC.h: -------------------------------------------------------------------------------- 1 | vsf_err_t stm32_adc_init(uint8_t index); 2 | vsf_err_t stm32_adc_fini(uint8_t index); 3 | vsf_err_t stm32_adc_config(uint8_t index, uint32_t clock_hz, uint8_t mode); 4 | vsf_err_t stm32_adc_config_channel(uint8_t index, uint8_t channel, 5 | uint8_t cycles); 6 | vsf_err_t stm32_adc_calibrate(uint8_t index, uint8_t channel); 7 | uint32_t stm32_adc_get_max_value(uint8_t index); 8 | vsf_err_t stm32_adc_start(uint8_t index, uint8_t channel); 9 | vsf_err_t stm32_adc_isready(uint8_t index, uint8_t channel); 10 | uint32_t stm32_adc_get(uint8_t index, uint8_t channel); 11 | vsf_err_t stm32_adc_sample(uint8_t index, uint8_t channel, uint32_t *voltage); 12 | -------------------------------------------------------------------------------- /vsf/interfaces/cpu/stm32/clko/STM32_CLKO.h: -------------------------------------------------------------------------------- 1 | vsf_err_t stm32_clko_init(uint8_t index); 2 | vsf_err_t stm32_clko_fini(uint8_t index); 3 | vsf_err_t stm32_clko_config(uint8_t index, uint32_t kHz); 4 | vsf_err_t stm32_clko_enable(uint8_t index); 5 | vsf_err_t stm32_clko_disable(uint8_t index); 6 | -------------------------------------------------------------------------------- /vsf/interfaces/cpu/stm32/core.h: -------------------------------------------------------------------------------- 1 | #ifndef __STM32_CORE_H_INCLUDED__ 2 | #define __STM32_CORE_H_INCLUDED__ 3 | 4 | enum stm32_clksrc_t 5 | { 6 | STM32_CLKSRC_HSE = 1, 7 | STM32_CLKSRC_HSI = 0, 8 | STM32_CLKSRC_PLL = 2 9 | }; 10 | enum stm32_pllsrc_t 11 | { 12 | STM32_PLLSRC_HSE, 13 | STM32_PLLSRC_HSEd2, 14 | STM32_PLLSRC_HSId2 15 | }; 16 | enum stm32_rtcsrc_t 17 | { 18 | STM32_RTCSRC_HSEd128, 19 | STM32_RTCSRC_LSE, 20 | STM32_RTCSRC_LSI 21 | }; 22 | enum stm32_hse_type_t 23 | { 24 | STM32_HSE_TYPE_CLOCK, 25 | STM32_HSE_TYPE_CRYSTAL 26 | }; 27 | enum debug_setting_t 28 | { 29 | STM32_DBG_JTAG_SWD = 0, 30 | STM32_DBG_SWD = 2, 31 | STM32_DBG_NONE = 4 32 | }; 33 | struct stm32_info_t 34 | { 35 | enum stm32_clksrc_t clksrc; 36 | enum stm32_pllsrc_t pllsrc; 37 | enum stm32_rtcsrc_t rtcsrc; 38 | enum stm32_hse_type_t hse_type; 39 | 40 | uint32_t osc_freq_hz; 41 | uint32_t pll_freq_hz; 42 | uint32_t ahb_freq_hz; 43 | uint32_t apb1_freq_hz; 44 | uint32_t apb2_freq_hz; 45 | 46 | uint8_t flash_latency; 47 | uint32_t vector_table; 48 | enum debug_setting_t debug_setting; 49 | 50 | // calculated internally 51 | uint32_t sys_freq_hz; 52 | }; 53 | 54 | vsf_err_t stm32_interface_init(void *p); 55 | vsf_err_t stm32_interface_fini(void *p); 56 | vsf_err_t stm32_interface_reset(void *p); 57 | vsf_err_t stm32_interface_set_stack(uint32_t sp); 58 | vsf_err_t stm32_interface_get_info(struct stm32_info_t **info); 59 | 60 | uint32_t stm32_uid_get(uint8_t *buffer, uint32_t size); 61 | 62 | vsf_err_t stm32_delay_delayms(uint16_t ms); 63 | vsf_err_t stm32_delay_delayus(uint16_t us); 64 | 65 | vsf_err_t stm32_tickclk_init(void); 66 | vsf_err_t stm32_tickclk_fini(void); 67 | vsf_err_t stm32_tickclk_start(void); 68 | vsf_err_t stm32_tickclk_stop(void); 69 | uint32_t stm32_tickclk_get_count(void); 70 | 71 | #endif // __STM32_CORE_H_INCLUDED__ 72 | -------------------------------------------------------------------------------- /vsf/interfaces/cpu/stm32/ebi/STM32_EBI.h: -------------------------------------------------------------------------------- 1 | vsf_err_t stm32_ebi_init(uint8_t index); 2 | vsf_err_t stm32_ebi_fini(uint8_t index); 3 | vsf_err_t stm32_ebi_config_sram(uint8_t index, 4 | struct ebi_sram_psram_nor_info_t *info); 5 | vsf_err_t stm32_ebi_config_psram(uint8_t index, 6 | struct ebi_sram_psram_nor_info_t *info); 7 | vsf_err_t stm32_ebi_config_nor(uint8_t index, 8 | struct ebi_sram_psram_nor_info_t *info); 9 | vsf_err_t stm32_ebi_config_nand(uint8_t index, struct ebi_nand_info_t *info); 10 | vsf_err_t stm32_ebi_config_sdram(uint8_t index, struct ebi_sdram_info_t *info); 11 | vsf_err_t stm32_ebi_config_ddram(uint8_t index, struct ebi_ddram_info_t *info); 12 | vsf_err_t stm32_ebi_config_pccard(uint8_t index, struct ebi_pccard_info_t *info); 13 | 14 | void* stm32_ebi_get_base_addr(uint8_t index, uint8_t target_index); 15 | vsf_err_t stm32_ebi_isready(uint8_t index, uint8_t target_index); 16 | 17 | uint8_t stm32_ebi_read8(uint8_t index, uint32_t address); 18 | void stm32_ebi_write8(uint8_t index, uint32_t address, uint8_t data); 19 | uint16_t stm32_ebi_read16(uint8_t index, uint32_t address); 20 | void stm32_ebi_write16(uint8_t index, uint32_t address, uint16_t data); 21 | uint32_t stm32_ebi_read32(uint8_t index, uint32_t address); 22 | void stm32_ebi_write32(uint8_t index, uint32_t address, uint32_t data); 23 | 24 | vsf_err_t stm32_ebi_readp8(uint8_t index, uint32_t address, uint32_t count, 25 | uint8_t *buff); 26 | vsf_err_t stm32_ebi_readp8_isready(uint8_t index); 27 | vsf_err_t stm32_ebi_writep8(uint8_t index, uint32_t address, uint32_t count, 28 | uint8_t *buff); 29 | vsf_err_t stm32_ebi_writep8_isready(uint8_t index); 30 | vsf_err_t stm32_ebi_readp16(uint8_t index, uint32_t address, uint32_t count, 31 | uint16_t *buff); 32 | vsf_err_t stm32_ebi_readp16_isready(uint8_t index); 33 | vsf_err_t stm32_ebi_writep16(uint8_t index, uint32_t address, uint32_t count, 34 | uint16_t *buff); 35 | vsf_err_t stm32_ebi_writep16_isready(uint8_t index); 36 | vsf_err_t stm32_ebi_readp32(uint8_t index, uint32_t address, uint32_t count, 37 | uint32_t *buff); 38 | vsf_err_t stm32_ebi_readp32_isready(uint8_t index); 39 | vsf_err_t stm32_ebi_writep32(uint8_t index, uint32_t address, uint32_t count, 40 | uint32_t *buff); 41 | vsf_err_t stm32_ebi_writep32_isready(uint8_t index); 42 | -------------------------------------------------------------------------------- /vsf/interfaces/cpu/stm32/eint/STM32_EINT.h: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * Copyright (C) 2008 - 2010 by Simon Qian * 3 | * SimonQian@SimonQian.com * 4 | * * 5 | * Project: Versaloon * 6 | * File: GPIO.h * 7 | * Author: SimonQian * 8 | * Versaion: See changelog * 9 | * Purpose: GPIO interface header file * 10 | * License: See license * 11 | *------------------------------------------------------------------------* 12 | * Change Log: * 13 | * YYYY-MM-DD: What(by Who) * 14 | * 2008-11-07: created(by SimonQian) * 15 | **************************************************************************/ 16 | 17 | vsf_err_t stm32_eint_init(uint8_t index); 18 | vsf_err_t stm32_eint_fini(uint8_t index); 19 | vsf_err_t stm32_eint_config(uint8_t index, uint8_t type, 20 | void (*callback)(void)); 21 | vsf_err_t stm32_eint_enable(uint8_t index); 22 | vsf_err_t stm32_eint_disable(uint8_t index); 23 | vsf_err_t stm32_eint_trigger(uint8_t index); 24 | -------------------------------------------------------------------------------- /vsf/interfaces/cpu/stm32/flash/STM32_FLASH.h: -------------------------------------------------------------------------------- 1 | vsf_err_t stm32_flash_init(uint8_t index); 2 | vsf_err_t stm32_flash_fini(uint8_t index); 3 | 4 | vsf_err_t stm32_flash_lock(uint8_t index); 5 | vsf_err_t stm32_flash_unlock(uint8_t index); 6 | 7 | vsf_err_t stm32_flash_getcapacity(uint8_t index, uint32_t *pagesize, 8 | uint32_t *pagenum); 9 | 10 | vsf_err_t stm32_flash_read(uint8_t index, uint32_t offset, uint8_t *buff, 11 | uint32_t size); 12 | vsf_err_t stm32_flash_read_isready(uint8_t index, uint32_t offset, 13 | uint8_t *buff, uint32_t size); 14 | vsf_err_t stm32_flash_write(uint8_t index, uint32_t offset, uint8_t *buff, 15 | uint32_t size); 16 | vsf_err_t stm32_flash_write_isready(uint8_t index, uint32_t offset, 17 | uint8_t *buff, uint32_t size); 18 | 19 | vsf_err_t stm32_flash_readpage(uint8_t index, uint32_t offset, uint8_t *buff); 20 | vsf_err_t stm32_flash_readpage_isready(uint8_t index, uint32_t offset, 21 | uint8_t *buff); 22 | vsf_err_t stm32_flash_writepage(uint8_t index, uint32_t offset, uint8_t *buff); 23 | vsf_err_t stm32_flash_writepage_isready(uint8_t index, uint32_t offset, 24 | uint8_t *buff); 25 | vsf_err_t stm32_flash_erasepage(uint8_t index, uint32_t offset); 26 | vsf_err_t stm32_flash_erasepage_isready(uint8_t index, uint32_t offset); 27 | vsf_err_t stm32_flash_protect(uint8_t index); 28 | bool stm32_flash_isprotected(uint8_t index); 29 | -------------------------------------------------------------------------------- /vsf/interfaces/cpu/stm32/gpio/STM32_GPIO.h: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * Copyright (C) 2008 - 2010 by Simon Qian * 3 | * SimonQian@SimonQian.com * 4 | * * 5 | * Project: Versaloon * 6 | * File: GPIO.h * 7 | * Author: SimonQian * 8 | * Versaion: See changelog * 9 | * Purpose: GPIO interface header file * 10 | * License: See license * 11 | *------------------------------------------------------------------------* 12 | * Change Log: * 13 | * YYYY-MM-DD: What(by Who) * 14 | * 2008-11-07: created(by SimonQian) * 15 | **************************************************************************/ 16 | 17 | vsf_err_t stm32_gpio_init(uint8_t index); 18 | vsf_err_t stm32_gpio_fini(uint8_t index); 19 | vsf_err_t stm32_gpio_config_pin(uint8_t index, uint8_t pin_idx, uint8_t mode); 20 | vsf_err_t stm32_gpio_config(uint8_t index, uint32_t pin_mask, uint32_t io, 21 | uint32_t pull_en_mask, uint32_t input_pull_mask); 22 | vsf_err_t stm32_gpio_set(uint8_t index, uint32_t pin_mask); 23 | vsf_err_t stm32_gpio_clear(uint8_t index, uint32_t pin_mask); 24 | vsf_err_t stm32_gpio_out(uint8_t index, uint32_t pin_mask, uint32_t value); 25 | vsf_err_t stm32_gpio_in(uint8_t index, uint32_t pin_mask, uint32_t *value); 26 | uint32_t stm32_gpio_get(uint8_t index, uint32_t pin_mask); 27 | -------------------------------------------------------------------------------- /vsf/interfaces/cpu/stm32/hw/STM32F10x_Lib/Libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x/system_stm32f10x.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file system_stm32f10x.h 4 | * @author MCD Application Team 5 | * @version V3.3.0 6 | * @date 04/16/2010 7 | * @brief CMSIS Cortex-M3 Device Peripheral Access Layer System Header File. 8 | ****************************************************************************** 9 | * 10 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 11 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 12 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 13 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 14 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 15 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 16 | * 17 | *

© COPYRIGHT 2010 STMicroelectronics

18 | ****************************************************************************** 19 | */ 20 | 21 | /** @addtogroup CMSIS 22 | * @{ 23 | */ 24 | 25 | /** @addtogroup stm32f10x_system 26 | * @{ 27 | */ 28 | 29 | /** 30 | * @brief Define to prevent recursive inclusion 31 | */ 32 | #ifndef __SYSTEM_STM32F10X_H 33 | #define __SYSTEM_STM32F10X_H 34 | 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | /** @addtogroup STM32F10x_System_Includes 40 | * @{ 41 | */ 42 | 43 | /** 44 | * @} 45 | */ 46 | 47 | 48 | /** @addtogroup STM32F10x_System_Exported_types 49 | * @{ 50 | */ 51 | 52 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ 53 | 54 | /** 55 | * @} 56 | */ 57 | 58 | /** @addtogroup STM32F10x_System_Exported_Constants 59 | * @{ 60 | */ 61 | 62 | /** 63 | * @} 64 | */ 65 | 66 | /** @addtogroup STM32F10x_System_Exported_Macros 67 | * @{ 68 | */ 69 | 70 | /** 71 | * @} 72 | */ 73 | 74 | /** @addtogroup STM32F10x_System_Exported_Functions 75 | * @{ 76 | */ 77 | 78 | extern void SystemInit(void); 79 | extern void SystemCoreClockUpdate(void); 80 | /** 81 | * @} 82 | */ 83 | 84 | #ifdef __cplusplus 85 | } 86 | #endif 87 | 88 | #endif /*__SYSTEM_STM32F10X_H */ 89 | 90 | /** 91 | * @} 92 | */ 93 | 94 | /** 95 | * @} 96 | */ 97 | /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/ 98 | -------------------------------------------------------------------------------- /vsf/interfaces/cpu/stm32/hw/STM32F10x_Lib/Libraries/CMSIS/CMSIS debug support.htm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zoobab/versaloon/456dcbde55e58725b4aa6e4fed4d35ad1f829b5a/vsf/interfaces/cpu/stm32/hw/STM32F10x_Lib/Libraries/CMSIS/CMSIS debug support.htm -------------------------------------------------------------------------------- /vsf/interfaces/cpu/stm32/hw/STM32F10x_Lib/Libraries/CMSIS/Documentation/CMSIS_Core.htm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zoobab/versaloon/456dcbde55e58725b4aa6e4fed4d35ad1f829b5a/vsf/interfaces/cpu/stm32/hw/STM32F10x_Lib/Libraries/CMSIS/Documentation/CMSIS_Core.htm -------------------------------------------------------------------------------- /vsf/interfaces/cpu/stm32/hw/STM32F10x_Lib/Libraries/CMSIS/License.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zoobab/versaloon/456dcbde55e58725b4aa6e4fed4d35ad1f829b5a/vsf/interfaces/cpu/stm32/hw/STM32F10x_Lib/Libraries/CMSIS/License.doc -------------------------------------------------------------------------------- /vsf/interfaces/cpu/stm32/hw/STM32F10x_Lib/Libraries/STM32F10x_StdPeriph_Driver/inc/stm32f10x_crc.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_crc.h 4 | * @author MCD Application Team 5 | * @version V3.3.0 6 | * @date 04/16/2010 7 | * @brief This file contains all the functions prototypes for the CRC firmware 8 | * library. 9 | ****************************************************************************** 10 | * @copy 11 | * 12 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 13 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 14 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 15 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 16 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 17 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 18 | * 19 | *

© COPYRIGHT 2010 STMicroelectronics

20 | */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __STM32F10x_CRC_H 24 | #define __STM32F10x_CRC_H 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | /* Includes ------------------------------------------------------------------*/ 31 | #include "stm32f10x.h" 32 | 33 | /** @addtogroup STM32F10x_StdPeriph_Driver 34 | * @{ 35 | */ 36 | 37 | /** @addtogroup CRC 38 | * @{ 39 | */ 40 | 41 | /** @defgroup CRC_Exported_Types 42 | * @{ 43 | */ 44 | 45 | /** 46 | * @} 47 | */ 48 | 49 | /** @defgroup CRC_Exported_Constants 50 | * @{ 51 | */ 52 | 53 | /** 54 | * @} 55 | */ 56 | 57 | /** @defgroup CRC_Exported_Macros 58 | * @{ 59 | */ 60 | 61 | /** 62 | * @} 63 | */ 64 | 65 | /** @defgroup CRC_Exported_Functions 66 | * @{ 67 | */ 68 | 69 | void CRC_ResetDR(void); 70 | uint32_t CRC_CalcCRC(uint32_t Data); 71 | uint32_t CRC_CalcBlockCRC(uint32_t pBuffer[], uint32_t BufferLength); 72 | uint32_t CRC_GetCRC(void); 73 | void CRC_SetIDRegister(uint8_t IDValue); 74 | uint8_t CRC_GetIDRegister(void); 75 | 76 | #ifdef __cplusplus 77 | } 78 | #endif 79 | 80 | #endif /* __STM32F10x_CRC_H */ 81 | /** 82 | * @} 83 | */ 84 | 85 | /** 86 | * @} 87 | */ 88 | 89 | /** 90 | * @} 91 | */ 92 | 93 | /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/ 94 | -------------------------------------------------------------------------------- /vsf/interfaces/cpu/stm32/hw/STM32F10x_Lib/Libraries/STM32F10x_StdPeriph_Driver/inc/stm32f10x_fsmc.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zoobab/versaloon/456dcbde55e58725b4aa6e4fed4d35ad1f829b5a/vsf/interfaces/cpu/stm32/hw/STM32F10x_Lib/Libraries/STM32F10x_StdPeriph_Driver/inc/stm32f10x_fsmc.h -------------------------------------------------------------------------------- /vsf/interfaces/cpu/stm32/hw/STM32F10x_Lib/Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_adc.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zoobab/versaloon/456dcbde55e58725b4aa6e4fed4d35ad1f829b5a/vsf/interfaces/cpu/stm32/hw/STM32F10x_Lib/Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_adc.c -------------------------------------------------------------------------------- /vsf/interfaces/cpu/stm32/hw/STM32F10x_Lib/Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_can.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zoobab/versaloon/456dcbde55e58725b4aa6e4fed4d35ad1f829b5a/vsf/interfaces/cpu/stm32/hw/STM32F10x_Lib/Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_can.c -------------------------------------------------------------------------------- /vsf/interfaces/cpu/stm32/hw/STM32F10x_Lib/Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_dac.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zoobab/versaloon/456dcbde55e58725b4aa6e4fed4d35ad1f829b5a/vsf/interfaces/cpu/stm32/hw/STM32F10x_Lib/Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_dac.c -------------------------------------------------------------------------------- /vsf/interfaces/cpu/stm32/hw/STM32F10x_Lib/Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_dma.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zoobab/versaloon/456dcbde55e58725b4aa6e4fed4d35ad1f829b5a/vsf/interfaces/cpu/stm32/hw/STM32F10x_Lib/Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_dma.c -------------------------------------------------------------------------------- /vsf/interfaces/cpu/stm32/hw/STM32F10x_Lib/Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_exti.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zoobab/versaloon/456dcbde55e58725b4aa6e4fed4d35ad1f829b5a/vsf/interfaces/cpu/stm32/hw/STM32F10x_Lib/Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_exti.c -------------------------------------------------------------------------------- /vsf/interfaces/cpu/stm32/hw/STM32F10x_Lib/Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_flash.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zoobab/versaloon/456dcbde55e58725b4aa6e4fed4d35ad1f829b5a/vsf/interfaces/cpu/stm32/hw/STM32F10x_Lib/Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_flash.c -------------------------------------------------------------------------------- /vsf/interfaces/cpu/stm32/hw/STM32F10x_Lib/Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_fsmc.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zoobab/versaloon/456dcbde55e58725b4aa6e4fed4d35ad1f829b5a/vsf/interfaces/cpu/stm32/hw/STM32F10x_Lib/Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_fsmc.c -------------------------------------------------------------------------------- /vsf/interfaces/cpu/stm32/hw/STM32F10x_Lib/Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_i2c.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zoobab/versaloon/456dcbde55e58725b4aa6e4fed4d35ad1f829b5a/vsf/interfaces/cpu/stm32/hw/STM32F10x_Lib/Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_i2c.c -------------------------------------------------------------------------------- /vsf/interfaces/cpu/stm32/hw/STM32F10x_Lib/Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_rcc.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zoobab/versaloon/456dcbde55e58725b4aa6e4fed4d35ad1f829b5a/vsf/interfaces/cpu/stm32/hw/STM32F10x_Lib/Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_rcc.c -------------------------------------------------------------------------------- /vsf/interfaces/cpu/stm32/hw/STM32F10x_Lib/Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_rtc.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zoobab/versaloon/456dcbde55e58725b4aa6e4fed4d35ad1f829b5a/vsf/interfaces/cpu/stm32/hw/STM32F10x_Lib/Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_rtc.c -------------------------------------------------------------------------------- /vsf/interfaces/cpu/stm32/hw/STM32F10x_Lib/Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_sdio.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zoobab/versaloon/456dcbde55e58725b4aa6e4fed4d35ad1f829b5a/vsf/interfaces/cpu/stm32/hw/STM32F10x_Lib/Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_sdio.c -------------------------------------------------------------------------------- /vsf/interfaces/cpu/stm32/hw/STM32F10x_Lib/Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_tim.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zoobab/versaloon/456dcbde55e58725b4aa6e4fed4d35ad1f829b5a/vsf/interfaces/cpu/stm32/hw/STM32F10x_Lib/Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_tim.c -------------------------------------------------------------------------------- /vsf/interfaces/cpu/stm32/hw/STM32F10x_Lib/Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_usart.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zoobab/versaloon/456dcbde55e58725b4aa6e4fed4d35ad1f829b5a/vsf/interfaces/cpu/stm32/hw/STM32F10x_Lib/Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_usart.c -------------------------------------------------------------------------------- /vsf/interfaces/cpu/stm32/hw/STM32F10x_Lib/Libraries/STM32_USB-FS-Device_Driver/inc/usb_mem.h: -------------------------------------------------------------------------------- 1 | /******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** 2 | * File Name : usb_mem.h 3 | * Author : MCD Application Team 4 | * Version : V3.2.1 5 | * Date : 07/05/2010 6 | * Description : Utility prototypes functions for memory/PMA transfers 7 | ******************************************************************************** 8 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 9 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. 10 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, 11 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE 12 | * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING 13 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 14 | *******************************************************************************/ 15 | 16 | /* Define to prevent recursive inclusion -------------------------------------*/ 17 | #ifndef __USB_MEM_H 18 | #define __USB_MEM_H 19 | 20 | /* Includes ------------------------------------------------------------------*/ 21 | /* Exported types ------------------------------------------------------------*/ 22 | /* Exported constants --------------------------------------------------------*/ 23 | /* Exported macro ------------------------------------------------------------*/ 24 | /* Exported functions ------------------------------------------------------- */ 25 | void UserToPMABufferCopy(uint8_t *pbUsrBuf, uint16_t wPMABufAddr, uint16_t wNBytes); 26 | void PMAToUserBufferCopy(uint8_t *pbUsrBuf, uint16_t wPMABufAddr, uint16_t wNBytes); 27 | 28 | /* External variables --------------------------------------------------------*/ 29 | 30 | #endif /*__USB_MEM_H*/ 31 | 32 | /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/ 33 | -------------------------------------------------------------------------------- /vsf/interfaces/cpu/stm32/hw/stm32f10x_conf.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file Project/Template/stm32f10x_conf.h 4 | * @author MCD Application Team 5 | * @version V3.1.2 6 | * @date 09/28/2009 7 | * @brief Library configuration file. 8 | ****************************************************************************** 9 | * @copy 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2009 STMicroelectronics

19 | */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __STM32F10x_CONF_H 23 | #define __STM32F10x_CONF_H 24 | 25 | /* Includes ------------------------------------------------------------------*/ 26 | /* Uncomment the line below to enable peripheral header file inclusion */ 27 | #include "stm32f10x_adc.h" 28 | #include "stm32f10x_bkp.h" 29 | /* #include "stm32f10x_can.h" */ 30 | /* #include "stm32f10x_crc.h" */ 31 | /* #include "stm32f10x_dac.h" */ 32 | /* #include "stm32f10x_dbgmcu.h" */ 33 | #include "stm32f10x_dma.h" 34 | /* #include "stm32f10x_exti.h" */ 35 | #include "stm32f10x_flash.h" 36 | /* #include "stm32f10x_fsmc.h" */ 37 | #include "stm32f10x_gpio.h" 38 | /* #include "stm32f10x_i2c.h" */ 39 | /* #include "stm32f10x_iwdg.h" */ 40 | #include "stm32f10x_pwr.h" 41 | #include "stm32f10x_rcc.h" 42 | /* #include "stm32f10x_rtc.h" */ 43 | /* #include "stm32f10x_sdio.h" */ 44 | #include "stm32f10x_spi.h" 45 | #include "stm32f10x_tim.h" 46 | #include "stm32f10x_usart.h" 47 | /* #include "stm32f10x_wwdg.h" */ 48 | #include "misc.h" /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */ 49 | 50 | /* Exported types ------------------------------------------------------------*/ 51 | /* Exported constants --------------------------------------------------------*/ 52 | /* Uncomment the line below to expanse the "assert_param" macro in the 53 | Standard Peripheral Library drivers code */ 54 | /* #define USE_FULL_ASSERT 1 */ 55 | 56 | /* Exported macro ------------------------------------------------------------*/ 57 | #ifdef USE_FULL_ASSERT 58 | 59 | /** 60 | * @brief The assert_param macro is used for function's parameters check. 61 | * @param expr: If expr is false, it calls assert_failed function 62 | * which reports the name of the source file and the source 63 | * line number of the call that failed. 64 | * If expr is true, it returns no value. 65 | * @retval None 66 | */ 67 | #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__)) 68 | /* Exported functions ------------------------------------------------------- */ 69 | void assert_failed(uint8_t* file, uint32_t line); 70 | #else 71 | #define assert_param(expr) ((void)0) 72 | #endif /* USE_FULL_ASSERT */ 73 | 74 | #endif /* __STM32F10x_CONF_H */ 75 | 76 | /******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/ 77 | -------------------------------------------------------------------------------- /vsf/interfaces/cpu/stm32/interfaces_const.h: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * Copyright (C) 2008 - 2010 by Simon Qian * 3 | * SimonQian@SimonQian.com * 4 | * * 5 | * Project: Versaloon * 6 | * File: interfaces_const.h * 7 | * Author: SimonQian * 8 | * Versaion: See changelog * 9 | * Purpose: consts of interface module * 10 | * License: See license * 11 | *------------------------------------------------------------------------* 12 | * Change Log: * 13 | * YYYY-MM-DD: What(by Who) * 14 | * 2011-04-08: created(by SimonQian) * 15 | **************************************************************************/ 16 | #ifndef __STM32_INTERFACE_CONST_H_INCLUDED__ 17 | #define __STM32_INTERFACE_CONST_H_INCLUDED__ 18 | 19 | #include "stm32f10x_adc.h" 20 | #include "stm32f10x_can.h" 21 | #include "stm32f10x_dac.h" 22 | #include "stm32f10x_exti.h" 23 | #include "stm32f10x_flash.h" 24 | #include "stm32f10x_gpio.h" 25 | #include "stm32f10x_i2c.h" 26 | #include "stm32f10x_sdio.h" 27 | #include "stm32f10x_spi.h" 28 | #include "stm32f10x_tim.h" 29 | #include "stm32f10x_usart.h" 30 | #include "core.h" 31 | 32 | #define stm32_USART_MODE0 0x00 33 | #define stm32_USART_MODE1 0x04 34 | #define stm32_USART_MODE2 0x08 35 | #define stm32_USART_MODE3 0x0C 36 | #define stm32_USART_CLKEN 0x80 37 | #define stm32_USART_STOPBITS_0P5 0x20 38 | #define stm32_USART_STOPBITS_1 0x00 39 | #define stm32_USART_STOPBITS_1P5 0x60 40 | #define stm32_USART_STOPBITS_2 0x40 41 | #define stm32_USART_PARITY_NONE 0x00 42 | #define stm32_USART_PARITY_ODD 0x03 43 | #define stm32_USART_PARITY_EVEN 0x02 44 | 45 | #define stm32_SPI_MASTER 0x04 46 | #define stm32_SPI_SLAVE 0x00 47 | #define stm32_SPI_MODE0 0 48 | #define stm32_SPI_MODE1 1 49 | #define stm32_SPI_MODE2 2 50 | #define stm32_SPI_MODE3 3 51 | #define stm32_SPI_MSB_FIRST 0x00 52 | #define stm32_SPI_LSB_FIRST 0x80 53 | 54 | #define stm32_ADC_ALIGNLEFT 0x08 55 | #define stm32_ADC_ALIGNRIGHT 0x00 56 | 57 | #define stm32_GPIO_INFLOAT 0x04 58 | #define stm32_GPIO_INPU 0x88 59 | #define stm32_GPIO_INPD 0x08 60 | #define stm32_GPIO_INP 0x08 61 | #define stm32_GPIO_OUTPP 0x01 62 | #define stm32_GPIO_OUTOD 0x05 63 | #define stm32_GPIO_ANALOG 0x00 64 | #define stm32_GPIO_AFOD 0x0F 65 | #define stm32_GPIO_AFPP 0x0B 66 | 67 | #define stm32_EINT_ONFALL 0x01 68 | #define stm32_EINT_ONRISE 0x02 69 | #define stm32_EINT_INT 0x04 70 | #define stm32_EINT_EVT 0x08 71 | 72 | #define stm32_SDIO_RESP_NONE 0x00 73 | #define stm32_SDIO_RESP_SHORT 0x40 74 | #define stm32_SDIO_RESP_LONG 0xC0 75 | 76 | #endif // __STM32_INTERFACE_CONST_H_INCLUDED__ 77 | -------------------------------------------------------------------------------- /vsf/interfaces/cpu/stm32/sdio/STM32_SDIO.h: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * Copyright (C) 2008 - 2010 by Simon Qian * 3 | * SimonQian@SimonQian.com * 4 | * * 5 | * Project: Versaloon * 6 | * File: GPIO.h * 7 | * Author: SimonQian * 8 | * Versaion: See changelog * 9 | * Purpose: GPIO interface header file * 10 | * License: See license * 11 | *------------------------------------------------------------------------* 12 | * Change Log: * 13 | * YYYY-MM-DD: What(by Who) * 14 | * 2012-01-23: created(by SimonQian) * 15 | **************************************************************************/ 16 | 17 | vsf_err_t stm32_sdio_init(uint8_t index); 18 | vsf_err_t stm32_sdio_config(uint8_t index, uint16_t kHz, uint8_t buswide); 19 | vsf_err_t stm32_sdio_fini(uint8_t index); 20 | vsf_err_t stm32_sdio_start(uint8_t index); 21 | vsf_err_t stm32_sdio_stop(uint8_t index); 22 | vsf_err_t stm32_sdio_send_cmd(uint8_t index, uint8_t cmd, uint32_t arg, 23 | uint8_t resp); 24 | vsf_err_t stm32_sdio_send_cmd_isready(uint8_t index, uint8_t resp); 25 | vsf_err_t stm32_sdio_get_resp(uint8_t index, uint8_t *cresp, uint32_t *resp, 26 | uint8_t resp_num); 27 | vsf_err_t stm32_sdio_data_tx(uint8_t index, uint32_t to_ms, 28 | uint32_t size, uint32_t block_size); 29 | vsf_err_t stm32_sdio_data_tx_isready(uint8_t index, uint32_t size, 30 | uint8_t *buffer); 31 | vsf_err_t stm32_sdio_data_rx(uint8_t index, uint32_t to_ms, 32 | uint32_t size, uint32_t block_size); 33 | vsf_err_t stm32_sdio_data_rx_isready(uint8_t index, uint32_t size, 34 | uint8_t *buffer); 35 | -------------------------------------------------------------------------------- /vsf/interfaces/cpu/stm32/spi/STM32_SPI.h: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * Copyright (C) 2008 - 2010 by Simon Qian * 3 | * SimonQian@SimonQian.com * 4 | * * 5 | * Project: Versaloon * 6 | * File: GPIO.h * 7 | * Author: SimonQian * 8 | * Versaion: See changelog * 9 | * Purpose: GPIO interface header file * 10 | * License: See license * 11 | *------------------------------------------------------------------------* 12 | * Change Log: * 13 | * YYYY-MM-DD: What(by Who) * 14 | * 2008-11-07: created(by SimonQian) * 15 | **************************************************************************/ 16 | 17 | vsf_err_t stm32_spi_init(uint8_t index); 18 | vsf_err_t stm32_spi_fini(uint8_t index); 19 | vsf_err_t stm32_spi_get_ability(uint8_t index, struct spi_ability_t *ability); 20 | vsf_err_t stm32_spi_enable(uint8_t index); 21 | vsf_err_t stm32_spi_disable(uint8_t index); 22 | vsf_err_t stm32_spi_config(uint8_t index, uint32_t kHz, uint8_t mode); 23 | vsf_err_t stm32_spi_select(uint8_t index, uint8_t cs); 24 | vsf_err_t stm32_spi_deselect(uint8_t index, uint8_t cs); 25 | vsf_err_t stm32_spi_io_tx(uint8_t index, uint8_t out); 26 | vsf_err_t stm32_spi_io_tx_isready(uint8_t index); 27 | vsf_err_t stm32_spi_io_rx_isready(uint8_t index); 28 | uint8_t stm32_spi_io_rx(uint8_t index); 29 | vsf_err_t stm32_spi_io(uint8_t index, uint8_t *out, uint8_t *in, uint32_t len); 30 | vsf_err_t stm32_spi_io_dma_start(uint8_t index, uint8_t *out, uint8_t *in, 31 | uint32_t len); 32 | vsf_err_t stm32_spi_io_dma_isready(uint8_t index); 33 | vsf_err_t stm32_spi_io_dma_end(uint8_t index); 34 | -------------------------------------------------------------------------------- /vsf/interfaces/cpu/stm32/timer/STM32_TIM.h: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * Copyright (C) 2008 - 2010 by Simon Qian * 3 | * SimonQian@SimonQian.com * 4 | * * 5 | * Project: Versaloon * 6 | * File: GPIO.h * 7 | * Author: SimonQian * 8 | * Versaion: See changelog * 9 | * Purpose: GPIO interface header file * 10 | * License: See license * 11 | *------------------------------------------------------------------------* 12 | * Change Log: * 13 | * YYYY-MM-DD: What(by Who) * 14 | * 2008-11-07: created(by SimonQian) * 15 | **************************************************************************/ 16 | 17 | vsf_err_t stm32_timer_init(uint8_t index); 18 | vsf_err_t stm32_timer_fini(uint8_t index); 19 | vsf_err_t stm32_timer_config(uint8_t index, uint32_t kHz, uint32_t mode, 20 | void (*overflow)(void)); 21 | vsf_err_t stm32_timer_start(uint8_t index); 22 | vsf_err_t stm32_timer_stop(uint8_t index); 23 | vsf_err_t stm32_timer_get_count(uint8_t index, uint32_t *count); 24 | vsf_err_t stm32_timer_set_count(uint8_t index, uint32_t count); 25 | vsf_err_t stm32_timer_config_channel(uint8_t index, uint8_t channel, 26 | uint32_t mode, void (*callback)(void)); 27 | vsf_err_t stm32_timer_get_channel(uint8_t index, uint8_t channel, 28 | uint32_t *count); 29 | vsf_err_t stm32_timer_set_channel(uint8_t index, uint8_t channel, 30 | uint32_t count); 31 | -------------------------------------------------------------------------------- /vsf/interfaces/cpu/stm32/usart/STM32_USART.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 - 2010 by Simon Qian * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 18 | ***************************************************************************/ 19 | 20 | vsf_err_t stm32_usart_init(uint8_t index); 21 | vsf_err_t stm32_usart_fini(uint8_t index); 22 | vsf_err_t stm32_usart_config(uint8_t index, uint32_t baudrate, 23 | uint8_t datalength, uint8_t mode); 24 | vsf_err_t stm32_usart_config_callback(uint8_t index, void *p, 25 | void (*ontx)(void *), void (*onrx)(void *, uint16_t)); 26 | vsf_err_t stm32_usart_tx(uint8_t index, uint16_t data); 27 | vsf_err_t stm32_usart_tx_isready(uint8_t index); 28 | uint16_t stm32_usart_rx(uint8_t index); 29 | vsf_err_t stm32_usart_rx_isready(uint8_t index); 30 | -------------------------------------------------------------------------------- /vsf/interfaces/cpu/stm32/vsf_basetype.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __VSF_BASETYPE_H_INCLUDED__ 3 | #define __VSF_BASETYPE_H_INCLUDED__ 4 | 5 | // define the most efficient atom integer 6 | typedef int vsf_int_t; 7 | 8 | #endif // __VSF_BASETYPE_H_INCLUDED__ 9 | -------------------------------------------------------------------------------- /vsf/stack/usb_device/class/CDC/vsfusbd_CDC.h: -------------------------------------------------------------------------------- 1 | #ifndef __VSFUSBD_CDC_H_INCLUDED__ 2 | #define __VSFUSBD_CDC_H_INCLUDED__ 3 | 4 | #include "tool/buffer/buffer.h" 5 | #include "dal/stream/stream.h" 6 | 7 | enum usb_CDC_req_t 8 | { 9 | USB_CDCREQ_SEND_ENCAPSULATED_COMMAND = 0x00, 10 | USB_CDCREQ_GET_ENCAPSULATED_RESPONSE = 0x01, 11 | USB_CDCREQ_SET_COMM_FEATURE = 0x02, 12 | USB_CDCREQ_GET_COMM_FEATURE = 0x03, 13 | USB_CDCREQ_CLEAR_COMM_FEATURE = 0x04, 14 | }; 15 | 16 | extern const struct vsfusbd_class_protocol_t vsfusbd_CDCControl_class; 17 | extern const struct vsfusbd_class_protocol_t vsfusbd_CDCData_class; 18 | 19 | struct vsfusbd_CDC_param_t 20 | { 21 | uint8_t ep_out; 22 | uint8_t ep_in; 23 | 24 | struct vsf_stream_t *stream_tx; 25 | struct vsf_stream_t *stream_rx; 26 | 27 | struct 28 | { 29 | vsf_err_t (*send_encapsulated_command)(struct vsf_buffer_t *buffer); 30 | } callback; 31 | 32 | // no need to initialize below if encapsulate command/response is not used 33 | struct vsf_buffer_t encapsulated_command_buffer; 34 | struct vsf_buffer_t encapsulated_response_buffer; 35 | 36 | // no need to initialize below by user 37 | volatile bool out_enable; 38 | }; 39 | 40 | // helper functions 41 | struct vsfusbd_setup_filter_t *vsfusbd_get_request_filter_do( 42 | struct vsfusbd_device_t *device, struct vsfusbd_setup_filter_t *list); 43 | 44 | #endif // __VSFUSBD_CDC_H_INCLUDED__ 45 | -------------------------------------------------------------------------------- /vsf/stack/usb_device/class/CDC/vsfusbd_CDCACM.h: -------------------------------------------------------------------------------- 1 | #ifndef __VSFUSBD_CDCACM_H_INCLUDED__ 2 | #define __VSFUSBD_CDCACM_H_INCLUDED__ 3 | 4 | #include "vsfusbd_CDC.h" 5 | 6 | struct vsfusbd_CDCACM_line_coding_t 7 | { 8 | uint32_t bitrate; 9 | uint8_t stopbittype; 10 | uint8_t paritytype; 11 | uint8_t datatype; 12 | }; 13 | 14 | #define USBCDCACM_CONTROLLINE_RTS 0x02 15 | #define USBCDCACM_CONTROLLINE_DTR 0x01 16 | #define USBCDCACM_CONTROLLINE_MASK 0x03 17 | 18 | enum usb_CDCACM_req_t 19 | { 20 | USB_CDCACMREQ_SET_LINE_CODING = 0x20, 21 | USB_CDCACMREQ_GET_LINE_CODING = 0x21, 22 | USB_CDCACMREQ_SET_CONTROL_LINE_STATE = 0x22, 23 | USB_CDCACMREQ_SEND_BREAK = 0x23, 24 | }; 25 | 26 | extern const struct vsfusbd_class_protocol_t vsfusbd_CDCACMControl_class; 27 | extern const struct vsfusbd_class_protocol_t vsfusbd_CDCACMData_class; 28 | 29 | struct vsfusbd_CDCACM_param_t 30 | { 31 | struct vsfusbd_CDC_param_t CDC_param; 32 | 33 | struct 34 | { 35 | vsf_err_t (*set_line_coding)(struct vsfusbd_CDCACM_line_coding_t *line_coding); 36 | vsf_err_t (*set_control_line)(uint8_t control_line); 37 | vsf_err_t (*get_control_line)(uint8_t *control_line); 38 | vsf_err_t (*send_break)(void); 39 | } callback; 40 | 41 | struct vsfusbd_CDCACM_line_coding_t line_coding; 42 | 43 | // no need to initialize below by user 44 | uint8_t control_line; 45 | uint8_t line_coding_buffer[7]; 46 | }; 47 | 48 | #endif // __VSFUSBD_CDCACM_H_INCLUDED__ 49 | -------------------------------------------------------------------------------- /vsf/stack/usb_device/class/HID/vsfusbd_HID.h: -------------------------------------------------------------------------------- 1 | #ifndef __VSFUSBD_HID_H_INCLUDED__ 2 | #define __VSFUSBD_HID_H_INCLUDED__ 3 | 4 | enum usb_HID_description_type_t 5 | { 6 | USB_HIDDESC_TYPE_HID = 0x21, 7 | USB_HIDDESC_TYPE_REPORT = 0x22, 8 | USB_HIDDESC_TYPE_PHYSICAL = 0x23, 9 | }; 10 | 11 | enum usb_HID_req_t 12 | { 13 | USB_HIDREQ_GET_REPORT = 0x01, 14 | USB_HIDREQ_GET_IDLE = 0x02, 15 | USB_HIDREQ_GET_PROTOCOL = 0x03, 16 | USB_HIDREQ_SET_REPORT = 0x09, 17 | USB_HIDREQ_SET_IDLE = 0x0A, 18 | USB_HIDREQ_SET_PROTOCOL = 0x0B, 19 | }; 20 | 21 | #define USB_HID_REPORT_TYPE_INPUT 1 22 | #define USB_HID_REPORT_TYPE_OUTPUT 2 23 | #define USB_HID_REPORT_TYPE_FEATURE 3 24 | 25 | #define USB_HID_PROTOCOL_BOOT 0 26 | #define USB_HID_PROTOCOL_REPORT 1 27 | 28 | extern const struct vsfusbd_class_protocol_t vsfusbd_HID_class; 29 | 30 | enum usb_HID_report_type_t 31 | { 32 | USB_HID_REPORT_OUTPUT, 33 | USB_HID_REPORT_INPUT, 34 | USB_HID_REPORT_FEATURE, 35 | }; 36 | 37 | struct vsfusbd_HID_report_t 38 | { 39 | enum usb_HID_report_type_t type; 40 | uint8_t id; 41 | uint8_t idle; 42 | struct vsf_buffer_t buffer; 43 | vsf_err_t (*on_set_get_report)(struct vsfusbd_HID_report_t *report); 44 | // no need to initialize below by user 45 | bool lock; 46 | uint32_t pos; 47 | uint8_t idle_cnt; 48 | }; 49 | 50 | #define VSFUSBD_DESC_HID_REPORT(ptr, size, func) \ 51 | {USB_HIDDESC_TYPE_REPORT, 0, 0, {(uint8_t*)(ptr), (size)}, (func)} 52 | 53 | enum vsfusbd_HID_output_state_t 54 | { 55 | HID_OUTPUT_STATE_WAIT, 56 | HID_OUTPUT_STATE_RECEIVING, 57 | }; 58 | 59 | struct vsfusbd_HID_param_t 60 | { 61 | uint8_t ep_out; 62 | uint8_t ep_in; 63 | 64 | struct vsfusbd_desc_filter_t *desc; 65 | 66 | uint8_t num_of_report; 67 | struct vsfusbd_HID_report_t *reports; 68 | 69 | struct vsf_buffer_t temp_buffer; 70 | // no need to initialize below by user 71 | uint8_t protocol; 72 | enum vsfusbd_HID_output_state_t output_state; 73 | uint8_t num_of_INPUT_report; 74 | uint8_t num_of_OUTPUT_report; 75 | uint8_t num_of_FEATURE_report; 76 | uint8_t current_output_report_id; 77 | uint8_t poll_report_idx; 78 | }; 79 | 80 | #endif // __VSFUSBD_HID_H_INCLUDED__ 81 | -------------------------------------------------------------------------------- /vsf/stack/usb_device/class/MSC/vsfusbd_MSC_BOT.h: -------------------------------------------------------------------------------- 1 | #ifndef __VSFUSBD_MSCBOT_H_INCLUDED__ 2 | #define __VSFUSBD_MSCBOT_H_INCLUDED__ 3 | 4 | #include "SCSI.h" 5 | 6 | #define USBMSC_CBW_SIGNATURE 0x43425355 7 | #define USBMSC_CSW_SIGNATURE 0x53425355 8 | 9 | #define USBMSC_CBWFLAGS_DIR_OUT 0x00 10 | #define USBMSC_CBWFLAGS_DIR_IN 0x80 11 | #define USBMSC_CBWFLAGS_DIR_MASK 0x80 12 | 13 | #define USBMSC_CBW_SIZE 31 14 | PACKED_HEAD struct PACKED_MID USBMSC_CBW_t 15 | { 16 | uint32_t dCBWSignature; 17 | uint32_t dCBWTag; 18 | uint32_t dCBWDataTransferLength; 19 | uint8_t bmCBWFlags; 20 | uint8_t bCBWLUN; 21 | uint8_t bCBWCBLength; 22 | uint8_t CBWCB[16]; 23 | }; PACKED_TAIL 24 | 25 | #define USBMSC_CSW_SIZE 13 26 | PACKED_HEAD struct PACKED_MID USBMSC_CSW_t 27 | { 28 | uint32_t dCSWSignature; 29 | uint32_t dCSWTag; 30 | uint32_t dCSWDataResidue; 31 | uint8_t dCSWStatus; 32 | }; PACKED_TAIL 33 | 34 | enum usb_MSCBOT_req_t 35 | { 36 | USB_MSCBOTREQ_GET_MAX_LUN = 0xFE, 37 | USB_MSCBOTREQ_RESET = 0xFF, 38 | }; 39 | 40 | #define USBMSC_CSW_OK 0x00 41 | #define USBMSC_CSW_FAIL 0x01 42 | #define USBMSC_CSW_PHASE_ERROR 0x02 43 | 44 | extern const struct vsfusbd_class_protocol_t vsfusbd_MSCBOT_class; 45 | 46 | enum vsfusbd_MSCBOT_status_t 47 | { 48 | VSFUSBD_MSCBOT_STATUS_IDLE, 49 | VSFUSBD_MSCBOT_STATUS_OUT, 50 | VSFUSBD_MSCBOT_STATUS_IN, 51 | VSFUSBD_MSCBOT_STATUS_CSW, 52 | VSFUSBD_MSCBOT_STATUS_ERROR, 53 | }; 54 | 55 | struct vsfusbd_MSCBOT_param_t 56 | { 57 | uint8_t ep_out; 58 | uint8_t ep_in; 59 | 60 | uint8_t max_lun; 61 | struct SCSI_LUN_info_t *lun_info; 62 | struct SCSI_handler_t *user_handlers; 63 | 64 | // tick-tock operation 65 | // buffer size should be the largest one of all LUNs 66 | struct vsf_buffer_t page_buffer[2]; 67 | 68 | // no need to initialize below by user 69 | uint8_t tick_tock; 70 | volatile bool idle, poll; 71 | struct SCSI_handler_t *cur_handlers; 72 | struct USBMSC_CBW_t CBW; 73 | uint8_t dCSWStatus; 74 | struct vsf_transaction_buffer_t tbuffer; 75 | uint32_t page_size, page_num, cur_usb_page, cur_scsi_page; 76 | volatile enum vsfusbd_MSCBOT_status_t bot_status; 77 | }; 78 | 79 | #endif // __VSFUSBD_MSC_H_INCLUDED__ 80 | 81 | -------------------------------------------------------------------------------- /vsf/tool/crc/crc.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 - 2010 by Simon Qian * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 18 | ***************************************************************************/ 19 | 20 | #include "app_type.h" 21 | 22 | #include "crc.h" 23 | 24 | uint32_t crc_calc(struct crc_t *crc, void *buff, uint32_t num) 25 | { 26 | uint8_t bitlen = (uint8_t)crc->bitlen, i; 27 | uint32_t result = crc->result; 28 | uint8_t *buff8 = (uint8_t *)buff; 29 | uint16_t *buff16 = (uint16_t *)buff; 30 | uint32_t *buff32 = (uint32_t *)buff; 31 | 32 | while (num--) 33 | { 34 | switch (crc->bitlen) 35 | { 36 | case CRC_BITLEN_8: 37 | result ^= *buff8++; 38 | break; 39 | case CRC_BITLEN_16: 40 | result ^= *buff16++; 41 | break; 42 | case CRC_BITLEN_32: 43 | result ^= *buff32++; 44 | break; 45 | } 46 | for (i = 0; i < bitlen; i++) 47 | { 48 | if (result & 0x80) 49 | { 50 | result = (result << 1) ^ crc->poly; 51 | } 52 | else 53 | { 54 | result <<= 1; 55 | } 56 | } 57 | } 58 | result &= (1 << bitlen) - 1; 59 | crc->result = result; 60 | return result; 61 | } 62 | -------------------------------------------------------------------------------- /vsf/tool/crc/crc.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 - 2010 by Simon Qian * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 18 | ***************************************************************************/ 19 | 20 | #ifndef __CRC_H_INCLUDED__ 21 | #define __CRC_H_INCLUDED__ 22 | 23 | struct crc_t 24 | { 25 | enum crc_bitlen_t 26 | { 27 | CRC_BITLEN_8 = 8, 28 | CRC_BITLEN_16 = 16, 29 | CRC_BITLEN_32 = 32, 30 | } bitlen; 31 | uint32_t result; 32 | uint32_t poly; 33 | }; 34 | 35 | uint32_t crc_calc(struct crc_t *crc, void *buff, uint32_t num); 36 | 37 | #endif // __CRC_H_INCLUDED__ 38 | -------------------------------------------------------------------------------- /vsf/tool/list/list.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 - 2010 by Simon Qian * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 18 | ***************************************************************************/ 19 | 20 | #ifndef __LIST_H_INCLUDED__ 21 | #define __LIST_H_INCLUDED__ 22 | 23 | struct sllist 24 | { 25 | struct sllist *next; 26 | }; 27 | 28 | #define sllist_init_node(node) ((node).next = NULL) 29 | #define sllist_insert(node, new) ((node).next = &(new)) 30 | #define sllist_get_container(pnode, type, member) \ 31 | (pnode ? \ 32 | ((type *)((char *)(pnode)-(unsigned long)&(((type *)0)->member))) \ 33 | : NULL) 34 | 35 | #endif // __LIST_H_INCLUDED__ 36 | 37 | -------------------------------------------------------------------------------- /vsf/tool/mal_embflash/mal_embflash.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 - 2010 by Simon Qian * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 18 | ***************************************************************************/ 19 | 20 | #ifndef __EMBFLASH_H_INCLUDED__ 21 | #define __EMBFLASH_H_INCLUDED__ 22 | 23 | struct embflash_param_t 24 | { 25 | uint8_t index; 26 | // private 27 | bool erased; 28 | }; 29 | 30 | extern struct mal_driver_t embflash_drv; 31 | 32 | #endif // __EMBFLASH_H_INCLUDED__ 33 | -------------------------------------------------------------------------------- /vsf/tool/mal_in_mal/mal_in_mal.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 - 2010 by Simon Qian * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 18 | ***************************************************************************/ 19 | 20 | #ifndef __MALINMAL_H_INCLUDED__ 21 | #define __MALINMAL_H_INCLUDED__ 22 | 23 | struct malinmal_param_t 24 | { 25 | struct dal_info_t *maldal; 26 | 27 | uint64_t addr; 28 | uint64_t size; 29 | }; 30 | 31 | extern struct mal_driver_t malinmal_drv; 32 | 33 | #endif // __MALINMAL_H_INCLUDED__ 34 | -------------------------------------------------------------------------------- /vsf/tool/vsfui_fb/vsfui_fb.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 - 2010 by Simon Qian * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 18 | ***************************************************************************/ 19 | 20 | #ifndef __VSFUI_FB_H_INCLUDED__ 21 | #define __VSFUI_FB_H_INCLUDED__ 22 | 23 | struct vsfui_fb_t 24 | { 25 | struct vsfui_fb_screen_t 26 | { 27 | uint16_t width; 28 | uint16_t height; 29 | uint8_t pixel_size; 30 | 31 | struct dal_info_t *dal; 32 | } screen; 33 | 34 | // buffer 35 | struct vsf_multibuf_t *mbuffer; 36 | 37 | // private 38 | bool displaying; 39 | uint32_t cur_block; 40 | }; 41 | 42 | vsf_err_t vsfui_fb_init(struct vsfui_fb_t *vsfui_fb); 43 | vsf_err_t vsfui_fb_fini(struct vsfui_fb_t *vsfui_fb); 44 | void* vsfui_fb_get_buffer(struct vsfui_fb_t *vsfui_fb); 45 | vsf_err_t vsfui_fb_validate_buffer(struct vsfui_fb_t *vsfui_fb); 46 | vsf_err_t vsfui_fb_poll(struct vsfui_fb_t *vsfui_fb); 47 | 48 | #endif // __VSFUI_FB_H_INCLUDED__ -------------------------------------------------------------------------------- /vsf/vsf_err.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __VSF_ERR_H_INCLUDED__ 3 | #define __VSF_ERR_H_INCLUDED__ 4 | 5 | #include "vsf_basetype.h" 6 | 7 | typedef vsf_int_t vsf_err_t; 8 | 9 | #define VSFERR_NOT_READY 1 10 | #define VSFERR_NONE 0 11 | #define VSFERR_NOT_SUPPORT -1 12 | #define VSFERR_NOT_AVAILABLE -3 13 | #define VSFERR_NOT_ACCESSABLE -4 14 | #define VSFERR_NOT_ENOUGH_RESOURCES -5 15 | #define VSFERR_FAIL -6 16 | #define VSFERR_INVALID_PARAMETER -7 17 | #define VSFERR_INVALID_RANGE -8 18 | #define VSFERR_INVALID_PTR -9 19 | #define VSFERR_IO -10 20 | #define VSFERR_BUG -11 21 | #define VSFERR_UNKNOWN -100 22 | 23 | #endif // __VSF_ERR_H_INCLUDED__ 24 | --------------------------------------------------------------------------------