mirror of
https://github.com/bouffalolab/bouffalo_sdk.git
synced 2025-05-09 03:11:58 +08:00
[feat] add new examples
This commit is contained in:
parent
bc120c8861
commit
0860ef4d6e
@ -172,13 +172,13 @@ static void board_pin_mux_init(void)
|
||||
|
||||
gpio_cfg.drive = 0;
|
||||
gpio_cfg.smtCtrl = 1;
|
||||
gpio_cfg.gpioMode = GPIO_MODE_AF;
|
||||
gpio_cfg.pullType = GPIO_PULL_UP;
|
||||
|
||||
for (int i = 0; i < sizeof(af_pin_table)/sizeof(af_pin_table[0]); i++)
|
||||
{
|
||||
gpio_cfg.gpioPin = af_pin_table[i].pin;
|
||||
gpio_cfg.gpioFun = af_pin_table[i].func;
|
||||
gpio_cfg.gpioMode = GPIO_MODE_AF;
|
||||
gpio_cfg.pullType = GPIO_PULL_UP;
|
||||
gpio_cfg.gpioPin = af_pin_table[i].pin;
|
||||
gpio_cfg.gpioFun = af_pin_table[i].func;
|
||||
|
||||
if(af_pin_table[i].func == GPIO_FUN_UNUSED)
|
||||
{
|
||||
@ -188,11 +188,24 @@ static void board_pin_mux_init(void)
|
||||
{
|
||||
gpio_cfg.pullType = GPIO_PULL_DOWN;
|
||||
}
|
||||
else if((af_pin_table[i].func == GPIO_FUN_DAC)|| (af_pin_table[i].func == GPIO_FUN_DAC))
|
||||
{
|
||||
gpio_cfg.gpioFun = GPIO_FUN_ANALOG;
|
||||
gpio_cfg.gpioMode = GPIO_MODE_ANALOG;
|
||||
}
|
||||
else if((af_pin_table[i].func & 0x70) == 0x70)
|
||||
{
|
||||
gpio_cfg.gpioFun = GPIO_FUN_UART;
|
||||
uint8_t sig = af_pin_table[i].func & 0x07;
|
||||
GLB_UART_Fun_Sel((gpio_cfg.gpioPin % 8), sig);
|
||||
|
||||
if (gpio_cfg.gpioPin > 31)
|
||||
{
|
||||
GLB_UART_Fun_Sel(((gpio_cfg.gpioPin-9) % 8), sig);
|
||||
}
|
||||
else
|
||||
{
|
||||
GLB_UART_Fun_Sel((gpio_cfg.gpioPin % 8), sig);
|
||||
}
|
||||
}
|
||||
GLB_GPIO_Init(&gpio_cfg);
|
||||
}
|
||||
|
@ -1,7 +1,31 @@
|
||||
/**
|
||||
* @file clock_config.h
|
||||
* @brief
|
||||
*
|
||||
* Copyright (c) 2021 Bouffalolab team
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _CLOCK_CONFIG_H
|
||||
#define _CLOCK_CONFIG_H
|
||||
|
||||
#define BSP_ROOT_CLOCK_SOURCE ROOT_CLOCK_SOURCE_DLL_144M
|
||||
#define BSP_ROOT_CLOCK_SOURCE ROOT_CLOCK_SOURCE_PLL_144M
|
||||
// #define BSP_AUDIO_PLL_CLOCK_SOURCE AUDIO_PLL_CLOCK_24000000_HZ
|
||||
|
||||
#if defined(BSP_ROOT_CLOCK_SOURCE)
|
||||
#define BSP_HCLK_DIV 0
|
||||
@ -9,36 +33,36 @@
|
||||
#endif
|
||||
|
||||
#if defined(BSP_USING_UART0)||defined(BSP_USING_UART1)
|
||||
#define BSP_UART_CLOCK_SOURCE ROOT_CLOCK_SOURCE_DLL_96M
|
||||
#define BSP_UART_CLOCK_SOURCE ROOT_CLOCK_SOURCE_PLL_96M
|
||||
#define BSP_UART_CLOCK_DIV 0
|
||||
#endif
|
||||
#if defined(BSP_USING_I2C0)
|
||||
#define BSP_I2C_CLOCK_SOURCE ROOT_CLOCK_SOURCE_DLL_BCLK
|
||||
#define BSP_I2C_CLOCK_DIV 0
|
||||
#define BSP_I2C_CLOCK_SOURCE ROOT_CLOCK_SOURCE_BCLK
|
||||
#define BSP_I2C_CLOCK_DIV 9
|
||||
#endif
|
||||
#if defined(BSP_USING_SPI0)
|
||||
#define BSP_SPI_CLOCK_SOURCE ROOT_CLOCK_SOURCE_DLL_BCLK
|
||||
#define BSP_SPI_CLOCK_SOURCE ROOT_CLOCK_SOURCE_BCLK
|
||||
#define BSP_SPI_CLOCK_DIV 0
|
||||
#endif
|
||||
#if defined(BSP_USING_PWM)
|
||||
#define BSP_PWM_CLOCK_SOURCE ROOT_CLOCK_SOURCE_DLL_XCLK
|
||||
#define BSP_PWM_CLOCK_DIV 0
|
||||
#endif
|
||||
#if defined(BSP_USING_IR)
|
||||
#define BSP_IR_CLOCK_SOURCE ROOT_CLOCK_SOURCE_DLL_XCLK
|
||||
#define BSP_IR_CLOCK_SOURCE ROOT_CLOCK_SOURCE_XCLK
|
||||
#define BSP_IR_CLOCK_DIV 0
|
||||
#endif
|
||||
#if defined(BSP_USING_I2S0)
|
||||
#define BSP_I2S_CLOCK_SOURCE ROOT_CLOCK_SOURCE_DLL_XCLK
|
||||
#define BSP_I2S_CLOCK_SOURCE ROOT_CLOCK_SOURCE_XCLK
|
||||
#define BSP_I2S_CLOCK_DIV 0
|
||||
#endif
|
||||
#if defined(BSP_USING_ADC0)
|
||||
#define BSP_ADC_CLOCK_SOURCE ROOT_CLOCK_SOURCE_DLL_XCLK
|
||||
#define BSP_ADC_CLOCK_SOURCE ROOT_CLOCK_SOURCE_XCLK
|
||||
#define BSP_ADC_CLOCK_DIV 0
|
||||
#endif
|
||||
#if defined(BSP_USING_DAC0)
|
||||
#define BSP_DAC_CLOCK_SOURCE ROOT_CLOCK_SOURCE_DLL_XCLK
|
||||
#define BSP_DAC_CLOCK_DIV 0
|
||||
#define BSP_DAC_CLOCK_SOURCE ROOT_CLOCK_SOURCE_AUPLL
|
||||
#define BSP_DAC_CLOCK_DIV 1
|
||||
#endif
|
||||
#if defined(BSP_USING_CAM)
|
||||
#define BSP_CAM_CLOCK_SOURCE ROOT_CLOCK_SOURCE_PLL_96M
|
||||
#define BSP_CAM_CLOCK_DIV 3
|
||||
#endif
|
||||
|
||||
#endif
|
@ -11,10 +11,11 @@
|
||||
#define BSP_USING_I2S0
|
||||
#define BSP_USING_USB
|
||||
#define BSP_USING_PWM_CH2
|
||||
#define BSP_USING_TIMER
|
||||
#define BSP_USING_TIMER_CH0
|
||||
#define BSP_USING_TIMER_CH1
|
||||
#define BSP_USING_CAM
|
||||
/* ----------------------*/
|
||||
|
||||
|
||||
/* PERIPHERAL With DMA LIST */
|
||||
|
||||
#define BSP_USING_DMA0_CH0
|
||||
@ -37,19 +38,19 @@
|
||||
#define BSP_USING_DMA0_CH6
|
||||
#endif
|
||||
|
||||
#ifdef BSP_USING_TIMER
|
||||
#define BSP_USING_TIMER_CH0
|
||||
//#define BSP_USING_TIMER_CH1
|
||||
#endif
|
||||
|
||||
/* PERIPHERAL CONFIG */
|
||||
#if defined(BSP_USING_ADC0)
|
||||
#ifndef ADC_CONFIG
|
||||
#define ADC_CONFIG \
|
||||
#ifndef ADC0_CONFIG
|
||||
#define ADC0_CONFIG \
|
||||
{ \
|
||||
.clk = ADC_CLK_500KHZ,\
|
||||
.clk_div = ADC_CLOCK_DIV_32,\
|
||||
.vref = ADC_VREF_3P2V,\
|
||||
.resWidth = ADC_DATA_WIDTH_16_WITH_256_AVERAGE,\
|
||||
.continuous_conv_mode = DISABLE,\
|
||||
.differential_mode = DISABLE,\
|
||||
.data_width = ADC_DATA_WIDTH_16B_WITH_256_AVERAGE,\
|
||||
.fifo_threshold = ADC_FIFO_THRESHOLD_1BYTE,\
|
||||
.gain = ADC_GAIN_1\
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@ -104,7 +105,7 @@
|
||||
.clk_polaraity = SPI_POLARITY_LOW, \
|
||||
.clk_phase = SPI_PHASE_1EDGE, \
|
||||
.datasize = SPI_DATASIZE_8BIT, \
|
||||
.fifo_threshold = 1, \
|
||||
.fifo_threshold = 4, \
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@ -115,7 +116,7 @@
|
||||
{ \
|
||||
.ch = 2, \
|
||||
.frequency = 1000000, \
|
||||
.dutyCycle = 0, \
|
||||
.dutycycle = 0, \
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@ -300,7 +301,7 @@
|
||||
.id = 0, \
|
||||
.ch = 1, \
|
||||
.cnt_mode = TIMER_CNT_PRELOAD, \
|
||||
.pl_trig_src = TIMER_PL_TRIG_COMP0, \
|
||||
.pl_trig_src = TIMER_PL_TRIG_COMP2, \
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
@ -24,7 +24,15 @@
|
||||
#define _PINMUX_CONFIG_H
|
||||
|
||||
// <<< Use Configuration Wizard in Context Menu >>>
|
||||
#define PINMUX_LVGL 0
|
||||
#define PINMUX_UVC 1
|
||||
#define PINMUX_CAMERA_LCD 2
|
||||
#define PINMUX_OTHER 3
|
||||
// <q> PINMUX SELECT <2> [PINMUX_LVGL//PINMUX_UVC//PINMUX_CAMERA_LCD]
|
||||
// <i> config pinmux select
|
||||
#define PINMUX_SELECT PINMUX_CAMERA_LCD
|
||||
|
||||
#if PINMUX_SELECT == PINMUX_LVGL
|
||||
// <q> GPIO0 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio0 function
|
||||
#define CONFIG_GPIO0_FUNC GPIO_FUN_UNUSED
|
||||
@ -37,144 +45,602 @@
|
||||
// <i> config gpio2 function
|
||||
#define CONFIG_GPIO2_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO3 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RX//GPIO_FUN_UART1_RX//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO3 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RX//GPIO_FUN_UART1_RX//GPIO_FUN_QDEC]
|
||||
// <i> config gpio3 function
|
||||
#define CONFIG_GPIO3_FUNC GPIO_FUN_I2S
|
||||
|
||||
// <q> GPIO4 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO4 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio4 function
|
||||
#define CONFIG_GPIO4_FUNC GPIO_FUN_I2S
|
||||
|
||||
// <q> GPIO5 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_CTS//GPIO_FUN_UART1_CTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO5 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_CTS//GPIO_FUN_UART1_CTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio5 function
|
||||
#define CONFIG_GPIO5_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO6 <2> [GPIO_FUN_UNUSED//GPIO_FUN_CLK_OUT//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_TX//GPIO_FUN_UART1_TX//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO6 <2> [GPIO_FUN_UNUSED//GPIO_FUN_CLK_OUT//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_TX//GPIO_FUN_UART1_TX//GPIO_FUN_QDEC]
|
||||
// <i> config gpio6 function
|
||||
#define CONFIG_GPIO6_FUNC GPIO_FUN_CLK_OUT
|
||||
|
||||
// <q> GPIO7 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RX//GPIO_FUN_UART1_RX//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO7 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_USB//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RX//GPIO_FUN_UART1_RX//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio7 function
|
||||
#define CONFIG_GPIO7_FUNC GPIO_FUN_USB
|
||||
|
||||
// <q> GPIO8 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO8 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_USB//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio8 function
|
||||
#define CONFIG_GPIO8_FUNC GPIO_FUN_USB
|
||||
|
||||
// <q> GPIO9 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO9 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio9 function
|
||||
#define CONFIG_GPIO9_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO10 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO10 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio10 function
|
||||
#define CONFIG_GPIO10_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO11 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO11 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio11 function
|
||||
#define CONFIG_GPIO11_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO12 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO12 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio12 function
|
||||
#define CONFIG_GPIO12_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO13 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO13 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio13 function
|
||||
#define CONFIG_GPIO13_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO14 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO14 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio14 function
|
||||
#define CONFIG_GPIO14_FUNC GPIO_FUN_UART0_TX
|
||||
|
||||
// <q> GPIO15 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO15 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio15 function
|
||||
#define CONFIG_GPIO15_FUNC GPIO_FUN_UART0_RX
|
||||
|
||||
// <q> GPIO16 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO16 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio16 function
|
||||
#define CONFIG_GPIO16_FUNC GPIO_FUN_I2C
|
||||
|
||||
// <q> GPIO17 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO17 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio17 function
|
||||
#define CONFIG_GPIO17_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO18 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO18 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio18 function
|
||||
#define CONFIG_GPIO18_FUNC GPIO_FUN_UNUSED
|
||||
#define CONFIG_GPIO18_FUNC GPIO_FUN_ANALOG
|
||||
|
||||
// <q> GPIO19 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO19 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio19 function
|
||||
#define CONFIG_GPIO19_FUNC GPIO_FUN_SPI
|
||||
|
||||
// <q> GPIO20 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO20 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio20 function
|
||||
#define CONFIG_GPIO20_FUNC GPIO_FUN_SPI
|
||||
|
||||
// <q> GPIO21 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO21 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio21 function
|
||||
#define CONFIG_GPIO21_FUNC GPIO_FUN_SPI
|
||||
|
||||
// <q> GPIO22 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO22 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio22 function
|
||||
#define CONFIG_GPIO22_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO23 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO23 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio23 function
|
||||
#define CONFIG_GPIO23_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO24 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO24 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio24 function
|
||||
#define CONFIG_GPIO24_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO25 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO25 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio25 function
|
||||
#define CONFIG_GPIO25_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO26 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO26 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio26 function
|
||||
#define CONFIG_GPIO26_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO27 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO27 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio27 function
|
||||
#define CONFIG_GPIO27_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO28 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO28 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio28 function
|
||||
#define CONFIG_GPIO28_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO29 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO29 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio29 function
|
||||
#define CONFIG_GPIO29_FUNC GPIO_FUN_I2S
|
||||
|
||||
// <q> GPIO30 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO30 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio30 function
|
||||
#define CONFIG_GPIO30_FUNC GPIO_FUN_I2S
|
||||
|
||||
// <q> GPIO31 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO31 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio31 function
|
||||
#define CONFIG_GPIO31_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO32 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO32 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio32 function
|
||||
#define CONFIG_GPIO32_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO33 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO33 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio33 function
|
||||
#define CONFIG_GPIO33_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO34 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO34 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio34 function
|
||||
#define CONFIG_GPIO34_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO35 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO35 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio35 function
|
||||
#define CONFIG_GPIO35_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO36 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO36 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio36 function
|
||||
#define CONFIG_GPIO36_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO37 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO37 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio37 function
|
||||
#define CONFIG_GPIO37_FUNC GPIO_FUN_UNUSED
|
||||
#elif PINMUX_SELECT == PINMUX_UVC
|
||||
// <q> GPIO0 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio0 function
|
||||
#define CONFIG_GPIO0_FUNC GPIO_FUN_CAM
|
||||
|
||||
// <q> GPIO1 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_CTS//GPIO_FUN_UART1_CTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio1 function
|
||||
#define CONFIG_GPIO1_FUNC GPIO_FUN_CAM
|
||||
|
||||
// <q> GPIO2 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_TX//GPIO_FUN_UART1_TX//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio2 function
|
||||
#define CONFIG_GPIO2_FUNC GPIO_FUN_CAM
|
||||
|
||||
// <q> GPIO3 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RX//GPIO_FUN_UART1_RX//GPIO_FUN_QDEC]
|
||||
// <i> config gpio3 function
|
||||
#define CONFIG_GPIO3_FUNC GPIO_FUN_CAM
|
||||
|
||||
// <q> GPIO4 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio4 function
|
||||
#define CONFIG_GPIO4_FUNC GPIO_FUN_CAM
|
||||
|
||||
// <q> GPIO5 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_CTS//GPIO_FUN_UART1_CTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio5 function
|
||||
#define CONFIG_GPIO5_FUNC GPIO_FUN_CAM
|
||||
|
||||
// <q> GPIO6 <2> [GPIO_FUN_UNUSED//GPIO_FUN_CLK_OUT//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_TX//GPIO_FUN_UART1_TX//GPIO_FUN_QDEC]
|
||||
// <i> config gpio6 function
|
||||
#define CONFIG_GPIO6_FUNC GPIO_FUN_CAM
|
||||
|
||||
// <q> GPIO7 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_USB//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RX//GPIO_FUN_UART1_RX//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio7 function
|
||||
#define CONFIG_GPIO7_FUNC GPIO_FUN_USB
|
||||
|
||||
// <q> GPIO8 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_USB//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio8 function
|
||||
#define CONFIG_GPIO8_FUNC GPIO_FUN_USB
|
||||
|
||||
// <q> GPIO9 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio9 function
|
||||
#define CONFIG_GPIO9_FUNC GPIO_FUN_CLK_OUT
|
||||
|
||||
// <q> GPIO10 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio10 function
|
||||
#define CONFIG_GPIO10_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO11 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio11 function
|
||||
#define CONFIG_GPIO11_FUNC GPIO_FUN_I2C
|
||||
|
||||
// <q> GPIO12 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio12 function
|
||||
#define CONFIG_GPIO12_FUNC GPIO_FUN_CAM
|
||||
|
||||
// <q> GPIO13 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio13 function
|
||||
#define CONFIG_GPIO13_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO14 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio14 function
|
||||
#define CONFIG_GPIO14_FUNC GPIO_FUN_UART0_TX
|
||||
|
||||
// <q> GPIO15 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio15 function
|
||||
#define CONFIG_GPIO15_FUNC GPIO_FUN_UART0_RX
|
||||
|
||||
// <q> GPIO16 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio16 function
|
||||
#define CONFIG_GPIO16_FUNC GPIO_FUN_I2C
|
||||
|
||||
// <q> GPIO17 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio17 function
|
||||
#define CONFIG_GPIO17_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO18 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio18 function
|
||||
#define CONFIG_GPIO18_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO19 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio19 function
|
||||
#define CONFIG_GPIO19_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO20 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio20 function
|
||||
#define CONFIG_GPIO20_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO21 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio21 function
|
||||
#define CONFIG_GPIO21_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO22 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio22 function
|
||||
#define CONFIG_GPIO22_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO23 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio23 function
|
||||
#define CONFIG_GPIO23_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO24 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio24 function
|
||||
#define CONFIG_GPIO24_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO25 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio25 function
|
||||
#define CONFIG_GPIO25_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO26 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio26 function
|
||||
#define CONFIG_GPIO26_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO27 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio27 function
|
||||
#define CONFIG_GPIO27_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO28 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio28 function
|
||||
#define CONFIG_GPIO28_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO29 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio29 function
|
||||
#define CONFIG_GPIO29_FUNC GPIO_FUN_CAM
|
||||
|
||||
// <q> GPIO30 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio30 function
|
||||
#define CONFIG_GPIO30_FUNC GPIO_FUN_CAM
|
||||
|
||||
// <q> GPIO31 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio31 function
|
||||
#define CONFIG_GPIO31_FUNC GPIO_FUN_CAM
|
||||
|
||||
// <q> GPIO32 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio32 function
|
||||
#define CONFIG_GPIO32_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO33 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio33 function
|
||||
#define CONFIG_GPIO33_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO34 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio34 function
|
||||
#define CONFIG_GPIO34_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO35 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio35 function
|
||||
#define CONFIG_GPIO35_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO36 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio36 function
|
||||
#define CONFIG_GPIO36_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO37 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio37 function
|
||||
#define CONFIG_GPIO37_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
#elif PINMUX_SELECT == PINMUX_CAMERA_LCD
|
||||
// <q> GPIO0 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio0 function
|
||||
#define CONFIG_GPIO0_FUNC GPIO_FUN_CAM
|
||||
|
||||
// <q> GPIO1 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_CTS//GPIO_FUN_UART1_CTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio1 function
|
||||
#define CONFIG_GPIO1_FUNC GPIO_FUN_CAM
|
||||
|
||||
// <q> GPIO2 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_TX//GPIO_FUN_UART1_TX//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio2 function
|
||||
#define CONFIG_GPIO2_FUNC GPIO_FUN_CAM
|
||||
|
||||
// <q> GPIO3 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RX//GPIO_FUN_UART1_RX//GPIO_FUN_QDEC]
|
||||
// <i> config gpio3 function
|
||||
#define CONFIG_GPIO3_FUNC GPIO_FUN_CAM
|
||||
|
||||
// <q> GPIO4 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio4 function
|
||||
#define CONFIG_GPIO4_FUNC GPIO_FUN_CAM
|
||||
|
||||
// <q> GPIO5 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_CTS//GPIO_FUN_UART1_CTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio5 function
|
||||
#define CONFIG_GPIO5_FUNC GPIO_FUN_CAM
|
||||
|
||||
// <q> GPIO6 <2> [GPIO_FUN_UNUSED//GPIO_FUN_CLK_OUT//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_TX//GPIO_FUN_UART1_TX//GPIO_FUN_QDEC]
|
||||
// <i> config gpio6 function
|
||||
#define CONFIG_GPIO6_FUNC GPIO_FUN_CAM
|
||||
|
||||
// <q> GPIO7 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_USB//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RX//GPIO_FUN_UART1_RX//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio7 function
|
||||
#define CONFIG_GPIO7_FUNC GPIO_FUN_USB
|
||||
|
||||
// <q> GPIO8 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_USB//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio8 function
|
||||
#define CONFIG_GPIO8_FUNC GPIO_FUN_USB
|
||||
|
||||
// <q> GPIO9 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio9 function
|
||||
#define CONFIG_GPIO9_FUNC GPIO_FUN_CLK_OUT
|
||||
|
||||
// <q> GPIO10 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio10 function
|
||||
#define CONFIG_GPIO10_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO11 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio11 function
|
||||
#define CONFIG_GPIO11_FUNC GPIO_FUN_I2C
|
||||
|
||||
// <q> GPIO12 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio12 function
|
||||
#define CONFIG_GPIO12_FUNC GPIO_FUN_CAM
|
||||
|
||||
// <q> GPIO13 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio13 function
|
||||
#define CONFIG_GPIO13_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO14 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio14 function
|
||||
#define CONFIG_GPIO14_FUNC GPIO_FUN_UART0_TX
|
||||
|
||||
// <q> GPIO15 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio15 function
|
||||
#define CONFIG_GPIO15_FUNC GPIO_FUN_UART0_RX
|
||||
|
||||
// <q> GPIO16 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio16 function
|
||||
#define CONFIG_GPIO16_FUNC GPIO_FUN_I2C
|
||||
|
||||
// <q> GPIO17 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio17 function
|
||||
#define CONFIG_GPIO17_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO18 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio18 function
|
||||
#define CONFIG_GPIO18_FUNC GPIO_FUN_ANALOG
|
||||
|
||||
// <q> GPIO19 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio19 function
|
||||
#define CONFIG_GPIO19_FUNC GPIO_FUN_SPI
|
||||
|
||||
// <q> GPIO20 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio20 function
|
||||
#define CONFIG_GPIO20_FUNC GPIO_FUN_SPI
|
||||
|
||||
// <q> GPIO21 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio21 function
|
||||
#define CONFIG_GPIO21_FUNC GPIO_FUN_SPI
|
||||
|
||||
// <q> GPIO22 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio22 function
|
||||
#define CONFIG_GPIO22_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO23 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio23 function
|
||||
#define CONFIG_GPIO23_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO24 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio24 function
|
||||
#define CONFIG_GPIO24_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO25 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio25 function
|
||||
#define CONFIG_GPIO25_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO26 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio26 function
|
||||
#define CONFIG_GPIO26_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO27 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio27 function
|
||||
#define CONFIG_GPIO27_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO28 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio28 function
|
||||
#define CONFIG_GPIO28_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO29 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio29 function
|
||||
#define CONFIG_GPIO29_FUNC GPIO_FUN_CAM
|
||||
|
||||
// <q> GPIO30 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio30 function
|
||||
#define CONFIG_GPIO30_FUNC GPIO_FUN_CAM
|
||||
|
||||
// <q> GPIO31 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio31 function
|
||||
#define CONFIG_GPIO31_FUNC GPIO_FUN_CAM
|
||||
|
||||
// <q> GPIO32 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio32 function
|
||||
#define CONFIG_GPIO32_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO33 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio33 function
|
||||
#define CONFIG_GPIO33_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO34 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio34 function
|
||||
#define CONFIG_GPIO34_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO35 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio35 function
|
||||
#define CONFIG_GPIO35_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO36 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio36 function
|
||||
#define CONFIG_GPIO36_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO37 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio37 function
|
||||
#define CONFIG_GPIO37_FUNC GPIO_FUN_UNUSED
|
||||
#else
|
||||
// <q> GPIO0 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio0 function
|
||||
#define CONFIG_GPIO0_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO1 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_CTS//GPIO_FUN_UART1_CTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio1 function
|
||||
#define CONFIG_GPIO1_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO2 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_TX//GPIO_FUN_UART1_TX//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio2 function
|
||||
#define CONFIG_GPIO2_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO3 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RX//GPIO_FUN_UART1_RX//GPIO_FUN_QDEC]
|
||||
// <i> config gpio3 function
|
||||
#define CONFIG_GPIO3_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO4 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio4 function
|
||||
#define CONFIG_GPIO4_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO5 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_CTS//GPIO_FUN_UART1_CTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio5 function
|
||||
#define CONFIG_GPIO5_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO6 <2> [GPIO_FUN_UNUSED//GPIO_FUN_CLK_OUT//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_TX//GPIO_FUN_UART1_TX//GPIO_FUN_QDEC]
|
||||
// <i> config gpio6 function
|
||||
#define CONFIG_GPIO6_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO7 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_USB//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RX//GPIO_FUN_UART1_RX//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio7 function
|
||||
#define CONFIG_GPIO7_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO8 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_USB//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio8 function
|
||||
#define CONFIG_GPIO8_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO9 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio9 function
|
||||
#define CONFIG_GPIO9_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO10 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio10 function
|
||||
#define CONFIG_GPIO10_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO11 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio11 function
|
||||
#define CONFIG_GPIO11_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO12 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio12 function
|
||||
#define CONFIG_GPIO12_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO13 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio13 function
|
||||
#define CONFIG_GPIO13_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO14 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio14 function
|
||||
#define CONFIG_GPIO14_FUNC GPIO_FUN_UART0_TX
|
||||
|
||||
// <q> GPIO15 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio15 function
|
||||
#define CONFIG_GPIO15_FUNC GPIO_FUN_UART0_RX
|
||||
|
||||
// <q> GPIO16 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio16 function
|
||||
#define CONFIG_GPIO16_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO17 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio17 function
|
||||
#define CONFIG_GPIO17_FUNC GPIO_FUN_UART1_TX
|
||||
|
||||
// <q> GPIO18 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio18 function
|
||||
#define CONFIG_GPIO18_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO19 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio19 function
|
||||
#define CONFIG_GPIO19_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO20 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio20 function
|
||||
#define CONFIG_GPIO20_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO21 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio21 function
|
||||
#define CONFIG_GPIO21_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO22 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio22 function
|
||||
#define CONFIG_GPIO22_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO23 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio23 function
|
||||
#define CONFIG_GPIO23_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO24 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio24 function
|
||||
#define CONFIG_GPIO24_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO25 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio25 function
|
||||
#define CONFIG_GPIO25_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO26 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio26 function
|
||||
#define CONFIG_GPIO26_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO27 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio27 function
|
||||
#define CONFIG_GPIO27_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO28 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio28 function
|
||||
#define CONFIG_GPIO28_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO29 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio29 function
|
||||
#define CONFIG_GPIO29_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO30 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio30 function
|
||||
#define CONFIG_GPIO30_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO31 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio31 function
|
||||
#define CONFIG_GPIO31_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO32 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio32 function
|
||||
#define CONFIG_GPIO32_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO33 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio33 function
|
||||
#define CONFIG_GPIO33_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO34 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio34 function
|
||||
#define CONFIG_GPIO34_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO35 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio35 function
|
||||
#define CONFIG_GPIO35_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO36 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio36 function
|
||||
#define CONFIG_GPIO36_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO37 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio37 function
|
||||
#define CONFIG_GPIO37_FUNC GPIO_FUN_UNUSED
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -195,13 +195,13 @@ static void board_pin_mux_init(void)
|
||||
|
||||
gpio_cfg.drive = 0;
|
||||
gpio_cfg.smtCtrl = 1;
|
||||
gpio_cfg.gpioMode = GPIO_MODE_AF;
|
||||
gpio_cfg.pullType = GPIO_PULL_UP;
|
||||
|
||||
for (int i = 0; i < sizeof(af_pin_table)/sizeof(af_pin_table[0]); i++)
|
||||
{
|
||||
gpio_cfg.gpioPin = af_pin_table[i].pin;
|
||||
gpio_cfg.gpioFun = af_pin_table[i].func;
|
||||
gpio_cfg.gpioMode = GPIO_MODE_AF;
|
||||
gpio_cfg.pullType = GPIO_PULL_UP;
|
||||
gpio_cfg.gpioPin = af_pin_table[i].pin;
|
||||
gpio_cfg.gpioFun = af_pin_table[i].func;
|
||||
|
||||
if(af_pin_table[i].func == GPIO_FUN_UNUSED)
|
||||
{
|
||||
@ -211,11 +211,24 @@ static void board_pin_mux_init(void)
|
||||
{
|
||||
gpio_cfg.pullType = GPIO_PULL_DOWN;
|
||||
}
|
||||
else if((af_pin_table[i].func == GPIO_FUN_DAC)|| (af_pin_table[i].func == GPIO_FUN_DAC))
|
||||
{
|
||||
gpio_cfg.gpioFun = GPIO_FUN_ANALOG;
|
||||
gpio_cfg.gpioMode = GPIO_MODE_ANALOG;
|
||||
}
|
||||
else if((af_pin_table[i].func & 0x70) == 0x70)
|
||||
{
|
||||
gpio_cfg.gpioFun = GPIO_FUN_UART;
|
||||
uint8_t sig = af_pin_table[i].func & 0x07;
|
||||
GLB_UART_Fun_Sel((gpio_cfg.gpioPin % 8), sig);
|
||||
|
||||
if (gpio_cfg.gpioPin > 31)
|
||||
{
|
||||
GLB_UART_Fun_Sel(((gpio_cfg.gpioPin-9) % 8), sig);
|
||||
}
|
||||
else
|
||||
{
|
||||
GLB_UART_Fun_Sel((gpio_cfg.gpioPin % 8), sig);
|
||||
}
|
||||
}
|
||||
GLB_GPIO_Init(&gpio_cfg);
|
||||
}
|
||||
@ -255,4 +268,4 @@ void board_init(void)
|
||||
{
|
||||
board_clock_init();
|
||||
board_pin_mux_init();
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,8 @@
|
||||
#ifndef _CLOCK_CONFIG_H
|
||||
#define _CLOCK_CONFIG_H
|
||||
|
||||
#define BSP_ROOT_CLOCK_SOURCE ROOT_CLOCK_SOURCE_DLL_144M
|
||||
#define BSP_ROOT_CLOCK_SOURCE ROOT_CLOCK_SOURCE_PLL_144M
|
||||
// #define BSP_AUDIO_PLL_CLOCK_SOURCE AUDIO_PLL_CLOCK_24000000_HZ
|
||||
|
||||
#if defined(BSP_ROOT_CLOCK_SOURCE)
|
||||
#define BSP_HCLK_DIV 0
|
||||
@ -32,36 +33,32 @@
|
||||
#endif
|
||||
|
||||
#if defined(BSP_USING_UART0)||defined(BSP_USING_UART1)
|
||||
#define BSP_UART_CLOCK_SOURCE ROOT_CLOCK_SOURCE_DLL_96M
|
||||
#define BSP_UART_CLOCK_SOURCE ROOT_CLOCK_SOURCE_PLL_96M
|
||||
#define BSP_UART_CLOCK_DIV 0
|
||||
#endif
|
||||
#if defined(BSP_USING_I2C0)
|
||||
#define BSP_I2C_CLOCK_SOURCE ROOT_CLOCK_SOURCE_DLL_BCLK
|
||||
#define BSP_I2C_CLOCK_SOURCE ROOT_CLOCK_SOURCE_BCLK
|
||||
#define BSP_I2C_CLOCK_DIV 0
|
||||
#endif
|
||||
#if defined(BSP_USING_SPI0)
|
||||
#define BSP_SPI_CLOCK_SOURCE ROOT_CLOCK_SOURCE_DLL_BCLK
|
||||
#define BSP_SPI_CLOCK_SOURCE ROOT_CLOCK_SOURCE_BCLK
|
||||
#define BSP_SPI_CLOCK_DIV 0
|
||||
#endif
|
||||
#if defined(BSP_USING_PWM)
|
||||
#define BSP_PWM_CLOCK_SOURCE ROOT_CLOCK_SOURCE_DLL_XCLK
|
||||
#define BSP_PWM_CLOCK_DIV 0
|
||||
#endif
|
||||
#if defined(BSP_USING_IR)
|
||||
#define BSP_IR_CLOCK_SOURCE ROOT_CLOCK_SOURCE_DLL_XCLK
|
||||
#define BSP_IR_CLOCK_SOURCE ROOT_CLOCK_SOURCE_XCLK
|
||||
#define BSP_IR_CLOCK_DIV 0
|
||||
#endif
|
||||
#if defined(BSP_USING_I2S0)
|
||||
#define BSP_I2S_CLOCK_SOURCE ROOT_CLOCK_SOURCE_DLL_XCLK
|
||||
#define BSP_I2S_CLOCK_SOURCE ROOT_CLOCK_SOURCE_XCLK
|
||||
#define BSP_I2S_CLOCK_DIV 0
|
||||
#endif
|
||||
#if defined(BSP_USING_ADC0)
|
||||
#define BSP_ADC_CLOCK_SOURCE ROOT_CLOCK_SOURCE_DLL_XCLK
|
||||
#define BSP_ADC_CLOCK_SOURCE ROOT_CLOCK_SOURCE_XCLK
|
||||
#define BSP_ADC_CLOCK_DIV 0
|
||||
#endif
|
||||
#if defined(BSP_USING_DAC0)
|
||||
#define BSP_DAC_CLOCK_SOURCE ROOT_CLOCK_SOURCE_DLL_XCLK
|
||||
#define BSP_DAC_CLOCK_DIV 0
|
||||
#define BSP_DAC_CLOCK_SOURCE ROOT_CLOCK_SOURCE_AUPLL
|
||||
#define BSP_DAC_CLOCK_DIV 1
|
||||
#endif
|
||||
|
||||
#endif
|
@ -34,45 +34,32 @@
|
||||
#define BSP_USING_I2S0
|
||||
#define BSP_USING_USB
|
||||
#define BSP_USING_PWM_CH2
|
||||
#define BSP_USING_TIMER
|
||||
#define BSP_USING_TIMER_CH0
|
||||
#define BSP_USING_TIMER_CH1
|
||||
/* ----------------------*/
|
||||
|
||||
|
||||
/* PERIPHERAL With DMA LIST */
|
||||
|
||||
#define BSP_USING_DMA0_CH0
|
||||
#define BSP_USING_DMA0_CH1
|
||||
|
||||
#ifdef BSP_USING_UART1
|
||||
#define BSP_USING_DMA0_CH2
|
||||
#endif
|
||||
|
||||
#ifdef BSP_USING_SPI0
|
||||
#define BSP_USING_DMA0_CH3
|
||||
#define BSP_USING_DMA0_CH4
|
||||
#endif
|
||||
|
||||
#ifdef BSP_USING_I2S0
|
||||
#define BSP_USING_DMA0_CH2
|
||||
#endif
|
||||
|
||||
#ifdef BSP_USING_DAC0
|
||||
#define BSP_USING_DMA0_CH6
|
||||
#endif
|
||||
|
||||
#ifdef BSP_USING_TIMER
|
||||
#define BSP_USING_TIMER_CH0
|
||||
//#define BSP_USING_TIMER_CH1
|
||||
#endif
|
||||
|
||||
/* PERIPHERAL CONFIG */
|
||||
#if defined(BSP_USING_ADC0)
|
||||
#ifndef ADC_CONFIG
|
||||
#define ADC_CONFIG \
|
||||
#ifndef ADC0_CONFIG
|
||||
#define ADC0_CONFIG \
|
||||
{ \
|
||||
.clk = ADC_CLK_500KHZ,\
|
||||
.clk_div = ADC_CLOCK_DIV_32,\
|
||||
.vref = ADC_VREF_3P2V,\
|
||||
.resWidth = ADC_DATA_WIDTH_16_WITH_256_AVERAGE,\
|
||||
.continuous_conv_mode = DISABLE,\
|
||||
.differential_mode = DISABLE,\
|
||||
.data_width = ADC_DATA_WIDTH_16B_WITH_256_AVERAGE,\
|
||||
.fifo_threshold = ADC_FIFO_THRESHOLD_1BYTE,\
|
||||
.gain = ADC_GAIN_1\
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@ -138,7 +125,8 @@
|
||||
{ \
|
||||
.ch = 2, \
|
||||
.frequency = 1000000, \
|
||||
.dutyCycle = 0, \
|
||||
.dutycycle = 0, \
|
||||
.it_pulse_count = 0,\
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@ -323,7 +311,7 @@
|
||||
.id = 0, \
|
||||
.ch = 1, \
|
||||
.cnt_mode = TIMER_CNT_PRELOAD, \
|
||||
.pl_trig_src = TIMER_PL_TRIG_COMP0, \
|
||||
.pl_trig_src = TIMER_PL_TRIG_COMP2, \
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
@ -37,143 +37,143 @@
|
||||
// <i> config gpio2 function
|
||||
#define CONFIG_GPIO2_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO3 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RX//GPIO_FUN_UART1_RX//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO3 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RX//GPIO_FUN_UART1_RX//GPIO_FUN_QDEC]
|
||||
// <i> config gpio3 function
|
||||
#define CONFIG_GPIO3_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO4 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO4 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio4 function
|
||||
#define CONFIG_GPIO4_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO5 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_CTS//GPIO_FUN_UART1_CTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO5 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_CTS//GPIO_FUN_UART1_CTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio5 function
|
||||
#define CONFIG_GPIO5_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO6 <2> [GPIO_FUN_UNUSED//GPIO_FUN_CLK_OUT//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_TX//GPIO_FUN_UART1_TX//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO6 <2> [GPIO_FUN_UNUSED//GPIO_FUN_CLK_OUT//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_TX//GPIO_FUN_UART1_TX//GPIO_FUN_QDEC]
|
||||
// <i> config gpio6 function
|
||||
#define CONFIG_GPIO6_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO7 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RX//GPIO_FUN_UART1_RX//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO7 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_USB//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RX//GPIO_FUN_UART1_RX//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio7 function
|
||||
#define CONFIG_GPIO7_FUNC GPIO_FUN_USB
|
||||
|
||||
// <q> GPIO8 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO8 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_USB//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio8 function
|
||||
#define CONFIG_GPIO8_FUNC GPIO_FUN_USB
|
||||
|
||||
// <q> GPIO9 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO9 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio9 function
|
||||
#define CONFIG_GPIO9_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO10 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO10 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio10 function
|
||||
#define CONFIG_GPIO10_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO11 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO11 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio11 function
|
||||
#define CONFIG_GPIO11_FUNC GPIO_FUN_UNUSED
|
||||
#define CONFIG_GPIO11_FUNC GPIO_FUN_ADC
|
||||
|
||||
// <q> GPIO12 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO12 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio12 function
|
||||
#define CONFIG_GPIO12_FUNC GPIO_FUN_UNUSED
|
||||
#define CONFIG_GPIO12_FUNC GPIO_FUN_ADC
|
||||
|
||||
// <q> GPIO13 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO13 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio13 function
|
||||
#define CONFIG_GPIO13_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO14 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO14 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio14 function
|
||||
#define CONFIG_GPIO14_FUNC GPIO_FUN_UART0_TX
|
||||
|
||||
// <q> GPIO15 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO15 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio15 function
|
||||
#define CONFIG_GPIO15_FUNC GPIO_FUN_UART0_RX
|
||||
|
||||
// <q> GPIO16 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO16 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio16 function
|
||||
#define CONFIG_GPIO16_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO17 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO17 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio17 function
|
||||
#define CONFIG_GPIO17_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO18 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO18 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio18 function
|
||||
#define CONFIG_GPIO18_FUNC GPIO_FUN_UART1_TX
|
||||
|
||||
// <q> GPIO19 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO19 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio19 function
|
||||
#define CONFIG_GPIO19_FUNC GPIO_FUN_UART1_RX
|
||||
|
||||
// <q> GPIO20 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO20 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio20 function
|
||||
#define CONFIG_GPIO20_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO21 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO21 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio21 function
|
||||
#define CONFIG_GPIO21_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO22 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO22 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio22 function
|
||||
#define CONFIG_GPIO22_FUNC GPIO_FUN_PWM
|
||||
|
||||
// <q> GPIO23 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO23 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio23 function
|
||||
#define CONFIG_GPIO23_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO24 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO24 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio24 function
|
||||
#define CONFIG_GPIO24_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO25 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO25 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio25 function
|
||||
#define CONFIG_GPIO25_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO26 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO26 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio26 function
|
||||
#define CONFIG_GPIO26_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO27 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO27 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio27 function
|
||||
#define CONFIG_GPIO27_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO28 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO28 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio28 function
|
||||
#define CONFIG_GPIO28_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO29 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO29 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio29 function
|
||||
#define CONFIG_GPIO29_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO30 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO30 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio30 function
|
||||
#define CONFIG_GPIO30_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO31 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO31 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio31 function
|
||||
#define CONFIG_GPIO31_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO32 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO32 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio32 function
|
||||
#define CONFIG_GPIO32_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO33 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO33 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio33 function
|
||||
#define CONFIG_GPIO33_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO34 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO34 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio34 function
|
||||
#define CONFIG_GPIO34_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO35 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO35 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio35 function
|
||||
#define CONFIG_GPIO35_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO36 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO36 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio36 function
|
||||
#define CONFIG_GPIO36_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO37 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <q> GPIO37 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio37 function
|
||||
#define CONFIG_GPIO37_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
|
30
bsp/board/bl706_lp/bl702_config.h
Normal file
30
bsp/board/bl706_lp/bl702_config.h
Normal file
@ -0,0 +1,30 @@
|
||||
/**
|
||||
* @file bl702_config.h
|
||||
* @brief
|
||||
*
|
||||
* Copyright (c) 2021 Bouffalolab team
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __BL702_CONFIG_H__
|
||||
#define __BL702_CONFIG_H__
|
||||
|
||||
#include "peripheral_config.h"
|
||||
#include "clock_config.h"
|
||||
|
||||
#endif
|
271
bsp/board/bl706_lp/board.c
Normal file
271
bsp/board/bl706_lp/board.c
Normal file
@ -0,0 +1,271 @@
|
||||
/**
|
||||
* @file board.c
|
||||
* @brief
|
||||
*
|
||||
* Copyright (c) 2021 Bouffalolab team
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "hal_gpio.h"
|
||||
#include "hal_clock.h"
|
||||
#include "bl702_glb.h"
|
||||
#include "pinmux_config.h"
|
||||
|
||||
struct pin_mux_cfg
|
||||
{
|
||||
uint8_t pin;
|
||||
uint16_t func;
|
||||
};
|
||||
|
||||
static const struct pin_mux_cfg af_pin_table[] =
|
||||
{
|
||||
{
|
||||
.pin = GPIO_PIN_0,
|
||||
.func = CONFIG_GPIO0_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_1,
|
||||
.func = CONFIG_GPIO1_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_2,
|
||||
.func = CONFIG_GPIO2_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_3,
|
||||
.func = CONFIG_GPIO3_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_4,
|
||||
.func = CONFIG_GPIO4_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_5,
|
||||
.func = CONFIG_GPIO5_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_6,
|
||||
.func = CONFIG_GPIO6_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_7,
|
||||
.func = CONFIG_GPIO7_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_8,
|
||||
.func = CONFIG_GPIO8_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_9,
|
||||
.func = CONFIG_GPIO9_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_10,
|
||||
.func = CONFIG_GPIO10_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_11,
|
||||
.func = CONFIG_GPIO11_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_12,
|
||||
.func = CONFIG_GPIO12_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_13,
|
||||
.func = CONFIG_GPIO13_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_14,
|
||||
.func = CONFIG_GPIO14_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_15,
|
||||
.func = CONFIG_GPIO15_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_16,
|
||||
.func = CONFIG_GPIO16_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_17,
|
||||
.func = CONFIG_GPIO17_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_18,
|
||||
.func = CONFIG_GPIO18_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_19,
|
||||
.func = CONFIG_GPIO19_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_20,
|
||||
.func = CONFIG_GPIO20_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_21,
|
||||
.func = CONFIG_GPIO21_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_22,
|
||||
.func = CONFIG_GPIO22_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_23,
|
||||
.func = CONFIG_GPIO23_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_24,
|
||||
.func = CONFIG_GPIO24_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_25,
|
||||
.func = CONFIG_GPIO25_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_26,
|
||||
.func = CONFIG_GPIO26_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_27,
|
||||
.func = CONFIG_GPIO27_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_28,
|
||||
.func = CONFIG_GPIO28_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_29,
|
||||
.func = CONFIG_GPIO29_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_30,
|
||||
.func = CONFIG_GPIO30_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_31,
|
||||
.func = CONFIG_GPIO31_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_32,
|
||||
.func = CONFIG_GPIO32_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_33,
|
||||
.func = CONFIG_GPIO33_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_34,
|
||||
.func = CONFIG_GPIO34_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_35,
|
||||
.func = CONFIG_GPIO35_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_36,
|
||||
.func = CONFIG_GPIO36_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_37,
|
||||
.func = CONFIG_GPIO37_FUNC
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
static void board_pin_mux_init(void)
|
||||
{
|
||||
GLB_GPIO_Cfg_Type gpio_cfg;
|
||||
|
||||
gpio_cfg.drive = 0;
|
||||
gpio_cfg.smtCtrl = 1;
|
||||
|
||||
for (int i = 0; i < sizeof(af_pin_table)/sizeof(af_pin_table[0]); i++)
|
||||
{
|
||||
gpio_cfg.gpioMode = GPIO_MODE_AF;
|
||||
gpio_cfg.pullType = GPIO_PULL_UP;
|
||||
gpio_cfg.gpioPin = af_pin_table[i].pin;
|
||||
gpio_cfg.gpioFun = af_pin_table[i].func;
|
||||
|
||||
if(af_pin_table[i].func == GPIO_FUN_UNUSED)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else if(af_pin_table[i].func == GPIO_FUN_PWM)
|
||||
{
|
||||
gpio_cfg.pullType = GPIO_PULL_DOWN;
|
||||
}
|
||||
else if((af_pin_table[i].func == GPIO_FUN_DAC)|| (af_pin_table[i].func == GPIO_FUN_DAC))
|
||||
{
|
||||
gpio_cfg.gpioFun = GPIO_FUN_ANALOG;
|
||||
gpio_cfg.gpioMode = GPIO_MODE_ANALOG;
|
||||
}
|
||||
else if((af_pin_table[i].func & 0x70) == 0x70)
|
||||
{
|
||||
gpio_cfg.gpioFun = GPIO_FUN_UART;
|
||||
uint8_t sig = af_pin_table[i].func & 0x07;
|
||||
|
||||
if (gpio_cfg.gpioPin > 31)
|
||||
{
|
||||
GLB_UART_Fun_Sel(((gpio_cfg.gpioPin-9) % 8), sig);
|
||||
}
|
||||
else
|
||||
{
|
||||
GLB_UART_Fun_Sel((gpio_cfg.gpioPin % 8), sig);
|
||||
}
|
||||
}
|
||||
GLB_GPIO_Init(&gpio_cfg);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void board_clock_init(void)
|
||||
{
|
||||
system_clock_init();
|
||||
peripheral_clock_init();
|
||||
}
|
||||
|
||||
void bl_show_info(void)
|
||||
{
|
||||
MSG(" ____ __ __ _ _ _ \r\n");
|
||||
MSG(" | _ \\ / _|/ _| | | | | | | \r\n");
|
||||
MSG(" | |_) | ___ _ _| |_| |_ __ _| | ___ | | __ _| |__ \r\n");
|
||||
MSG(" | _ < / _ \\| | | | _| _/ _` | |/ _ \\| |/ _` | '_ \\ \r\n");
|
||||
MSG(" | |_) | (_) | |_| | | | || (_| | | (_) | | (_| | |_) |\r\n");
|
||||
MSG(" |____/ \\___/ \\__,_|_| |_| \\__,_|_|\\___/|_|\\__,_|_.__/ \r\n");
|
||||
MSG("\r\n");
|
||||
MSG("Build:%s,%s\r\n",__TIME__,__DATE__);
|
||||
MSG("Copyright (c) 2021 Bouffalolab team\r\n");
|
||||
|
||||
#if 0
|
||||
MSG("root clock:%dM\r\n",system_clock_get(SYSTEM_CLOCK_ROOT_CLOCK)/1000000);
|
||||
MSG("fclk clock:%dM\r\n",system_clock_get(SYSTEM_CLOCK_FCLK)/1000000);
|
||||
MSG("bclk clock:%dM\r\n",system_clock_get(SYSTEM_CLOCK_BCLK)/1000000);
|
||||
|
||||
MSG("uart clock:%dM\r\n",peripheral_clock_get(PERIPHERAL_CLOCK_UART)/1000000);
|
||||
MSG("spi clock:%dM\r\n",peripheral_clock_get(PERIPHERAL_CLOCK_SPI)/1000000);
|
||||
MSG("i2c clock:%dM\r\n",peripheral_clock_get(PERIPHERAL_CLOCK_I2C)/1000000);
|
||||
#endif
|
||||
}
|
||||
|
||||
void board_init(void)
|
||||
{
|
||||
board_clock_init();
|
||||
board_pin_mux_init();
|
||||
}
|
64
bsp/board/bl706_lp/clock_config.h
Normal file
64
bsp/board/bl706_lp/clock_config.h
Normal file
@ -0,0 +1,64 @@
|
||||
/**
|
||||
* @file clock_config.h
|
||||
* @brief
|
||||
*
|
||||
* Copyright (c) 2021 Bouffalolab team
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _CLOCK_CONFIG_H
|
||||
#define _CLOCK_CONFIG_H
|
||||
|
||||
#define BSP_ROOT_CLOCK_SOURCE ROOT_CLOCK_SOURCE_XTAL_32M
|
||||
// #define BSP_AUDIO_PLL_CLOCK_SOURCE AUDIO_PLL_CLOCK_24000000_HZ
|
||||
|
||||
#if defined(BSP_ROOT_CLOCK_SOURCE)
|
||||
#define BSP_HCLK_DIV 0
|
||||
#define BSP_BCLK_DIV 1
|
||||
#endif
|
||||
|
||||
#if defined(BSP_USING_UART0)||defined(BSP_USING_UART1)
|
||||
#define BSP_UART_CLOCK_SOURCE ROOT_CLOCK_SOURCE_PLL_96M
|
||||
#define BSP_UART_CLOCK_DIV 0
|
||||
#endif
|
||||
#if defined(BSP_USING_I2C0)
|
||||
#define BSP_I2C_CLOCK_SOURCE ROOT_CLOCK_SOURCE_BCLK
|
||||
#define BSP_I2C_CLOCK_DIV 0
|
||||
#endif
|
||||
#if defined(BSP_USING_SPI0)
|
||||
#define BSP_SPI_CLOCK_SOURCE ROOT_CLOCK_SOURCE_BCLK
|
||||
#define BSP_SPI_CLOCK_DIV 0
|
||||
#endif
|
||||
#if defined(BSP_USING_IR)
|
||||
#define BSP_IR_CLOCK_SOURCE ROOT_CLOCK_SOURCE_XCLK
|
||||
#define BSP_IR_CLOCK_DIV 0
|
||||
#endif
|
||||
#if defined(BSP_USING_I2S0)
|
||||
#define BSP_I2S_CLOCK_SOURCE ROOT_CLOCK_SOURCE_XCLK
|
||||
#define BSP_I2S_CLOCK_DIV 0
|
||||
#endif
|
||||
#if defined(BSP_USING_ADC0)
|
||||
#define BSP_ADC_CLOCK_SOURCE ROOT_CLOCK_SOURCE_XCLK
|
||||
#define BSP_ADC_CLOCK_DIV 0
|
||||
#endif
|
||||
#if defined(BSP_USING_DAC0)
|
||||
#define BSP_DAC_CLOCK_SOURCE ROOT_CLOCK_SOURCE_AUPLL
|
||||
#define BSP_DAC_CLOCK_DIV 1
|
||||
#endif
|
||||
|
||||
#endif
|
318
bsp/board/bl706_lp/peripheral_config.h
Normal file
318
bsp/board/bl706_lp/peripheral_config.h
Normal file
@ -0,0 +1,318 @@
|
||||
/**
|
||||
* @file peripheral_config.h
|
||||
* @brief
|
||||
*
|
||||
* Copyright (c) 2021 Bouffalolab team
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _PERIPHERAL_CONFIG_H_
|
||||
#define _PERIPHERAL_CONFIG_H_
|
||||
|
||||
/* PERIPHERAL USING LIST */
|
||||
#define BSP_USING_ADC0
|
||||
#define BSP_USING_DAC0
|
||||
#define BSP_USING_UART0
|
||||
#define BSP_USING_UART1
|
||||
#define BSP_USING_SPI0
|
||||
#define BSP_USING_I2C0
|
||||
#define BSP_USING_I2S0
|
||||
#define BSP_USING_USB
|
||||
#define BSP_USING_PWM_CH2
|
||||
#define BSP_USING_TIMER_CH0
|
||||
/* ----------------------*/
|
||||
|
||||
/* PERIPHERAL With DMA LIST */
|
||||
|
||||
#define BSP_USING_DMA0_CH0
|
||||
#define BSP_USING_DMA0_CH1
|
||||
#define BSP_USING_DMA0_CH2
|
||||
#define BSP_USING_DMA0_CH3
|
||||
#define BSP_USING_DMA0_CH4
|
||||
#define BSP_USING_DMA0_CH2
|
||||
#define BSP_USING_DMA0_CH6
|
||||
|
||||
/* PERIPHERAL CONFIG */
|
||||
#if defined(BSP_USING_ADC0)
|
||||
#ifndef ADC0_CONFIG
|
||||
#define ADC0_CONFIG \
|
||||
{ \
|
||||
.clk_div = ADC_CLOCK_DIV_32,\
|
||||
.vref = ADC_VREF_3P2V,\
|
||||
.continuous_conv_mode = DISABLE,\
|
||||
.differential_mode = DISABLE,\
|
||||
.data_width = ADC_DATA_WIDTH_16B_WITH_256_AVERAGE,\
|
||||
.fifo_threshold = ADC_FIFO_THRESHOLD_1BYTE,\
|
||||
.gain = ADC_GAIN_1\
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(BSP_USING_DAC0)
|
||||
#ifndef DAC_CONFIG
|
||||
#define DAC_CONFIG \
|
||||
{ \
|
||||
.clk = DAC_CLK_500KHZ,\
|
||||
.pin.dac0 = GLB_GPIO_PIN_11,\
|
||||
.pin.pin_num = 1,\
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(BSP_USING_UART0)
|
||||
#ifndef UART0_CONFIG
|
||||
#define UART0_CONFIG \
|
||||
{ \
|
||||
.id = 0, \
|
||||
.baudrate = 2000000,\
|
||||
.databits = UART_DATA_LEN_8, \
|
||||
.stopbits = UART_STOP_ONE, \
|
||||
.parity = UART_PAR_NONE, \
|
||||
.fifo_threshold = 1, \
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(BSP_USING_UART1)
|
||||
#ifndef UART1_CONFIG
|
||||
#define UART1_CONFIG \
|
||||
{ \
|
||||
.id = 1, \
|
||||
.baudrate = 2000000,\
|
||||
.databits = UART_DATA_LEN_8, \
|
||||
.stopbits = UART_STOP_ONE, \
|
||||
.parity = UART_PAR_NONE, \
|
||||
.fifo_threshold = 64, \
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(BSP_USING_SPI0)
|
||||
#ifndef SPI0_CONFIG
|
||||
#define SPI0_CONFIG \
|
||||
{ \
|
||||
.id = 0, \
|
||||
.clk = 18000000,\
|
||||
.mode = SPI_MASTER_MODE, \
|
||||
.direction = SPI_MSB_BYTE0_DIRECTION_FIRST, \
|
||||
.clk_polaraity = SPI_POLARITY_LOW, \
|
||||
.clk_phase = SPI_PHASE_1EDGE, \
|
||||
.datasize = SPI_DATASIZE_8BIT, \
|
||||
.fifo_threshold = 1, \
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(BSP_USING_PWM_CH2)
|
||||
#ifndef PWM_CH2_CONFIG
|
||||
#define PWM_CH2_CONFIG \
|
||||
{ \
|
||||
.ch = 2, \
|
||||
.frequency = 1000000, \
|
||||
.dutycycle = 0, \
|
||||
.it_pulse_count = 0,\
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(BSP_USING_I2S0)
|
||||
#ifndef I2S0_CONFIG
|
||||
#define I2S0_CONFIG \
|
||||
{ \
|
||||
.id = 0, \
|
||||
.iis_mode = I2S_MODE_MASTER,\
|
||||
.interface_mode = I2S_MODE_LEFT, \
|
||||
.sampl_freq_hz = 16*1000, \
|
||||
.channel_num = I2S_FS_CHANNELS_NUM_MONO, \
|
||||
.frame_size = I2S_FRAME_LEN_16, \
|
||||
.data_size = I2S_DATA_LEN_16, \
|
||||
.fifo_threshold = 8, \
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(BSP_USING_DMA0_CH0)
|
||||
#ifndef DMA0_CH0_CONFIG
|
||||
#define DMA0_CH0_CONFIG \
|
||||
{ \
|
||||
.id = 0, \
|
||||
.ch = 0,\
|
||||
.direction = DMA_MEMORY_TO_MEMORY,\
|
||||
.transfer_mode = DMA_LLI_ONCE_MODE, \
|
||||
.src_req = DMA_REQUEST_NONE, \
|
||||
.dst_req = DMA_REQUEST_NONE, \
|
||||
.src_width = DMA_TRANSFER_WIDTH_32BIT , \
|
||||
.dst_width = DMA_TRANSFER_WIDTH_32BIT , \
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(BSP_USING_DMA0_CH1)
|
||||
#ifndef DMA0_CH1_CONFIG
|
||||
#define DMA0_CH1_CONFIG \
|
||||
{ \
|
||||
.id = 0, \
|
||||
.ch = 1,\
|
||||
.direction = DMA_MEMORY_TO_MEMORY, \
|
||||
.transfer_mode = DMA_LLI_ONCE_MODE, \
|
||||
.src_req = DMA_REQUEST_NONE, \
|
||||
.dst_req = DMA_REQUEST_NONE, \
|
||||
.src_width = DMA_TRANSFER_WIDTH_16BIT , \
|
||||
.dst_width = DMA_TRANSFER_WIDTH_16BIT , \
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(BSP_USING_DMA0_CH2)
|
||||
#ifndef DMA0_CH2_CONFIG
|
||||
#define DMA0_CH2_CONFIG \
|
||||
{ \
|
||||
.id = 0, \
|
||||
.ch = 2,\
|
||||
.direction = DMA_MEMORY_TO_PERIPH, \
|
||||
.transfer_mode = DMA_LLI_ONCE_MODE, \
|
||||
.src_req = DMA_REQUEST_NONE, \
|
||||
.dst_req = DMA_REQUEST_UART1_TX, \
|
||||
.src_width = DMA_TRANSFER_WIDTH_8BIT , \
|
||||
.dst_width = DMA_TRANSFER_WIDTH_8BIT , \
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(BSP_USING_DMA0_CH3)
|
||||
#ifndef DMA0_CH3_CONFIG
|
||||
#define DMA0_CH3_CONFIG \
|
||||
{ \
|
||||
.id = 0, \
|
||||
.ch = 3,\
|
||||
.direction = DMA_MEMORY_TO_PERIPH, \
|
||||
.transfer_mode = DMA_LLI_ONCE_MODE, \
|
||||
.src_req = DMA_REQUEST_NONE, \
|
||||
.dst_req = DMA_REQUEST_SPI0_TX, \
|
||||
.src_width = DMA_TRANSFER_WIDTH_8BIT , \
|
||||
.dst_width = DMA_TRANSFER_WIDTH_8BIT , \
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(BSP_USING_DMA0_CH4)
|
||||
#ifndef DMA0_CH4_CONFIG
|
||||
#define DMA0_CH4_CONFIG \
|
||||
{ \
|
||||
.id = 0, \
|
||||
.ch = 4,\
|
||||
.direction = DMA_PERIPH_TO_MEMORY, \
|
||||
.transfer_mode = DMA_LLI_ONCE_MODE, \
|
||||
.src_req = DMA_REQUEST_SPI0_RX, \
|
||||
.dst_req = DMA_REQUEST_NONE, \
|
||||
.src_width = DMA_TRANSFER_WIDTH_8BIT , \
|
||||
.dst_width = DMA_TRANSFER_WIDTH_8BIT , \
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(BSP_USING_DMA0_CH5)
|
||||
#ifndef DMA0_CH5_CONFIG
|
||||
#define DMA0_CH5_CONFIG \
|
||||
{ \
|
||||
.id = 0, \
|
||||
.ch = 5,\
|
||||
.direction = DMA_MEMORY_TO_PERIPH, \
|
||||
.transfer_mode = DMA_LLI_CYCLE_MODE, \
|
||||
.src_req = DMA_REQUEST_NONE, \
|
||||
.dst_req = DMA_REQUEST_I2S_TX, \
|
||||
.src_width = DMA_TRANSFER_WIDTH_16BIT , \
|
||||
.dst_width = DMA_TRANSFER_WIDTH_16BIT , \
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(BSP_USING_DMA0_CH6)
|
||||
#ifndef DMA0_CH6_CONFIG
|
||||
#define DMA0_CH6_CONFIG \
|
||||
{ \
|
||||
.id = 0, \
|
||||
.ch = 6,\
|
||||
.direction = DMA_MEMORY_TO_PERIPH, \
|
||||
.transfer_mode = DMA_LLI_CYCLE_MODE, \
|
||||
.src_req = DMA_REQUEST_NONE, \
|
||||
.dst_req = DMA_REQUEST_I2S_TX, \
|
||||
.src_width = DMA_TRANSFER_WIDTH_16BIT , \
|
||||
.dst_width = DMA_TRANSFER_WIDTH_16BIT , \
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(BSP_USING_DMA0_CH7)
|
||||
#ifndef DMA0_CH7_CONFIG
|
||||
#define DMA0_CH7_CONFIG \
|
||||
{ \
|
||||
.id = 0, \
|
||||
.ch = 0,\
|
||||
.direction = DMA_MEMORY_TO_MEMORY,\
|
||||
.transfer_mode = DMA_LLI_ONCE_MODE, \
|
||||
.src_req = DMA_REQUEST_NONE, \
|
||||
.dst_req = DMA_REQUEST_NONE, \
|
||||
.src_width = DMA_TRANSFER_WIDTH_32BIT , \
|
||||
.dst_width = DMA_TRANSFER_WIDTH_32BIT , \
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#if defined(BSP_USING_I2C0)
|
||||
#ifndef I2C0_CONFIG
|
||||
#define I2C0_CONFIG \
|
||||
{ \
|
||||
.id = 0, \
|
||||
.mode = I2C_HW_MODE,\
|
||||
.phase = 15, \
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#if defined (BSP_USING_TIMER_CH0)
|
||||
#ifndef TIMER_CH0_CONFIG
|
||||
#define TIMER_CH0_CONFIG \
|
||||
{ \
|
||||
.id = 0, \
|
||||
.ch = 0, \
|
||||
.cnt_mode = TIMER_CNT_PRELOAD, \
|
||||
.pl_trig_src = TIMER_PL_TRIG_COMP0, \
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined (BSP_USING_TIMER_CH1)
|
||||
#ifndef TIMER_CH1_CONFIG
|
||||
#define TIMER_CH1_CONFIG \
|
||||
{ \
|
||||
.id = 0, \
|
||||
.ch = 1, \
|
||||
.cnt_mode = TIMER_CNT_PRELOAD, \
|
||||
.pl_trig_src = TIMER_PL_TRIG_COMP0, \
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
180
bsp/board/bl706_lp/pinmux_config.h
Normal file
180
bsp/board/bl706_lp/pinmux_config.h
Normal file
@ -0,0 +1,180 @@
|
||||
/**
|
||||
* @file pinmux_config.h
|
||||
* @brief
|
||||
*
|
||||
* Copyright (c) 2021 Bouffalolab team
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
#ifndef _PINMUX_CONFIG_H
|
||||
#define _PINMUX_CONFIG_H
|
||||
|
||||
// <<< Use Configuration Wizard in Context Menu >>>
|
||||
|
||||
// <q> GPIO0 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio0 function
|
||||
#define CONFIG_GPIO0_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO1 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_CTS//GPIO_FUN_UART1_CTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio1 function
|
||||
#define CONFIG_GPIO1_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO2 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_TX//GPIO_FUN_UART1_TX//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio2 function
|
||||
#define CONFIG_GPIO2_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO3 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RX//GPIO_FUN_UART1_RX//GPIO_FUN_QDEC]
|
||||
// <i> config gpio3 function
|
||||
#define CONFIG_GPIO3_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO4 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio4 function
|
||||
#define CONFIG_GPIO4_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO5 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_CTS//GPIO_FUN_UART1_CTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio5 function
|
||||
#define CONFIG_GPIO5_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO6 <2> [GPIO_FUN_UNUSED//GPIO_FUN_CLK_OUT//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_TX//GPIO_FUN_UART1_TX//GPIO_FUN_QDEC]
|
||||
// <i> config gpio6 function
|
||||
#define CONFIG_GPIO6_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO7 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_USB//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RX//GPIO_FUN_UART1_RX//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio7 function
|
||||
#define CONFIG_GPIO7_FUNC GPIO_FUN_USB
|
||||
|
||||
// <q> GPIO8 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_USB//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio8 function
|
||||
#define CONFIG_GPIO8_FUNC GPIO_FUN_USB
|
||||
|
||||
// <q> GPIO9 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio9 function
|
||||
#define CONFIG_GPIO9_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO10 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio10 function
|
||||
#define CONFIG_GPIO10_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO11 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio11 function
|
||||
#define CONFIG_GPIO11_FUNC GPIO_FUN_ADC
|
||||
|
||||
// <q> GPIO12 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio12 function
|
||||
#define CONFIG_GPIO12_FUNC GPIO_FUN_ADC
|
||||
|
||||
// <q> GPIO13 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio13 function
|
||||
#define CONFIG_GPIO13_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO14 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio14 function
|
||||
#define CONFIG_GPIO14_FUNC GPIO_FUN_UART0_TX
|
||||
|
||||
// <q> GPIO15 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio15 function
|
||||
#define CONFIG_GPIO15_FUNC GPIO_FUN_UART0_RX
|
||||
|
||||
// <q> GPIO16 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio16 function
|
||||
#define CONFIG_GPIO16_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO17 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio17 function
|
||||
#define CONFIG_GPIO17_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO18 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio18 function
|
||||
#define CONFIG_GPIO18_FUNC GPIO_FUN_UART1_TX
|
||||
|
||||
// <q> GPIO19 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio19 function
|
||||
#define CONFIG_GPIO19_FUNC GPIO_FUN_UART1_RX
|
||||
|
||||
// <q> GPIO20 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio20 function
|
||||
#define CONFIG_GPIO20_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO21 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio21 function
|
||||
#define CONFIG_GPIO21_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO22 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio22 function
|
||||
#define CONFIG_GPIO22_FUNC GPIO_FUN_PWM
|
||||
|
||||
// <q> GPIO23 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio23 function
|
||||
#define CONFIG_GPIO23_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO24 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio24 function
|
||||
#define CONFIG_GPIO24_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO25 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio25 function
|
||||
#define CONFIG_GPIO25_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO26 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio26 function
|
||||
#define CONFIG_GPIO26_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO27 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio27 function
|
||||
#define CONFIG_GPIO27_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO28 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio28 function
|
||||
#define CONFIG_GPIO28_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO29 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio29 function
|
||||
#define CONFIG_GPIO29_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO30 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio30 function
|
||||
#define CONFIG_GPIO30_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO31 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio31 function
|
||||
#define CONFIG_GPIO31_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO32 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_ANALOG//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_QDEC]
|
||||
// <i> config gpio32 function
|
||||
#define CONFIG_GPIO32_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO33 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio33 function
|
||||
#define CONFIG_GPIO33_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO34 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio34 function
|
||||
#define CONFIG_GPIO34_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO35 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio35 function
|
||||
#define CONFIG_GPIO35_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO36 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio36 function
|
||||
#define CONFIG_GPIO36_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO37 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio37 function
|
||||
#define CONFIG_GPIO37_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
#endif
|
5
examples/adc/adc_tsen/CMakeLists.txt
Normal file
5
examples/adc/adc_tsen/CMakeLists.txt
Normal file
@ -0,0 +1,5 @@
|
||||
set(mains main.c)
|
||||
generate_bin()
|
||||
|
||||
|
||||
|
83
examples/adc/adc_tsen/main.c
Normal file
83
examples/adc/adc_tsen/main.c
Normal file
@ -0,0 +1,83 @@
|
||||
/**
|
||||
* @file main.c
|
||||
* @brief
|
||||
*
|
||||
* Copyright (c) 2021 Bouffalolab team
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "hal_adc.h"
|
||||
#include "hal_gpio.h"
|
||||
|
||||
adc_channel_t posChList[] = {ADC_CHANNEL_TSEN_P};
|
||||
adc_channel_t negChList[] = {ADC_CHANNEL_GND};
|
||||
|
||||
uint16_t tsen_offset = 0;
|
||||
|
||||
struct device* adc_tsen;
|
||||
|
||||
int main(void)
|
||||
{
|
||||
float sum_val = 0.0;
|
||||
bflb_platform_init(0);
|
||||
|
||||
adc_channel_cfg_t adc_channel_cfg;
|
||||
|
||||
adc_channel_cfg.pos_channel = posChList;
|
||||
adc_channel_cfg.neg_channel = negChList;
|
||||
adc_channel_cfg.num = 1;
|
||||
|
||||
MSG("adc tsen test case \r\n");
|
||||
adc_register(ADC0_INDEX, "adc_tsen", DEVICE_OFLAG_STREAM_RX);
|
||||
|
||||
adc_tsen = device_find("adc_tsen");
|
||||
if(adc_tsen)
|
||||
{
|
||||
ADC_DEV(adc_tsen)->continuous_conv_mode = DISABLE;
|
||||
device_open(adc_tsen, DEVICE_OFLAG_STREAM_RX);
|
||||
device_control(adc_tsen, DEVICE_CTRL_ADC_CHANNEL_CONFIG,&adc_channel_cfg);
|
||||
device_control(adc_tsen, DEVICE_CTRL_ADC_TSEN_ON,NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
MSG("adc device find fail \n");
|
||||
}
|
||||
|
||||
if(adc_trim_tsen(&tsen_offset) == ERROR)
|
||||
{
|
||||
MSG("read efuse data fail \n");
|
||||
return ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
MSG("offset = %d \n", tsen_offset);
|
||||
}
|
||||
|
||||
while(1)
|
||||
{
|
||||
for(int i = 0; i < 50; i ++)
|
||||
{
|
||||
sum_val += adc_get_tsen(tsen_offset);
|
||||
bflb_platform_delay_ms(10);
|
||||
}
|
||||
MSG("Tsen temp:%0.2f \n", (sum_val / 50.0));
|
||||
sum_val = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
240
examples/ble/bl702_flash_ble.ld
Normal file
240
examples/ble/bl702_flash_ble.ld
Normal file
@ -0,0 +1,240 @@
|
||||
/****************************************************************************************
|
||||
* @file bl702_flash.ld
|
||||
*
|
||||
* @brief This file is the map file (gnuarm or armgcc).
|
||||
*
|
||||
* Copyright (C) BouffaloLab 2021
|
||||
*
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/* configure the CPU type */
|
||||
OUTPUT_ARCH( "riscv" )
|
||||
/* link with the standard c library */
|
||||
/* INPUT(-lc) */
|
||||
/* link with the standard GCC library */
|
||||
/* INPUT(-lgcc) */
|
||||
/* configure the entry point */
|
||||
ENTRY(_enter)
|
||||
|
||||
StackSize = 0x1000; /* 4KB */
|
||||
HeapSize = 0x1000; /* 4KB */
|
||||
__EM_SIZE = DEFINED(ble_controller_init) ? 8K : 0K;
|
||||
|
||||
MEMORY
|
||||
{
|
||||
xip_memory (rx) : ORIGIN = 0x23000000, LENGTH = 1024K
|
||||
itcm_memory (rx) : ORIGIN = 0x22014000, LENGTH = 16K
|
||||
dtcm_memory (rx) : ORIGIN = 0x42018000, LENGTH = 32K
|
||||
ram_memory (!rx) : ORIGIN = 0x42020000, LENGTH = 32K
|
||||
rsvd_memory (!rx) : ORIGIN = 0x42028000, LENGTH = 1K
|
||||
ram2_memory (!rx) : ORIGIN = 0x42028400, LENGTH = (31K - __EM_SIZE)
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
PROVIDE(__metal_chicken_bit = 0);
|
||||
|
||||
.text :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__text_code_start__ = .;
|
||||
|
||||
KEEP (*(.text.metal.init.enter))
|
||||
KEEP (*(SORT_NONE(.init)))
|
||||
/* section information for finsh shell */
|
||||
. = ALIGN(4);
|
||||
_shell_command_start = .;
|
||||
KEEP(*(shellCommand))
|
||||
_shell_command_end = .;
|
||||
|
||||
/* section information for usb desc */
|
||||
. = ALIGN(4);
|
||||
_usb_desc_start = .;
|
||||
KEEP(*(usb_desc))
|
||||
. = ALIGN(4);
|
||||
_usb_desc_end = .;
|
||||
|
||||
*(.text)
|
||||
*(.text.*)
|
||||
|
||||
/*put .rodata**/
|
||||
*(EXCLUDE_FILE( *bl702_glb.o \
|
||||
*bl702_pds.o \
|
||||
*bl702_common.o \
|
||||
*bl702_sf_cfg.o \
|
||||
*bl702_sf_ctrl.o \
|
||||
*bl702_sflash.o \
|
||||
*bl702_xip_sflash.o \
|
||||
*bl702_ef_ctrl.o) .rodata*)
|
||||
*(.rodata)
|
||||
*(.rodata.*)
|
||||
|
||||
*(.srodata)
|
||||
*(.srodata.*)
|
||||
|
||||
_bt_gatt_service_static_list_start = .;
|
||||
KEEP(*(SORT_BY_NAME("._bt_gatt_service_static.static.*")))
|
||||
_bt_gatt_service_static_list_end = .;
|
||||
_bt_l2cap_fixed_chan_list_start = .;
|
||||
KEEP(*(SORT_BY_NAME("._bt_l2cap_fixed_chan.static.*")))
|
||||
_bt_l2cap_fixed_chan_list_end = .;
|
||||
|
||||
. = ALIGN(4);
|
||||
__text_code_end__ = .;
|
||||
} > xip_memory
|
||||
|
||||
. = ALIGN(4);
|
||||
__itcm_load_addr = .;
|
||||
|
||||
.itcm_region : AT (__itcm_load_addr)
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__tcm_code_start__ = .;
|
||||
|
||||
*(.tcm_code)
|
||||
*(.tcm_const)
|
||||
*(.sclock_rlt_code)
|
||||
*(.sclock_rlt_const)
|
||||
|
||||
*bl702_glb.o*(.rodata*)
|
||||
*bl702_pds.o*(.rodata*)
|
||||
*bl702_common.o*(.rodata*)
|
||||
*bl702_sf_cfg.o*(.rodata*)
|
||||
*bl702_sf_ctrl.o*(.rodata*)
|
||||
*bl702_sflash.o*(.rodata*)
|
||||
*bl702_xip_sflash.o*(.rodata*)
|
||||
*bl702_ef_ctrl.o*(.rodata*)
|
||||
|
||||
. = ALIGN(4);
|
||||
__tcm_code_end__ = .;
|
||||
} > itcm_memory
|
||||
|
||||
__dtcm_load_addr = __itcm_load_addr + SIZEOF(.itcm_region);
|
||||
|
||||
.dtcm_region : AT (__dtcm_load_addr)
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__tcm_data_start__ = .;
|
||||
|
||||
*(.tcm_data)
|
||||
/* *finger_print.o(.data*) */
|
||||
|
||||
. = ALIGN(4);
|
||||
__tcm_data_end__ = .;
|
||||
} > dtcm_memory
|
||||
|
||||
/* .heap_dummy section doesn't contains any symbols. It is only
|
||||
* used for linker to calculate size of heap sections, and assign
|
||||
* values to heap symbols later */
|
||||
.heap_dummy (NOLOAD):
|
||||
{
|
||||
. = ALIGN(0x4);
|
||||
. = . + HeapSize;
|
||||
. = ALIGN(0x4);
|
||||
} > dtcm_memory
|
||||
|
||||
_HeapBase = ORIGIN(dtcm_memory) + LENGTH(dtcm_memory) - StackSize - HeapSize;
|
||||
_HeapSize = HeapSize;
|
||||
|
||||
/* Check if data + heap + stack exceeds RAM limit */
|
||||
ASSERT(_HeapBase >= __tcm_data_end__, "region RAM overflowed with stack")
|
||||
|
||||
/*************************************************************************/
|
||||
/* .stack_dummy section doesn't contains any symbols. It is only
|
||||
* used for linker to calculate size of stack sections, and assign
|
||||
* values to stack symbols later */
|
||||
.stack_dummy (NOLOAD):
|
||||
{
|
||||
. = ALIGN(0x4);
|
||||
. = . + StackSize;
|
||||
. = ALIGN(0x4);
|
||||
} > dtcm_memory
|
||||
|
||||
/* Set stack top to end of RAM, and stack limit move down by
|
||||
* size of stack_dummy section */
|
||||
__StackTop = ORIGIN(dtcm_memory) + LENGTH(dtcm_memory);
|
||||
PROVIDE( __freertos_irq_stack_top = __StackTop);
|
||||
__StackLimit = __StackTop - SIZEOF(.stack_dummy);
|
||||
|
||||
/* Check if data + heap + stack exceeds RAM limit */
|
||||
ASSERT(__StackLimit >= __tcm_data_end__, "region RAM overflowed with stack")
|
||||
/*************************************************************************/
|
||||
|
||||
__system_ram_load_addr = __dtcm_load_addr + SIZEOF(.dtcm_region);
|
||||
|
||||
.system_ram_data_region : AT (__system_ram_load_addr)
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__system_ram_data_start__ = .;
|
||||
|
||||
*(.system_ram)
|
||||
|
||||
. = ALIGN(4);
|
||||
__system_ram_data_end__ = .;
|
||||
} > ram_memory
|
||||
|
||||
__ram_load_addr = __system_ram_load_addr + SIZEOF(.system_ram_data_region);
|
||||
|
||||
/* Data section */
|
||||
RAM_DATA : AT (__ram_load_addr)
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__ram_data_start__ = .;
|
||||
|
||||
PROVIDE( __global_pointer$ = . + 0x800 );
|
||||
|
||||
*(.data)
|
||||
*(.data.*)
|
||||
*(.sdata)
|
||||
*(.sdata.*)
|
||||
*(.sdata2)
|
||||
*(.sdata2.*)
|
||||
|
||||
. = ALIGN(4);
|
||||
__ram_data_end__ = .;
|
||||
} > ram_memory
|
||||
|
||||
.bss (NOLOAD) :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__bss_start__ = .;
|
||||
|
||||
*(.bss*)
|
||||
*(.sbss*)
|
||||
*(COMMON)
|
||||
|
||||
. = ALIGN(4);
|
||||
__bss_end__ = .;
|
||||
} > ram_memory
|
||||
|
||||
.noinit_data (NOLOAD) :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__noinit_data_start__ = .;
|
||||
|
||||
*(.noinit_data*)
|
||||
|
||||
. = ALIGN(4);
|
||||
__noinit_data_end__ = .;
|
||||
} > ram_memory
|
||||
|
||||
.heap (NOLOAD):
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__HeapBase = .;
|
||||
|
||||
/*__end__ = .;*/
|
||||
/*end = __end__;*/
|
||||
KEEP(*(.heap*))
|
||||
|
||||
. = ALIGN(4);
|
||||
__HeapLimit = .;
|
||||
} > ram_memory
|
||||
__HeapLimit = ORIGIN(ram_memory) + LENGTH(ram_memory);
|
||||
|
||||
PROVIDE( _heap_start = ORIGIN(ram2_memory) );
|
||||
PROVIDE( _heap_size = LENGTH(ram2_memory) );
|
||||
|
||||
}
|
||||
|
8
examples/ble/ble_central/CMakeLists.txt
Normal file
8
examples/ble/ble_central/CMakeLists.txt
Normal file
@ -0,0 +1,8 @@
|
||||
set(BSP_COMMON_DIR ${CMAKE_SOURCE_DIR}/bsp/bsp_common)
|
||||
set(TARGET_REQUIRED_SRCS ${CMAKE_CURRENT_LIST_DIR}/ble_central_tp_client.c)
|
||||
set(TARGET_REQUIRED_LIBS ble "${CMAKE_SOURCE_DIR}/components/ble/blecontroller/lib/libblecontroller.a")
|
||||
set(mains main.c)
|
||||
set(LINKER_SCRIPT ${CMAKE_SOURCE_DIR}/examples/ble/bl702_flash_ble.ld)
|
||||
generate_bin()
|
||||
|
||||
|
325
examples/ble/ble_central/ble_central_tp_client.c
Normal file
325
examples/ble/ble_central/ble_central_tp_client.c
Normal file
@ -0,0 +1,325 @@
|
||||
/****************************************************************************
|
||||
FILE NAME
|
||||
ble_central_tp_client.c
|
||||
|
||||
DESCRIPTION
|
||||
test profile demo
|
||||
|
||||
NOTES
|
||||
*/
|
||||
/****************************************************************************/
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <FreeRTOS.h>
|
||||
#include <task.h>
|
||||
|
||||
#include "bluetooth.h"
|
||||
#include "conn.h"
|
||||
#include "gatt.h"
|
||||
#include "hci_core.h"
|
||||
#include "uuid.h"
|
||||
#include "ble_central_tp_client.h"
|
||||
#include "log.h"
|
||||
|
||||
static void ble_tp_connected(struct bt_conn *conn, u8_t err);
|
||||
static void ble_tp_disconnected(struct bt_conn *conn, u8_t reason);
|
||||
|
||||
struct bt_conn *ble_tp_conn;
|
||||
struct bt_gatt_exchange_params exchg_mtu;
|
||||
TaskHandle_t ble_write_data_task_h;
|
||||
|
||||
static struct bt_gatt_discover_params discover_params;
|
||||
static struct bt_gatt_subscribe_params subscribe_params;
|
||||
static struct tp_char_hdl char_hdl;
|
||||
struct k_sem write_data_poll_sem;
|
||||
|
||||
|
||||
int tx_mtu_size = 20;
|
||||
|
||||
static u8_t created_write_data_task = 0;
|
||||
static u8_t isRegister = 0;
|
||||
|
||||
static struct bt_conn_cb ble_tp_conn_callbacks = {
|
||||
.connected = ble_tp_connected,
|
||||
.disconnected = ble_tp_disconnected,
|
||||
};
|
||||
|
||||
static void ble_subscribe();
|
||||
static void ble_discover(u8_t type);
|
||||
|
||||
/*************************************************************************
|
||||
NAME
|
||||
notify_func(receive data from server)
|
||||
*/
|
||||
static u8_t notify_func(struct bt_conn *conn,
|
||||
struct bt_gatt_subscribe_params *params,
|
||||
const void *data, u16_t length)
|
||||
{
|
||||
static u32_t time = 0;
|
||||
static int len = 0;
|
||||
BT_WARN("notify_func complete \r\n");
|
||||
|
||||
if (!params->value) {
|
||||
BT_WARN("Unsubscribed\r\n");
|
||||
params->value_handle = 0U;
|
||||
return BT_GATT_ITER_STOP;
|
||||
}
|
||||
|
||||
if(!time){
|
||||
time = k_now_ms();
|
||||
}
|
||||
len += length;
|
||||
if(k_now_ms()- time >= 1000){
|
||||
BT_WARN("data_len=[%d]\r\n",len);
|
||||
time = k_now_ms();
|
||||
len = 0;
|
||||
}
|
||||
|
||||
BT_WARN("Notification: data length %u\r\n", length);
|
||||
if(length)
|
||||
{
|
||||
k_sem_give(&write_data_poll_sem);
|
||||
}
|
||||
return BT_GATT_ITER_CONTINUE;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
NAME
|
||||
ble_write_data_task(send data to server)
|
||||
*/
|
||||
static void ble_write_data_task(void *pvParameters)
|
||||
{
|
||||
int error;
|
||||
uint8_t buf[20] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19};
|
||||
while(1)
|
||||
{
|
||||
k_sem_take(&write_data_poll_sem, K_FOREVER);
|
||||
BT_WARN("ble_write_data\r\n");
|
||||
// Send data to server
|
||||
error = bt_gatt_write_without_response(ble_tp_conn,char_hdl.tp_wr_hdl,buf,20,0);
|
||||
BT_WARN("Write Complete (err %d)\r\n", error);
|
||||
}
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
NAME
|
||||
ble_subscribe
|
||||
*/
|
||||
static void ble_subscribe()
|
||||
{
|
||||
if (!ble_tp_conn) {
|
||||
BT_WARN("Not connected\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
subscribe_params.ccc_handle = char_hdl.tp_ccc_hdl;
|
||||
subscribe_params.value_handle = char_hdl.tp_notify_hdl;
|
||||
subscribe_params.value = 1;
|
||||
subscribe_params.notify = notify_func;
|
||||
|
||||
int err = bt_gatt_subscribe(ble_tp_conn, &subscribe_params);
|
||||
if (err) {
|
||||
BT_WARN("Subscribe failed (err %d)\r\n", err);
|
||||
} else {
|
||||
BT_WARN("Subscribed\r\n");
|
||||
}
|
||||
k_sem_init(&write_data_poll_sem, 0, 1);
|
||||
if(!created_write_data_task && (xTaskCreate(ble_write_data_task, (char*)"ble_write_data", 512, NULL, 15, &ble_write_data_task_h) == pdPASS))
|
||||
{
|
||||
created_write_data_task = 1;
|
||||
BT_WARN("Create write data task success .\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
created_write_data_task = 0;
|
||||
BT_WARN("Create write data taskfail .\n");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
NAME
|
||||
ble_discover_func
|
||||
*/
|
||||
static uint8_t ble_discover_func(struct bt_conn *conn, const struct bt_gatt_attr *attr, struct bt_gatt_discover_params *params)
|
||||
{
|
||||
struct bt_gatt_chrc *gatt_chrc;
|
||||
char str[37];
|
||||
BT_WARN( "ble_discover_func\r\n");
|
||||
if (!attr) {
|
||||
BT_WARN( "Discover complete\r\n");
|
||||
if(params->type!= BT_GATT_DISCOVER_DESCRIPTOR)
|
||||
{
|
||||
ble_discover(BT_GATT_DISCOVER_DESCRIPTOR);
|
||||
return BT_GATT_ITER_STOP;
|
||||
}
|
||||
(void)memset(params, 0, sizeof(*params));
|
||||
ble_subscribe();
|
||||
return BT_GATT_ITER_STOP;
|
||||
}
|
||||
if(params == NULL)
|
||||
{
|
||||
BT_WARN( "ble_discover_func_PARAMS\r\n");
|
||||
}
|
||||
switch (params->type) {
|
||||
case BT_GATT_DISCOVER_PRIMARY:
|
||||
break;
|
||||
|
||||
case BT_GATT_DISCOVER_SECONDARY:
|
||||
break;
|
||||
|
||||
case BT_GATT_DISCOVER_CHARACTERISTIC:
|
||||
gatt_chrc = attr->user_data;
|
||||
bt_uuid_to_str(gatt_chrc->uuid, str, sizeof(str));
|
||||
if(!bt_uuid_cmp(gatt_chrc->uuid, BT_UUID_CHAR_BLE_TP_RD)) {
|
||||
char_hdl.tp_rd_hdl= gatt_chrc->value_handle;
|
||||
BT_WARN("TP SERVICE, char_hdl.tp_rd_hdl: %d\n", char_hdl.tp_rd_hdl);
|
||||
}
|
||||
else if(!bt_uuid_cmp(gatt_chrc->uuid, BT_UUID_CHAR_BLE_TP_WR)) {
|
||||
char_hdl.tp_wr_hdl= gatt_chrc->value_handle;
|
||||
BT_WARN("TP SERVICE, char_hdl..tp_wr_hdl: %d\n", char_hdl.tp_wr_hdl);
|
||||
}
|
||||
else if(!bt_uuid_cmp(gatt_chrc->uuid, BT_UUID_CHAR_BLE_TP_IND)) {
|
||||
char_hdl.tp_ind_hdl= gatt_chrc->value_handle;
|
||||
BT_WARN("TP SERVICE, char_hdl.tp_ind_hdl: %d\n", char_hdl.tp_ind_hdl);
|
||||
}
|
||||
else if(!bt_uuid_cmp(gatt_chrc->uuid, BT_UUID_CHAR_BLE_TP_NOT))
|
||||
{
|
||||
char_hdl.tp_notify_hdl = gatt_chrc->value_handle;
|
||||
BT_WARN("TP SERVICE, char_hdl.tp_notify_hdl: %d\n", char_hdl.tp_notify_hdl);
|
||||
}
|
||||
break;
|
||||
|
||||
case BT_GATT_DISCOVER_INCLUDE:
|
||||
break;
|
||||
|
||||
case BT_GATT_DISCOVER_DESCRIPTOR:
|
||||
if(!bt_uuid_cmp(attr->uuid,BT_UUID_GATT_CCC))
|
||||
{
|
||||
char_hdl.tp_ccc_hdl = attr->handle;
|
||||
BT_WARN("TP SERVICE, char_hdl.tp_ccc_hdl: %d\n", char_hdl.tp_ccc_hdl);
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return BT_GATT_ITER_CONTINUE;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
NAME
|
||||
ble_discover
|
||||
*/
|
||||
static void ble_discover(u8_t type)
|
||||
{
|
||||
int err;
|
||||
|
||||
if (!ble_tp_conn) {
|
||||
return;
|
||||
}
|
||||
|
||||
discover_params.func = ble_discover_func;
|
||||
discover_params.start_handle = 0x0001;
|
||||
discover_params.end_handle = 0xffff;
|
||||
discover_params.type = type;
|
||||
discover_params.uuid = NULL;
|
||||
|
||||
err = bt_gatt_discover(ble_tp_conn, &discover_params);
|
||||
if (err) {
|
||||
BT_WARN("Discover failed (err %d)\r\n", err);
|
||||
} else {
|
||||
BT_WARN("Discover pending\r\n");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
NAME
|
||||
ble_tp_tx_mtu_size
|
||||
*/
|
||||
static void ble_tp_tx_mtu_size(struct bt_conn *conn, u8_t err,
|
||||
struct bt_gatt_exchange_params *params)
|
||||
{
|
||||
if(!err)
|
||||
{
|
||||
tx_mtu_size = bt_gatt_get_mtu(ble_tp_conn);
|
||||
BT_WARN("ble tp echange mtu size success, mtu size: %d\n", tx_mtu_size);
|
||||
}
|
||||
else
|
||||
{
|
||||
BT_WARN("ble tp echange mtu size failure, err: %d\n", err);
|
||||
}
|
||||
ble_discover( BT_GATT_DISCOVER_CHARACTERISTIC);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
NAME
|
||||
ble_tp_connected
|
||||
*/
|
||||
static void ble_tp_connected(struct bt_conn *conn, u8_t err)
|
||||
{
|
||||
int tx_octets = 0x00fb;
|
||||
int tx_time = 0x0848;
|
||||
int ret = -1;
|
||||
|
||||
if( err )
|
||||
return;
|
||||
BT_WARN("%s\n",__func__);
|
||||
ble_tp_conn = conn;
|
||||
|
||||
//set data length after connected.
|
||||
ret = bt_le_set_data_len(ble_tp_conn, tx_octets, tx_time);
|
||||
if(!ret)
|
||||
{
|
||||
BT_WARN("ble tp set data length success.\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
BT_WARN("ble tp set data length failure, err: %d\n", ret);
|
||||
}
|
||||
|
||||
//exchange mtu size after connected.
|
||||
exchg_mtu.func = ble_tp_tx_mtu_size;
|
||||
ret = bt_gatt_exchange_mtu(ble_tp_conn, &exchg_mtu);
|
||||
if (!ret) {
|
||||
BT_WARN("ble tp exchange mtu size pending.\n");
|
||||
} else {
|
||||
BT_WARN("ble tp exchange mtu size failure, err: %d\n", ret);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
NAME
|
||||
ble_tp_disconnected
|
||||
*/
|
||||
static void ble_tp_disconnected(struct bt_conn *conn, u8_t reason)
|
||||
{
|
||||
BT_WARN("%s\n",__func__);
|
||||
ble_tp_conn = NULL;
|
||||
if(created_write_data_task)
|
||||
{
|
||||
BT_WARN("Delete write data task .\n");
|
||||
vTaskDelete(ble_write_data_task_h);
|
||||
created_write_data_task = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
NAME
|
||||
ble_tp_init
|
||||
*/
|
||||
void ble_tp_init()
|
||||
{
|
||||
if( !isRegister )
|
||||
{
|
||||
isRegister = 1;
|
||||
bt_conn_cb_register(&ble_tp_conn_callbacks);
|
||||
}
|
||||
}
|
48
examples/ble/ble_central/ble_central_tp_client.h
Normal file
48
examples/ble/ble_central/ble_central_tp_client.h
Normal file
@ -0,0 +1,48 @@
|
||||
/****************************************************************************
|
||||
FILE NAME
|
||||
ble_central_tp_client.h
|
||||
|
||||
DESCRIPTION
|
||||
NOTES
|
||||
*/
|
||||
/****************************************************************************/
|
||||
|
||||
#ifndef _BLE_TP_SVC_H_
|
||||
#define _BLE_TP_SVC_H_
|
||||
|
||||
#include "config.h"
|
||||
|
||||
struct tp_char_hdl
|
||||
{
|
||||
uint16_t tp_rd_hdl;
|
||||
uint16_t tp_wr_hdl;
|
||||
uint16_t tp_ind_hdl;
|
||||
uint16_t tp_notify_hdl;
|
||||
uint16_t tp_ccc_hdl;
|
||||
//struct hids_rpt_hdl rpt_hdl[7];
|
||||
}__packed;
|
||||
|
||||
|
||||
//07af27a5-9c22-11ea-9afe-02fcdc4e7412
|
||||
#define BT_UUID_SVC_BLE_TP BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0x07af27a5, 0x9c22, 0x11ea, 0x9afe, 0x02fcdc4e7412))
|
||||
//07af27a6-9c22-11ea-9afe-02fcdc4e7412
|
||||
#define BT_UUID_CHAR_BLE_TP_RD BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0x07af27a6, 0x9c22, 0x11ea, 0x9afe, 0x02fcdc4e7412))
|
||||
//07af27a7-9c22-11ea-9afe-02fcdc4e7412
|
||||
#define BT_UUID_CHAR_BLE_TP_WR BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0x07af27a7, 0x9c22, 0x11ea, 0x9afe, 0x02fcdc4e7412))
|
||||
//07af27a8-9c22-11ea-9afe-02fcdc4e7412
|
||||
#define BT_UUID_CHAR_BLE_TP_IND BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0x07af27a8, 0x9c22, 0x11ea, 0x9afe, 0x02fcdc4e7412))
|
||||
//07af27a9-9c22-11ea-9afe-02fcdc4e7412
|
||||
#define BT_UUID_CHAR_BLE_TP_NOT BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0x07af27a9, 0x9c22, 0x11ea, 0x9afe, 0x02fcdc4e7412))
|
||||
|
||||
//read value handle offset 2
|
||||
#define BT_CHAR_BLE_TP_RD_ATTR_VAL_INDEX (2)
|
||||
//write value handle offset 4
|
||||
#define BT_CHAR_BLE_TP_WR_ATTR_VAL_INDEX (4)
|
||||
//indicate value handle offset 6
|
||||
#define BT_CHAR_BLE_TP_IND_ATTR_VAL_INDEX (6)
|
||||
//notity value handle offset 9
|
||||
#define BT_CHAR_BLE_TP_NOT_ATTR_VAL_INDEX (9)
|
||||
|
||||
void ble_tp_init();
|
||||
#endif
|
||||
|
279
examples/ble/ble_central/main.c
Normal file
279
examples/ble/ble_central/main.c
Normal file
@ -0,0 +1,279 @@
|
||||
/**
|
||||
* @file main.c
|
||||
* @brief
|
||||
*
|
||||
* Copyright (c) 2021 Bouffalolab team
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
#include "hal_uart.h"
|
||||
#include <FreeRTOS.h>
|
||||
#include "semphr.h"
|
||||
#include "bluetooth.h"
|
||||
#include "gap.h"
|
||||
#include "bl702_glb.h"
|
||||
#include "ble_central_tp_client.h"
|
||||
#include "conn.h"
|
||||
#include "log.h"
|
||||
|
||||
#define NAME_LEN 30
|
||||
|
||||
extern uint8_t _heap_start;
|
||||
extern uint8_t _heap_size; // @suppress("Type cannot be resolved")
|
||||
static HeapRegion_t xHeapRegions[] =
|
||||
{
|
||||
{ &_heap_start, (unsigned int) &_heap_size },
|
||||
{ NULL, 0 }, /* Terminates the array. */
|
||||
{ NULL, 0 } /* Terminates the array. */
|
||||
};
|
||||
|
||||
uint8_t sharedBuf[16];
|
||||
|
||||
extern void ble_controller_init(uint8_t task_priority);
|
||||
#if defined(BFLB_BLE)
|
||||
extern int hci_driver_init(void);
|
||||
#endif
|
||||
|
||||
void user_vAssertCalled(void) __attribute__ ((weak, alias ("vAssertCalled")));
|
||||
void vAssertCalled(void)
|
||||
{
|
||||
MSG("vAssertCalled\r\n");
|
||||
while( 1 );
|
||||
}
|
||||
|
||||
void vApplicationTickHook(void)
|
||||
{
|
||||
//MSG("vApplicationTickHook\r\n");
|
||||
}
|
||||
|
||||
void vApplicationStackOverflowHook(TaskHandle_t xTask, char *pcTaskName )
|
||||
{
|
||||
MSG("vApplicationStackOverflowHook\r\n");
|
||||
if(pcTaskName){
|
||||
MSG("Stack name %s\r\n", pcTaskName);
|
||||
}
|
||||
while( 1 );
|
||||
}
|
||||
|
||||
void vApplicationMallocFailedHook(void)
|
||||
{
|
||||
MSG("vApplicationMallocFailedHook\r\n");
|
||||
while( 1 );
|
||||
}
|
||||
void vApplicationGetIdleTaskMemory(StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize)
|
||||
{
|
||||
/* If the buffers to be provided to the Idle task are declared inside this
|
||||
function then they must be declared static - otherwise they will be allocated on
|
||||
the stack and so not exists after this function exits. */
|
||||
static StaticTask_t xIdleTaskTCB;
|
||||
static StackType_t uxIdleTaskStack[ configMINIMAL_STACK_SIZE ];
|
||||
|
||||
/* Pass out a pointer to the StaticTask_t structure in which the Idle task's
|
||||
state will be stored. */
|
||||
*ppxIdleTaskTCBBuffer = &xIdleTaskTCB;
|
||||
|
||||
/* Pass out the array that will be used as the Idle task's stack. */
|
||||
*ppxIdleTaskStackBuffer = uxIdleTaskStack;
|
||||
|
||||
/* Pass out the size of the array pointed to by *ppxIdleTaskStackBuffer.
|
||||
Note that, as the array is necessarily of type StackType_t,
|
||||
configMINIMAL_STACK_SIZE is specified in words, not bytes. */
|
||||
*pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;
|
||||
}
|
||||
|
||||
/* configSUPPORT_STATIC_ALLOCATION and configUSE_TIMERS are both set to 1, so the
|
||||
application must provide an implementation of vApplicationGetTimerTaskMemory()
|
||||
to provide the memory that is used by the Timer service task. */
|
||||
void vApplicationGetTimerTaskMemory(StaticTask_t **ppxTimerTaskTCBBuffer, StackType_t **ppxTimerTaskStackBuffer, uint32_t *pulTimerTaskStackSize)
|
||||
{
|
||||
/* If the buffers to be provided to the Timer task are declared inside this
|
||||
function then they must be declared static - otherwise they will be allocated on
|
||||
the stack and so not exists after this function exits. */
|
||||
static StaticTask_t xTimerTaskTCB;
|
||||
static StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ];
|
||||
|
||||
/* Pass out a pointer to the StaticTask_t structure in which the Timer
|
||||
task's state will be stored. */
|
||||
*ppxTimerTaskTCBBuffer = &xTimerTaskTCB;
|
||||
|
||||
/* Pass out the array that will be used as the Timer task's stack. */
|
||||
*ppxTimerTaskStackBuffer = uxTimerTaskStack;
|
||||
|
||||
/* Pass out the size of the array pointed to by *ppxTimerTaskStackBuffer.
|
||||
Note that, as the array is necessarily of type StackType_t,
|
||||
configTIMER_TASK_STACK_DEPTH is specified in words, not bytes. */
|
||||
*pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
NAME
|
||||
data_cb
|
||||
*/
|
||||
static bool data_cb(struct bt_data *data, void *user_data)
|
||||
{
|
||||
char *name = user_data;
|
||||
u8_t len;
|
||||
|
||||
switch (data->type) {
|
||||
case BT_DATA_NAME_SHORTENED:
|
||||
case BT_DATA_NAME_COMPLETE:
|
||||
len = (data->data_len > NAME_LEN - 1)?(NAME_LEN - 1):(data->data_len);
|
||||
memcpy(name, data->data, len);
|
||||
return false;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
NAME
|
||||
device_found
|
||||
*/
|
||||
|
||||
static void device_found(const bt_addr_le_t *addr, s8_t rssi, u8_t evtype,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
char le_addr[BT_ADDR_LE_STR_LEN];
|
||||
char name[30];
|
||||
int err;
|
||||
char *adv_name = "BL_TEST_01"; //This name must be the same as adv_name in ble_central
|
||||
|
||||
(void)memset(name, 0, sizeof(name));
|
||||
bt_data_parse(buf, data_cb, name);
|
||||
bt_addr_le_to_str(addr, le_addr, sizeof(le_addr));
|
||||
|
||||
BT_WARN("[DEVICE]: %s, AD evt type %u, RSSI %i %s \r\n",le_addr, evtype, rssi, name);
|
||||
if(strcmp(name,adv_name) == 0)
|
||||
{
|
||||
struct bt_conn *conn;
|
||||
struct bt_le_conn_param param = {
|
||||
.interval_min = BT_GAP_INIT_CONN_INT_MIN,\
|
||||
.interval_max = BT_GAP_INIT_CONN_INT_MAX,\
|
||||
.latency = 0,\
|
||||
.timeout = 400,\
|
||||
};
|
||||
err = bt_le_scan_stop();
|
||||
if (err) {
|
||||
BT_WARN("Stopping scanning failed (err %d)\r\n", err);
|
||||
} else {
|
||||
BT_WARN("Scan successfully stopped \r\n");
|
||||
}
|
||||
conn = bt_conn_create_le(addr, ¶m);
|
||||
if(!conn) {
|
||||
BT_WARN("Connection failed\r\n");
|
||||
}else{
|
||||
BT_WARN("Connection pending\r\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
NAME
|
||||
ble_start_scan
|
||||
*/
|
||||
static void ble_start_scan(void)
|
||||
{
|
||||
int err;
|
||||
struct bt_le_scan_param scan_param = {
|
||||
.type = 0, \
|
||||
.filter_dup = 1,\
|
||||
.interval = BT_GAP_SCAN_FAST_INTERVAL, \
|
||||
.window = BT_GAP_SCAN_FAST_WINDOW, \
|
||||
};
|
||||
err = bt_le_scan_start(&scan_param, device_found);
|
||||
if(err){
|
||||
BT_WARN("Failed to start scan (err %d) \r\n", err);
|
||||
}else{
|
||||
BT_WARN("Start scan successfully \r\n");
|
||||
}
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
NAME
|
||||
bt_enable_cb
|
||||
*/
|
||||
|
||||
static void bt_enable_cb(int err)
|
||||
{
|
||||
|
||||
ble_tp_init();
|
||||
ble_start_scan();
|
||||
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
NAME
|
||||
ble_stack_start
|
||||
*/
|
||||
void ble_stack_start(void)
|
||||
{
|
||||
|
||||
GLB_Set_EM_Sel(GLB_EM_8KB);
|
||||
|
||||
// Initialize BLE controller
|
||||
MSG("[OS] ble_controller_init...\r\n");
|
||||
ble_controller_init(configMAX_PRIORITIES - 1);
|
||||
|
||||
// Initialize BLE Host stack
|
||||
MSG("[OS] hci_driver_init...\r\n");
|
||||
|
||||
hci_driver_init();
|
||||
|
||||
MSG("[OS] bt_enable...\r\n");
|
||||
bt_enable(bt_enable_cb);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
NAME
|
||||
ble_init
|
||||
*/
|
||||
void ble_init(void)
|
||||
{
|
||||
extern void ble_stack_start(void);
|
||||
ble_stack_start();
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
NAME
|
||||
ble_init_task
|
||||
*/
|
||||
static void ble_init_task(void *pvParameters)
|
||||
{
|
||||
ble_init();
|
||||
vTaskDelete(NULL);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
static StackType_t ble_init_stack[1024];
|
||||
static StaticTask_t ble_init_task_h;
|
||||
|
||||
bflb_platform_init(0);
|
||||
HBN_Set_XCLK_CLK_Sel(HBN_XCLK_CLK_XTAL);
|
||||
GLB_Set_MTimer_CLK(1, GLB_MTIMER_CLK_BCLK, 17);
|
||||
|
||||
vPortDefineHeapRegions(xHeapRegions);
|
||||
|
||||
MSG("[OS] ble init task...\r\n");
|
||||
xTaskCreateStatic(ble_init_task, (char*)"ble_init", sizeof(ble_init_stack)/4, NULL, 15, ble_init_stack, &ble_init_task_h);
|
||||
|
||||
vTaskStartScheduler();
|
||||
while(1)
|
||||
{
|
||||
}
|
||||
}
|
8
examples/ble/ble_peripheral/CMakeLists.txt
Normal file
8
examples/ble/ble_peripheral/CMakeLists.txt
Normal file
@ -0,0 +1,8 @@
|
||||
set(BSP_COMMON_DIR ${CMAKE_SOURCE_DIR}/bsp/bsp_common)
|
||||
set(TARGET_REQUIRED_SRCS ${CMAKE_CURRENT_LIST_DIR}/ble_peripheral_tp_server.c)
|
||||
set(TARGET_REQUIRED_LIBS ble "${CMAKE_SOURCE_DIR}/components/ble/blecontroller/lib/libblecontroller.a")
|
||||
set(mains main.c)
|
||||
set(LINKER_SCRIPT ${CMAKE_SOURCE_DIR}/examples/ble/bl702_flash_ble.ld)
|
||||
generate_bin()
|
||||
|
||||
|
324
examples/ble/ble_peripheral/ble_peripheral_tp_server.c
Normal file
324
examples/ble/ble_peripheral/ble_peripheral_tp_server.c
Normal file
@ -0,0 +1,324 @@
|
||||
/****************************************************************************
|
||||
FILE NAME
|
||||
ble_peripheral_tp_server.c
|
||||
|
||||
DESCRIPTION
|
||||
test profile demo
|
||||
|
||||
NOTES
|
||||
*/
|
||||
/****************************************************************************/
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <FreeRTOS.h>
|
||||
#include <task.h>
|
||||
|
||||
#include "bluetooth.h"
|
||||
#include "conn.h"
|
||||
#include "gatt.h"
|
||||
#include "hci_core.h"
|
||||
#include "uuid.h"
|
||||
#include "ble_peripheral_tp_server.h"
|
||||
#include "log.h"
|
||||
|
||||
static void ble_tp_connected(struct bt_conn *conn, u8_t err);
|
||||
static void ble_tp_disconnected(struct bt_conn *conn, u8_t reason);
|
||||
|
||||
struct bt_conn *ble_tp_conn;
|
||||
struct bt_gatt_exchange_params exchg_mtu;
|
||||
TaskHandle_t ble_tp_task_h;
|
||||
|
||||
struct k_sem notify_poll_sem;
|
||||
|
||||
|
||||
int tx_mtu_size = 20;
|
||||
u8_t tp_start = 0;
|
||||
static u8_t created_tp_task = 0;
|
||||
static u8_t isRegister = 0;
|
||||
|
||||
static struct bt_conn_cb ble_tp_conn_callbacks = {
|
||||
.connected = ble_tp_connected,
|
||||
.disconnected = ble_tp_disconnected,
|
||||
};
|
||||
|
||||
/*************************************************************************
|
||||
NAME
|
||||
ble_tp_tx_mtu_size
|
||||
*/
|
||||
static void ble_tp_tx_mtu_size(struct bt_conn *conn, u8_t err,
|
||||
struct bt_gatt_exchange_params *params)
|
||||
{
|
||||
if(!err)
|
||||
{
|
||||
tx_mtu_size = bt_gatt_get_mtu(ble_tp_conn);
|
||||
BT_WARN("ble tp echange mtu size success, mtu size: %d\n", tx_mtu_size);
|
||||
}
|
||||
else
|
||||
{
|
||||
BT_WARN("ble tp echange mtu size failure, err: %d\n", err);
|
||||
}
|
||||
//ble_write_data();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
NAME
|
||||
ble_tp_connected
|
||||
*/
|
||||
static void ble_tp_connected(struct bt_conn *conn, u8_t err)
|
||||
{
|
||||
int tx_octets = 0x00fb;
|
||||
int tx_time = 0x0848;
|
||||
int ret = -1;
|
||||
|
||||
if( err )
|
||||
return;
|
||||
|
||||
BT_WARN("%s\n",__func__);
|
||||
ble_tp_conn = conn;
|
||||
|
||||
//set data length after connected.
|
||||
ret = bt_le_set_data_len(ble_tp_conn, tx_octets, tx_time);
|
||||
if(!ret)
|
||||
{
|
||||
BT_WARN("ble tp set data length success.\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
BT_WARN("ble tp set data length failure, err: %d\n", ret);
|
||||
}
|
||||
|
||||
//exchange mtu size after connected.
|
||||
exchg_mtu.func = ble_tp_tx_mtu_size;
|
||||
ret = bt_gatt_exchange_mtu(ble_tp_conn, &exchg_mtu);
|
||||
if (!ret) {
|
||||
BT_WARN("ble tp exchange mtu size pending.\n");
|
||||
} else {
|
||||
BT_WARN("ble tp exchange mtu size failure, err: %d\n", ret);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
NAME
|
||||
ble_tp_disconnected
|
||||
*/
|
||||
static void ble_tp_disconnected(struct bt_conn *conn, u8_t reason)
|
||||
{
|
||||
BT_WARN("%s\n",__func__);
|
||||
if(created_tp_task){
|
||||
BT_WARN("Delete throughput tx task .\n");
|
||||
vTaskDelete(ble_tp_task_h);
|
||||
created_tp_task = 0;
|
||||
}
|
||||
|
||||
ble_tp_conn = NULL;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
NAME
|
||||
ble_tp_recv_rd
|
||||
*/
|
||||
static int ble_tp_recv_rd(struct bt_conn *conn, const struct bt_gatt_attr *attr,
|
||||
void *buf, u16_t len, u16_t offset)
|
||||
{
|
||||
int size = 9;
|
||||
char data[9] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09};
|
||||
|
||||
memcpy(buf, data, size);
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
NAME
|
||||
ble_tp_recv_wr(receive data from client)
|
||||
*/
|
||||
static int ble_tp_recv_wr(struct bt_conn *conn, const struct bt_gatt_attr *attr,
|
||||
const void *buf, u16_t len, u16_t offset, u8_t flags)
|
||||
{
|
||||
BT_WARN("recv data len=%d, offset=%d, flag=%d\r\n", len, offset, flags);
|
||||
|
||||
if (flags & BT_GATT_WRITE_FLAG_PREPARE)
|
||||
{
|
||||
//Don't use prepare write data, execute write will upload data again.
|
||||
BT_WARN("rcv prepare write request\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(flags & BT_GATT_WRITE_FLAG_CMD)
|
||||
{
|
||||
//Use write command data.
|
||||
BT_WARN("rcv write command\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
//Use write request / execute write data.
|
||||
BT_WARN("rcv write request / exce write\n");
|
||||
}
|
||||
k_sem_give(¬ify_poll_sem);
|
||||
return len;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
NAME
|
||||
indicate_rsp /bl_tp_send_indicate
|
||||
*/
|
||||
|
||||
void indicate_rsp(struct bt_conn *conn, const struct bt_gatt_attr *attr, u8_t err)
|
||||
{
|
||||
BT_WARN("%s, receive comfirmation, err:%d\n", __func__, err);
|
||||
}
|
||||
|
||||
static int bl_tp_send_indicate(struct bt_conn *conn, const struct bt_gatt_attr *attr,
|
||||
const void *data, u16_t len)
|
||||
{
|
||||
static struct bt_gatt_indicate_params ind_params;
|
||||
|
||||
ind_params.attr = attr;
|
||||
ind_params.data = data;
|
||||
ind_params.len = len;
|
||||
ind_params.func = indicate_rsp;
|
||||
ind_params.uuid = NULL;
|
||||
|
||||
return bt_gatt_indicate(conn, &ind_params);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
NAME
|
||||
ble_tp_ind_ccc_changed
|
||||
*/
|
||||
static void ble_tp_ind_ccc_changed(const struct bt_gatt_attr *attr, u16_t value)
|
||||
{
|
||||
int err = -1;
|
||||
char data[9] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09};
|
||||
|
||||
if(value == BT_GATT_CCC_INDICATE) {
|
||||
err = bl_tp_send_indicate(ble_tp_conn, get_attr(BT_CHAR_BLE_TP_IND_ATTR_VAL_INDEX), data, 9);
|
||||
BT_WARN("ble tp send indatcate: %d\n", err);
|
||||
}
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
NAME
|
||||
ble_tp_notify(send data to client)
|
||||
*/
|
||||
static void ble_tp_notify_task(void *pvParameters)
|
||||
{
|
||||
int err = -1;
|
||||
char data[244] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09};
|
||||
k_sem_give(¬ify_poll_sem);
|
||||
while(1)
|
||||
{
|
||||
k_sem_take(¬ify_poll_sem, K_FOREVER);
|
||||
//send data to client
|
||||
err = bt_gatt_notify(ble_tp_conn, get_attr(BT_CHAR_BLE_TP_NOT_ATTR_VAL_INDEX), data, (tx_mtu_size - 3));
|
||||
BT_WARN("ble tp send notify : %d\n", err);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
NAME
|
||||
ble_tp_not_ccc_changed
|
||||
*/
|
||||
static void ble_tp_not_ccc_changed(const struct bt_gatt_attr *attr, u16_t value)
|
||||
{
|
||||
BT_WARN("ccc:value=[%d]\r\n",value);
|
||||
|
||||
if(value == BT_GATT_CCC_NOTIFY) {
|
||||
k_sem_init(¬ify_poll_sem, 0, 1);
|
||||
if(xTaskCreate(ble_tp_notify_task, (char*)"bletp", 512, NULL, 15, &ble_tp_task_h) == pdPASS)
|
||||
{
|
||||
created_tp_task = 1;
|
||||
BT_WARN("Create throughput tx task success .\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
created_tp_task = 0;
|
||||
BT_WARN("Create throughput tx taskfail .\n");
|
||||
}
|
||||
} else {
|
||||
|
||||
if(created_tp_task){
|
||||
BT_WARN("Delete throughput tx task .\n");
|
||||
vTaskDelete(ble_tp_task_h);
|
||||
created_tp_task = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* DEFINE : attrs
|
||||
*/
|
||||
static struct bt_gatt_attr attrs[]= {
|
||||
BT_GATT_PRIMARY_SERVICE(BT_UUID_SVC_BLE_TP),
|
||||
|
||||
BT_GATT_CHARACTERISTIC(BT_UUID_CHAR_BLE_TP_RD,
|
||||
BT_GATT_CHRC_READ,
|
||||
BT_GATT_PERM_READ,
|
||||
ble_tp_recv_rd,
|
||||
NULL,
|
||||
NULL),
|
||||
|
||||
BT_GATT_CHARACTERISTIC(BT_UUID_CHAR_BLE_TP_WR,
|
||||
BT_GATT_CHRC_WRITE |BT_GATT_CHRC_WRITE_WITHOUT_RESP,
|
||||
BT_GATT_PERM_WRITE|BT_GATT_PERM_PREPARE_WRITE,
|
||||
NULL,
|
||||
ble_tp_recv_wr,
|
||||
NULL),
|
||||
|
||||
BT_GATT_CHARACTERISTIC(BT_UUID_CHAR_BLE_TP_IND,
|
||||
BT_GATT_CHRC_INDICATE,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL),
|
||||
|
||||
BT_GATT_CCC(ble_tp_ind_ccc_changed, BT_GATT_PERM_READ | BT_GATT_PERM_WRITE),
|
||||
|
||||
BT_GATT_CHARACTERISTIC(BT_UUID_CHAR_BLE_TP_NOT,
|
||||
BT_GATT_CHRC_NOTIFY,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL),
|
||||
|
||||
BT_GATT_CCC(ble_tp_not_ccc_changed, BT_GATT_PERM_READ | BT_GATT_PERM_WRITE)
|
||||
|
||||
};
|
||||
|
||||
/*************************************************************************
|
||||
NAME
|
||||
get_attr
|
||||
*/
|
||||
struct bt_gatt_attr *get_attr(u8_t index)
|
||||
{
|
||||
return &attrs[index];
|
||||
}
|
||||
|
||||
struct bt_gatt_service ble_tp_server = BT_GATT_SERVICE(attrs);
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
NAME
|
||||
ble_tp_init
|
||||
*/
|
||||
void ble_tp_init()
|
||||
{
|
||||
if( !isRegister )
|
||||
{
|
||||
isRegister = 1;
|
||||
bt_conn_cb_register(&ble_tp_conn_callbacks);
|
||||
bt_gatt_service_register(&ble_tp_server);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
41
examples/ble/ble_peripheral/ble_peripheral_tp_server.h
Normal file
41
examples/ble/ble_peripheral/ble_peripheral_tp_server.h
Normal file
@ -0,0 +1,41 @@
|
||||
/****************************************************************************
|
||||
FILE NAME
|
||||
ble_peripheral_tp_server.h
|
||||
|
||||
DESCRIPTION
|
||||
NOTES
|
||||
*/
|
||||
/****************************************************************************/
|
||||
|
||||
#ifndef _BLE_TP_SVC_H_
|
||||
#define _BLE_TP_SVC_H_
|
||||
|
||||
#include "config.h"
|
||||
|
||||
//07af27a5-9c22-11ea-9afe-02fcdc4e7412
|
||||
#define BT_UUID_SVC_BLE_TP BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0x07af27a5, 0x9c22, 0x11ea, 0x9afe, 0x02fcdc4e7412))
|
||||
//07af27a6-9c22-11ea-9afe-02fcdc4e7412
|
||||
#define BT_UUID_CHAR_BLE_TP_RD BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0x07af27a6, 0x9c22, 0x11ea, 0x9afe, 0x02fcdc4e7412))
|
||||
//07af27a7-9c22-11ea-9afe-02fcdc4e7412
|
||||
#define BT_UUID_CHAR_BLE_TP_WR BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0x07af27a7, 0x9c22, 0x11ea, 0x9afe, 0x02fcdc4e7412))
|
||||
//07af27a8-9c22-11ea-9afe-02fcdc4e7412
|
||||
#define BT_UUID_CHAR_BLE_TP_IND BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0x07af27a8, 0x9c22, 0x11ea, 0x9afe, 0x02fcdc4e7412))
|
||||
//07af27a9-9c22-11ea-9afe-02fcdc4e7412
|
||||
#define BT_UUID_CHAR_BLE_TP_NOT BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0x07af27a9, 0x9c22, 0x11ea, 0x9afe, 0x02fcdc4e7412))
|
||||
|
||||
//read value handle offset 2
|
||||
#define BT_CHAR_BLE_TP_RD_ATTR_VAL_INDEX (2)
|
||||
//write value handle offset 4
|
||||
#define BT_CHAR_BLE_TP_WR_ATTR_VAL_INDEX (4)
|
||||
//indicate value handle offset 6
|
||||
#define BT_CHAR_BLE_TP_IND_ATTR_VAL_INDEX (6)
|
||||
//notity value handle offset 9
|
||||
#define BT_CHAR_BLE_TP_NOT_ATTR_VAL_INDEX (9)
|
||||
|
||||
void ble_tp_init();
|
||||
struct bt_gatt_attr *get_attr(u8_t index);
|
||||
void ble_write_data(void);
|
||||
|
||||
|
||||
#endif
|
||||
|
195
examples/ble/ble_peripheral/main.c
Normal file
195
examples/ble/ble_peripheral/main.c
Normal file
@ -0,0 +1,195 @@
|
||||
/**
|
||||
* @file main.c
|
||||
* @brief
|
||||
*
|
||||
* Copyright (c) 2021 Bouffalolab team
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
#include "hal_uart.h"
|
||||
#include <FreeRTOS.h>
|
||||
#include "semphr.h"
|
||||
#include "bluetooth.h"
|
||||
#include "gap.h"
|
||||
#include "bl702_glb.h"
|
||||
#include "ble_peripheral_tp_server.h"
|
||||
|
||||
extern uint8_t _heap_start;
|
||||
extern uint8_t _heap_size; // @suppress("Type cannot be resolved")
|
||||
static HeapRegion_t xHeapRegions[] =
|
||||
{
|
||||
{ &_heap_start, (unsigned int) &_heap_size },
|
||||
{ NULL, 0 }, /* Terminates the array. */
|
||||
{ NULL, 0 } /* Terminates the array. */
|
||||
};
|
||||
|
||||
uint8_t sharedBuf[16];
|
||||
void user_vAssertCalled(void) __attribute__ ((weak, alias ("vAssertCalled")));
|
||||
void vAssertCalled(void)
|
||||
{
|
||||
MSG("vAssertCalled\r\n");
|
||||
while( 1 );
|
||||
}
|
||||
|
||||
void vApplicationTickHook(void)
|
||||
{
|
||||
//MSG("vApplicationTickHook\r\n");
|
||||
}
|
||||
|
||||
void vApplicationStackOverflowHook(TaskHandle_t xTask, char *pcTaskName )
|
||||
{
|
||||
MSG("vApplicationStackOverflowHook\r\n");
|
||||
if(pcTaskName){
|
||||
MSG("Stack name %s\r\n", pcTaskName);
|
||||
}
|
||||
while( 1 );
|
||||
}
|
||||
|
||||
void vApplicationMallocFailedHook(void)
|
||||
{
|
||||
MSG("vApplicationMallocFailedHook\r\n");
|
||||
while( 1 );
|
||||
}
|
||||
void vApplicationGetIdleTaskMemory(StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize)
|
||||
{
|
||||
/* If the buffers to be provided to the Idle task are declared inside this
|
||||
function then they must be declared static - otherwise they will be allocated on
|
||||
the stack and so not exists after this function exits. */
|
||||
static StaticTask_t xIdleTaskTCB;
|
||||
static StackType_t uxIdleTaskStack[ configMINIMAL_STACK_SIZE ];
|
||||
|
||||
/* Pass out a pointer to the StaticTask_t structure in which the Idle task's
|
||||
state will be stored. */
|
||||
*ppxIdleTaskTCBBuffer = &xIdleTaskTCB;
|
||||
|
||||
/* Pass out the array that will be used as the Idle task's stack. */
|
||||
*ppxIdleTaskStackBuffer = uxIdleTaskStack;
|
||||
|
||||
/* Pass out the size of the array pointed to by *ppxIdleTaskStackBuffer.
|
||||
Note that, as the array is necessarily of type StackType_t,
|
||||
configMINIMAL_STACK_SIZE is specified in words, not bytes. */
|
||||
*pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;
|
||||
}
|
||||
|
||||
/* configSUPPORT_STATIC_ALLOCATION and configUSE_TIMERS are both set to 1, so the
|
||||
application must provide an implementation of vApplicationGetTimerTaskMemory()
|
||||
to provide the memory that is used by the Timer service task. */
|
||||
void vApplicationGetTimerTaskMemory(StaticTask_t **ppxTimerTaskTCBBuffer, StackType_t **ppxTimerTaskStackBuffer, uint32_t *pulTimerTaskStackSize)
|
||||
{
|
||||
/* If the buffers to be provided to the Timer task are declared inside this
|
||||
function then they must be declared static - otherwise they will be allocated on
|
||||
the stack and so not exists after this function exits. */
|
||||
static StaticTask_t xTimerTaskTCB;
|
||||
static StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ];
|
||||
|
||||
/* Pass out a pointer to the StaticTask_t structure in which the Timer
|
||||
task's state will be stored. */
|
||||
*ppxTimerTaskTCBBuffer = &xTimerTaskTCB;
|
||||
|
||||
/* Pass out the array that will be used as the Timer task's stack. */
|
||||
*ppxTimerTaskStackBuffer = uxTimerTaskStack;
|
||||
|
||||
/* Pass out the size of the array pointed to by *ppxTimerTaskStackBuffer.
|
||||
Note that, as the array is necessarily of type StackType_t,
|
||||
configTIMER_TASK_STACK_DEPTH is specified in words, not bytes. */
|
||||
*pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;
|
||||
}
|
||||
|
||||
int ble_start_adv(void)
|
||||
{
|
||||
struct bt_le_adv_param adv_param = {
|
||||
//options:3, connectable undirected, adv one time
|
||||
.options = 3, \
|
||||
.interval_min = BT_GAP_ADV_FAST_INT_MIN_3, \
|
||||
.interval_max = BT_GAP_ADV_FAST_INT_MAX_3, \
|
||||
};
|
||||
|
||||
|
||||
char *adv_name = "BL_TEST_01"; // This name must be the same as adv_name in ble_central
|
||||
uint8_t data[1] = {(BT_LE_AD_LIMITED | BT_LE_AD_NO_BREDR)};
|
||||
uint8_t data_uuid[2] = {0x12, 0x18};//0x1812
|
||||
uint8_t data_appearance[2] = {0x80, 0x01};//0x0180
|
||||
uint8_t data_manu[4] = {0x71, 0x01, 0x04, 0x13};
|
||||
struct bt_data adv_data[] = {
|
||||
BT_DATA(BT_DATA_FLAGS, data, 1),
|
||||
BT_DATA(BT_DATA_UUID16_ALL, data_uuid, sizeof(data_uuid)),
|
||||
BT_DATA(BT_DATA_GAP_APPEARANCE, data_appearance, sizeof(data_appearance)),
|
||||
BT_DATA(BT_DATA_NAME_COMPLETE, adv_name, strlen(adv_name)),
|
||||
BT_DATA(BT_DATA_MANUFACTURER_DATA, data_manu, sizeof(data_manu))
|
||||
};
|
||||
|
||||
|
||||
return bt_le_adv_start(&adv_param, adv_data, ARRAY_SIZE(adv_data), NULL, 0);
|
||||
}
|
||||
|
||||
void bt_enable_cb(int err)
|
||||
{
|
||||
ble_tp_init();
|
||||
ble_start_adv();
|
||||
}
|
||||
extern void ble_controller_init(uint8_t task_priority);
|
||||
#if defined(BFLB_BLE)
|
||||
extern int hci_driver_init(void);
|
||||
#endif
|
||||
|
||||
void ble_stack_start(void)
|
||||
{
|
||||
|
||||
MSG("[OS] ble_controller_init...\r\n");
|
||||
GLB_Set_EM_Sel(GLB_EM_8KB);
|
||||
ble_controller_init(configMAX_PRIORITIES - 1);
|
||||
|
||||
// Initialize BLE Host stack
|
||||
MSG("[OS] hci_driver_init...\r\n");
|
||||
hci_driver_init();
|
||||
|
||||
MSG("[OS] bt_enable...\r\n");
|
||||
bt_enable(bt_enable_cb);
|
||||
}
|
||||
|
||||
void ble_init(void)
|
||||
{
|
||||
extern void ble_stack_start(void);
|
||||
ble_stack_start();
|
||||
}
|
||||
|
||||
static void ble_init_task(void *pvParameters)
|
||||
{
|
||||
ble_init();
|
||||
vTaskDelete(NULL);
|
||||
}
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
static StackType_t ble_init_stack[1024];
|
||||
static StaticTask_t ble_init_task_h;
|
||||
|
||||
bflb_platform_init(0);
|
||||
HBN_Set_XCLK_CLK_Sel(HBN_XCLK_CLK_XTAL);
|
||||
GLB_Set_MTimer_CLK(1, GLB_MTIMER_CLK_BCLK, 17);
|
||||
|
||||
vPortDefineHeapRegions(xHeapRegions);
|
||||
|
||||
MSG("[OS] ble_init_task.....\r\n");
|
||||
xTaskCreateStatic(ble_init_task, (char*)"ble_init", sizeof(ble_init_stack)/4, NULL, 15, ble_init_stack, &ble_init_task_h);
|
||||
|
||||
vTaskStartScheduler();
|
||||
while(1)
|
||||
{
|
||||
}
|
||||
}
|
16
examples/boot2_iap/CMakeLists.txt
Normal file
16
examples/boot2_iap/CMakeLists.txt
Normal file
@ -0,0 +1,16 @@
|
||||
list(APPEND ADD_INCLUDE
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
)
|
||||
|
||||
set(TARGET_REQUIRED_LIBS xz)
|
||||
|
||||
list(APPEND TARGET_REQUIRED_SRCS blsp_common.c blsp_media_boot.c )
|
||||
list(APPEND TARGET_REQUIRED_SRCS blsp_boot_parser.c blsp_boot_decompress.c blsp_port.c )
|
||||
list(APPEND TARGET_REQUIRED_SRCS bflb_eflash_loader_uart.c ) #bflb_eflash_loader_gpio.c
|
||||
list(APPEND TARGET_REQUIRED_SRCS bflb_eflash_loader_cmds.c )
|
||||
SET(LINKER_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/blsp_boot2_iap_flash.ld)
|
||||
set(mains blsp_boot2_iap.c)
|
||||
generate_bin()
|
||||
|
||||
|
||||
|
159
examples/boot2_iap/bflb_eflash_loader.h
Normal file
159
examples/boot2_iap/bflb_eflash_loader.h
Normal file
@ -0,0 +1,159 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file blsp_eflash_loader.h
|
||||
* @version V1.2
|
||||
* @date
|
||||
* @brief This file is the peripheral case header file
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT(c) 2018 Bouffalo Lab</center></h2>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of Bouffalo Lab nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef __BFLB_EFLASH_LOADER_H__
|
||||
#define __BFLB_EFLASH_LOADER_H__
|
||||
|
||||
|
||||
/*error code definition*/
|
||||
typedef enum tag_eflash_loader_error_code_t
|
||||
{
|
||||
BFLB_EFLASH_LOADER_SUCCESS=0x00,
|
||||
|
||||
/*flash*/
|
||||
BFLB_EFLASH_LOADER_FLASH_INIT_ERROR=0x0001,
|
||||
BFLB_EFLASH_LOADER_FLASH_ERASE_PARA_ERROR=0x0002,
|
||||
BFLB_EFLASH_LOADER_FLASH_ERASE_ERROR=0x0003,
|
||||
BFLB_EFLASH_LOADER_FLASH_WRITE_PARA_ERROR=0x0004,
|
||||
BFLB_EFLASH_LOADER_FLASH_WRITE_ADDR_ERROR=0x0005,
|
||||
BFLB_EFLASH_LOADER_FLASH_WRITE_ERROR=0x0006,
|
||||
BFLB_EFLASH_LOADER_FLASH_BOOT_PARA_ERROR=0x0007,
|
||||
BFLB_EFLASH_LOADER_FLASH_SET_PARA_ERROR=0x0008,
|
||||
BFLB_EFLASH_LOADER_FLASH_READ_STATUS_REG_ERROR=0x0009,
|
||||
BFLB_EFLASH_LOADER_FLASH_WRITE_STATUS_REG_ERROR=0x000A,
|
||||
BFLB_EFLASH_LOADER_FLASH_DECOMPRESS_WRITE_ERROR=0x000B,
|
||||
BFLB_EFLASH_LOADER_FLASH_WRITE_XZ_ERROR=0x000C,
|
||||
|
||||
/*cmd*/
|
||||
BFLB_EFLASH_LOADER_CMD_ID_ERROR =0x0101,
|
||||
BFLB_EFLASH_LOADER_CMD_LEN_ERROR=0x0102,
|
||||
BFLB_EFLASH_LOADER_CMD_CRC_ERROR=0x0103,
|
||||
BFLB_EFLASH_LOADER_CMD_SEQ_ERROR=0x0104,
|
||||
|
||||
/*image*/
|
||||
BFLB_EFLASH_LOADER_IMG_BOOTHEADER_LEN_ERROR=0x0201,
|
||||
BFLB_EFLASH_LOADER_IMG_BOOTHEADER_NOT_LOAD_ERROR=0x0202,
|
||||
BFLB_EFLASH_LOADER_IMG_BOOTHEADER_MAGIC_ERROR=0x0203,
|
||||
BFLB_EFLASH_LOADER_IMG_BOOTHEADER_CRC_ERROR=0x0204,
|
||||
BFLB_EFLASH_LOADER_IMG_BOOTHEADER_ENCRYPT_NOTFIT=0x0205,
|
||||
BFLB_EFLASH_LOADER_IMG_BOOTHEADER_SIGN_NOTFIT=0x0206,
|
||||
BFLB_EFLASH_LOADER_IMG_SEGMENT_CNT_ERROR=0x0207,
|
||||
BFLB_EFLASH_LOADER_IMG_AES_IV_LEN_ERROR=0x0208,
|
||||
BFLB_EFLASH_LOADER_IMG_AES_IV_CRC_ERROR=0x0209,
|
||||
BFLB_EFLASH_LOADER_IMG_PK_LEN_ERROR=0x020a,
|
||||
BFLB_EFLASH_LOADER_IMG_PK_CRC_ERROR=0x020b,
|
||||
BFLB_EFLASH_LOADER_IMG_PK_HASH_ERROR=0x020c,
|
||||
BFLB_EFLASH_LOADER_IMG_SIGNATURE_LEN_ERROR=0x020d,
|
||||
BFLB_EFLASH_LOADER_IMG_SIGNATURE_CRC_ERROR=0x020e,
|
||||
BFLB_EFLASH_LOADER_IMG_SECTIONHEADER_LEN_ERROR=0x020f,
|
||||
BFLB_EFLASH_LOADER_IMG_SECTIONHEADER_CRC_ERROR=0x0210,
|
||||
BFLB_EFLASH_LOADER_IMG_SECTIONHEADER_DST_ERROR=0x0211,
|
||||
BFLB_EFLASH_LOADER_IMG_SECTIONDATA_LEN_ERROR=0x0212,
|
||||
BFLB_EFLASH_LOADER_IMG_SECTIONDATA_DEC_ERROR=0x0213,
|
||||
BFLB_EFLASH_LOADER_IMG_SECTIONDATA_TLEN_ERROR=0x0214,
|
||||
BFLB_EFLASH_LOADER_IMG_SECTIONDATA_CRC_ERROR=0x0215,
|
||||
BFLB_EFLASH_LOADER_IMG_HALFBAKED_ERROR=0x0216,
|
||||
BFLB_EFLASH_LOADER_IMG_HASH_ERROR=0x0217,
|
||||
BFLB_EFLASH_LOADER_IMG_SIGN_PARSE_ERROR=0x0218,
|
||||
BFLB_EFLASH_LOADER_IMG_SIGN_ERROR=0x0219,
|
||||
BFLB_EFLASH_LOADER_IMG_DEC_ERROR=0x021a,
|
||||
BFLB_EFLASH_LOADER_IMG_ALL_INVALID_ERROR=0x021b,
|
||||
|
||||
/*IF*/
|
||||
BFLB_EFLASH_LOADER_IF_RATE_LEN_ERROR=0x0301,
|
||||
BFLB_EFLASH_LOADER_IF_RATE_PARA_ERROR=0x0302,
|
||||
BFLB_EFLASH_LOADER_IF_PASSWORDERROR=0x0303,
|
||||
BFLB_EFLASH_LOADER_IF_PASSWORDCLOSE=0x0304,
|
||||
|
||||
/*efuse*/
|
||||
BFLB_EFLASH_LOADER_EFUSE_WRITE_PARA_ERROR=0x0401,
|
||||
BFLB_EFLASH_LOADER_EFUSE_WRITE_ADDR_ERROR=0x0402,
|
||||
BFLB_EFLASH_LOADER_EFUSE_WRITE_ERROR=0x0403,
|
||||
BFLB_EFLASH_LOADER_EFUSE_READ_PARA_ERROR=0x0404,
|
||||
BFLB_EFLASH_LOADER_EFUSE_READ_ADDR_ERROR=0x0405,
|
||||
BFLB_EFLASH_LOADER_EFUSE_READ_ERROR=0x0406,
|
||||
BFLB_EFLASH_LOADER_EFUSE_READ_MAC_ERROR=0x0407,
|
||||
|
||||
/*MISC*/
|
||||
BFLB_EFLASH_LOADER_PLL_ERROR=0xfffc,
|
||||
BFLB_EFLASH_LOADER_INVASION_ERROR=0xfffd,
|
||||
BFLB_EFLASH_LOADER_POLLING=0xfffe,
|
||||
BFLB_EFLASH_LOADER_FAIL=0xffff,
|
||||
|
||||
}eflash_loader_error_code_t;
|
||||
|
||||
/** private definition**/
|
||||
#define EFLASH_LOADER_CMD_DISABLE 0x000
|
||||
#define EFLASH_LOADER_CMD_ENABLE 0x001
|
||||
#define BFLB_EFLASH_LOADER_CMD_ACK 0x00004B4F
|
||||
#define BFLB_EFLASH_LOADER_CMD_NACK 0x00004C46
|
||||
|
||||
#define BFLB_EFLASH_LOADER_EFUSE0_SIZE 128
|
||||
|
||||
/*max data payload in command*/
|
||||
#define BFLB_EFLASH_LOADER_READBUF_SIZE (1024*16+8)
|
||||
#define BFLB_EFLASH_LOADER_WRITEBUF_SIZE BFLB_EFLASH_LOADER_READBUF_SIZE
|
||||
#define BFLB_EFLASH_LOADER_CMD_DATA_MAX_LEN (BFLB_EFLASH_LOADER_READBUF_SIZE-0x04) //cmd+rsvd+len(2bytes)
|
||||
|
||||
#define MAXOF(a,b) ((a)>(b)?(a):(b))
|
||||
#define OFFSET(TYPE, MEMBER) ((uint32_t)(&(((TYPE *)0)->MEMBER)))
|
||||
|
||||
#ifndef EFLASH_LOADER_FAST
|
||||
#define bflb_eflash_loader_printf(...) //bflb_platform_printf(__VA_ARGS__)
|
||||
#define bflb_eflash_loader_printe(...) //bflb_platform_printf(__VA_ARGS__)
|
||||
#define bflb_eflash_loader_printd(...) //bflb_platform_printf(__VA_ARGS__)
|
||||
#else
|
||||
#define bflb_eflash_loader_printf(...) //bflb_platform_printf(__VA_ARGS__)
|
||||
#define bflb_eflash_loader_printe(...) //bflb_platform_printf(__VA_ARGS__)
|
||||
#define bflb_eflash_loader_printd(...) //bflb_platform_printf(__VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#define bflb_eflash_loader_printw(...) //bflb_platform_printf(__VA_ARGS__)
|
||||
#define bflb_eflash_loader_printx(...) //bflb_platform_printx(__VA_ARGS__)
|
||||
|
||||
|
||||
/*read data buffer from flash or boot interface*/
|
||||
extern volatile uint32_t g_rx_buf_index;
|
||||
extern volatile uint32_t g_rx_buf_len;
|
||||
extern uint32_t g_eflash_loader_readbuf[2][(BFLB_EFLASH_LOADER_READBUF_SIZE+3)/4];
|
||||
extern uint32_t g_eflash_loader_cmd_ack_buf[16];
|
||||
|
||||
uint8_t bootrom_read_boot_mode(void);
|
||||
void bflb_eflash_loader_init_uart_gpio(uint8_t eflash_loader_uart_pin_select);
|
||||
void bflb_eflash_loader_deinit_uart_gpio_do(uint8_t eflash_loader_uart_pin_select);
|
||||
void bflb_eflash_loader_deinit_uart_gpio(uint8_t eflash_loader_uart_pin_select);
|
||||
void bflb_eflash_loader_init_flash_gpio(uint8_t flash_cfg);
|
||||
|
||||
#endif
|
343
examples/boot2_iap/bflb_eflash_loader_cmds.c
Normal file
343
examples/boot2_iap/bflb_eflash_loader_cmds.c
Normal file
@ -0,0 +1,343 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file blsp_eflash_loader_cmds.c
|
||||
* @version V1.2
|
||||
* @date
|
||||
* @brief This file is the peripheral case header file
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT(c) 2018 Bouffalo Lab</center></h2>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of Bouffalo Lab nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
#include "bflb_eflash_loader_cmds.h"
|
||||
#include "bflb_eflash_loader.h"
|
||||
#include "bflb_eflash_loader_uart.h"
|
||||
#include "stdio.h"
|
||||
#include "stdint.h"
|
||||
#include "string.h"
|
||||
#include "softcrc.h"
|
||||
#include "bflb_platform.h"
|
||||
#include "partition.h"
|
||||
#include "bl702_sec_eng.h"
|
||||
#include "hal_flash.h"
|
||||
#include "bl702_hbn.h"
|
||||
#include "bl702_glb.h"
|
||||
|
||||
/*for mass read comamnd(flash read and efuse read) is only valid for UART
|
||||
this is due to ack buffer is g_eflash_loader_readbuf */
|
||||
#define eflash_loader_cmd_mass_ack_buf g_eflash_loader_readbuf[1]
|
||||
#define BFLB_EFLASH_LOADER_CHECK_LEN 2048
|
||||
#define BFLB_EFLASH_MAX_SIZE 2*1024*1024
|
||||
|
||||
|
||||
/*add for verify using SHA-256*/
|
||||
uint32_t g_sha_tmp_buf[16]={0};
|
||||
uint32_t g_padding[16]={0};
|
||||
uint32_t g_sha_in_buf[(BFLB_EFLASH_LOADER_READBUF_SIZE+3)/4]={0};
|
||||
static uint32_t g_eflash_loader_error=0;
|
||||
extern struct device * download_uart;
|
||||
|
||||
static int32_t bflb_eflash_loader_cmd_read_jedec_id( uint16_t cmd, uint8_t *data, uint16_t len);
|
||||
static int32_t bflb_eflash_loader_cmd_reset( uint16_t cmd, uint8_t *data, uint16_t len);
|
||||
static int32_t bflb_eflash_loader_cmd_erase_flash( uint16_t cmd, uint8_t *data, uint16_t len);
|
||||
static int32_t bflb_eflash_loader_cmd_write_flash( uint16_t cmd, uint8_t *data, uint16_t len);
|
||||
static int32_t bflb_eflash_loader_cmd_read_flash( uint16_t cmd, uint8_t *data, uint16_t len);
|
||||
static int32_t bflb_eflash_loader_cmd_readSha_flash( uint16_t cmd, uint8_t *data, uint16_t len);
|
||||
static int32_t bflb_eflash_loader_cmd_xip_readSha_flash( uint16_t cmd, uint8_t *data, uint16_t len);
|
||||
static int32_t bflb_eflash_loader_cmd_write_flash_check( uint16_t cmd, uint8_t *data, uint16_t len);
|
||||
static int32_t bflb_eflash_loader_cmd_set_flash_para( uint16_t cmd, uint8_t *data, uint16_t len);
|
||||
static int32_t bflb_eflash_loader_cmd_xip_read_flash_start( uint16_t cmd, uint8_t *data, uint16_t len);
|
||||
static int32_t bflb_eflash_loader_cmd_xip_read_flash_finish( uint16_t cmd, uint8_t *data, uint16_t len);
|
||||
|
||||
|
||||
static const struct eflash_loader_cmd_cfg_t eflash_loader_cmds[]=
|
||||
{
|
||||
{BFLB_EFLASH_LOADER_CMD_RESET, EFLASH_LOADER_CMD_ENABLE, bflb_eflash_loader_cmd_reset},
|
||||
{BFLB_EFLASH_LOADER_CMD_FLASH_ERASE, EFLASH_LOADER_CMD_ENABLE, bflb_eflash_loader_cmd_erase_flash},
|
||||
{BFLB_EFLASH_LOADER_CMD_FLASH_WRITE, EFLASH_LOADER_CMD_ENABLE, bflb_eflash_loader_cmd_write_flash},
|
||||
{BFLB_EFLASH_LOADER_CMD_FLASH_READ, EFLASH_LOADER_CMD_ENABLE, bflb_eflash_loader_cmd_read_flash},
|
||||
{BFLB_EFLASH_LOADER_CMD_FLASH_WRITE_CHECK, EFLASH_LOADER_CMD_ENABLE, bflb_eflash_loader_cmd_write_flash_check},
|
||||
{BFLB_EFLASH_LOADER_CMD_FLASH_SET_PARA, EFLASH_LOADER_CMD_ENABLE, bflb_eflash_loader_cmd_set_flash_para},
|
||||
{BFLB_EFLASH_LOADER_CMD_FLASH_READSHA, EFLASH_LOADER_CMD_ENABLE, bflb_eflash_loader_cmd_readSha_flash},
|
||||
{BFLB_EFLASH_LOADER_CMD_FLASH_XIP_READSHA, EFLASH_LOADER_CMD_ENABLE, bflb_eflash_loader_cmd_xip_readSha_flash},
|
||||
{BFLB_EFLASH_LOADER_CMD_XIP_READ_START, EFLASH_LOADER_CMD_ENABLE, bflb_eflash_loader_cmd_xip_read_flash_start},
|
||||
{BFLB_EFLASH_LOADER_CMD_XIP_READ_FINISH, EFLASH_LOADER_CMD_ENABLE, bflb_eflash_loader_cmd_xip_read_flash_finish},
|
||||
{BFLB_EFLASH_LOADER_CMD_FLASH_READ_JEDECID, EFLASH_LOADER_CMD_ENABLE, bflb_eflash_loader_cmd_read_jedec_id},
|
||||
};
|
||||
|
||||
/* int boot command control */
|
||||
void bflb_eflash_loader_cmd_init()
|
||||
{
|
||||
g_eflash_loader_error=BFLB_EFLASH_LOADER_SUCCESS;
|
||||
//download_uart = device_find("download_uart");
|
||||
}
|
||||
|
||||
/* ack host with command process result */
|
||||
static void bflb_eflash_loader_cmd_ack(uint32_t result)
|
||||
{
|
||||
if(result==0){
|
||||
/*OK*/
|
||||
g_eflash_loader_cmd_ack_buf[0]=BFLB_EFLASH_LOADER_CMD_ACK;
|
||||
bflb_eflash_loader_uart_send((uint32_t *)g_eflash_loader_cmd_ack_buf,2);
|
||||
return;
|
||||
}else{
|
||||
/* FL+Error code(2bytes) */
|
||||
g_eflash_loader_cmd_ack_buf[0]=BFLB_EFLASH_LOADER_CMD_NACK|((result<<16)&0xffff0000);
|
||||
bflb_eflash_loader_uart_send(g_eflash_loader_cmd_ack_buf,4);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static int32_t bflb_eflash_loader_cmd_read_jedec_id( uint16_t cmd, uint8_t *data, uint16_t len)
|
||||
{
|
||||
uint8_t *ackdata=(uint8_t *)eflash_loader_cmd_mass_ack_buf;
|
||||
|
||||
bflb_eflash_loader_printf("JID\n");
|
||||
eflash_loader_cmd_mass_ack_buf[0]=BFLB_EFLASH_LOADER_CMD_ACK;
|
||||
|
||||
/*ack read jedec ID */
|
||||
ackdata[2]=4;
|
||||
ackdata[3]=0;
|
||||
flash_read_jedec_id((uint8_t *)&eflash_loader_cmd_mass_ack_buf[1]);
|
||||
bflb_eflash_loader_uart_send((uint32_t *)ackdata,4+4);
|
||||
return BFLB_EFLASH_LOADER_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t bflb_eflash_loader_cmd_reset( uint16_t cmd, uint8_t *data, uint16_t len)
|
||||
{
|
||||
int32_t ret=BFLB_EFLASH_LOADER_SUCCESS;
|
||||
|
||||
pt_table_set_iap_para(&p_iap_param);
|
||||
pt_table_dump();
|
||||
bflb_eflash_loader_printf("RST\n");
|
||||
|
||||
bflb_eflash_loader_cmd_ack(ret);
|
||||
bflb_eflash_loader_usart_wait_tx_idle(BFLB_EFLASH_LOADER_IF_TX_IDLE_TIMEOUT);
|
||||
|
||||
/* add for bl702, will impact on boot pin read */
|
||||
HBN_Set_Status_Flag(0x594c440B);
|
||||
|
||||
/* FPGA POR RST NOT work,so add system reset */
|
||||
bflb_platform_delay_us(10);
|
||||
GLB_SW_System_Reset();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t bflb_eflash_loader_cmd_erase_flash( uint16_t cmd, uint8_t *data, uint16_t len)
|
||||
{
|
||||
int32_t ret=BFLB_EFLASH_LOADER_SUCCESS;
|
||||
uint32_t startaddr,endaddr;
|
||||
|
||||
bflb_eflash_loader_printf("E\n");
|
||||
|
||||
if(len!=8){
|
||||
ret=BFLB_EFLASH_LOADER_FLASH_ERASE_PARA_ERROR;
|
||||
}else{
|
||||
/*clean write error, since write usually behand erase*/
|
||||
g_eflash_loader_error=BFLB_EFLASH_LOADER_SUCCESS;
|
||||
|
||||
memcpy(&startaddr,data,4);
|
||||
memcpy(&endaddr,data+4,4);
|
||||
|
||||
p_iap_param.iap_img_len=endaddr - startaddr + 1;
|
||||
|
||||
|
||||
bflb_eflash_loader_printd("from%08xto%08x\n",p_iap_param.iap_start_addr,p_iap_param.iap_start_addr + p_iap_param.iap_img_len - 1);
|
||||
if(SUCCESS!=flash_erase_xip(p_iap_param.iap_start_addr,p_iap_param.iap_start_addr + p_iap_param.iap_img_len-1))
|
||||
{
|
||||
bflb_eflash_loader_printe("fail\n");
|
||||
ret=BFLB_EFLASH_LOADER_FLASH_ERASE_ERROR;
|
||||
}
|
||||
}
|
||||
bflb_eflash_loader_cmd_ack(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t ATTR_TCM_SECTION bflb_eflash_loader_cmd_write_flash( uint16_t cmd, uint8_t *data, uint16_t len)
|
||||
{
|
||||
int32_t ret=BFLB_EFLASH_LOADER_SUCCESS;
|
||||
uint32_t write_len;
|
||||
|
||||
//bflb_eflash_loader_printf("W\n");
|
||||
|
||||
if(len<=4){
|
||||
ret=BFLB_EFLASH_LOADER_FLASH_WRITE_PARA_ERROR;
|
||||
}else{
|
||||
//memcpy(&startaddr,data,4);
|
||||
write_len=len-4;
|
||||
//MSG("to%08x,%d\n",p_iap_param.iap_write_addr,write_len);
|
||||
bflb_platform_clear_time();
|
||||
if(p_iap_param.iap_write_addr<0xffffffff){
|
||||
|
||||
bflb_eflash_loader_cmd_ack(ret);
|
||||
|
||||
if(SUCCESS!=flash_write_xip(p_iap_param.iap_write_addr,data+4,write_len))
|
||||
{
|
||||
/*error , response again with error */
|
||||
bflb_eflash_loader_printe("fail\r\n");
|
||||
ret=BFLB_EFLASH_LOADER_FLASH_WRITE_ERROR;
|
||||
g_eflash_loader_error=ret;
|
||||
}else{
|
||||
p_iap_param.iap_write_addr += write_len;
|
||||
//bflb_eflash_loader_printe("Write suss\r\n");
|
||||
return BFLB_EFLASH_LOADER_SUCCESS;
|
||||
}
|
||||
}else{
|
||||
ret=BFLB_EFLASH_LOADER_FLASH_WRITE_ADDR_ERROR;
|
||||
}
|
||||
bflb_eflash_loader_printd("%d\n",bflb_platform_get_time_us());
|
||||
}
|
||||
|
||||
bflb_eflash_loader_cmd_ack(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t bflb_eflash_loader_cmd_read_flash( uint16_t cmd, uint8_t *data, uint16_t len)
|
||||
{
|
||||
return BFLB_EFLASH_LOADER_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t bflb_eflash_loader_cmd_xip_read_flash_start( uint16_t cmd, uint8_t *data, uint16_t len)
|
||||
{
|
||||
int32_t ret=BFLB_EFLASH_LOADER_SUCCESS;
|
||||
|
||||
bflb_eflash_loader_cmd_ack(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t bflb_eflash_loader_cmd_xip_read_flash_finish( uint16_t cmd, uint8_t *data, uint16_t len)
|
||||
{
|
||||
int32_t ret=BFLB_EFLASH_LOADER_SUCCESS;
|
||||
|
||||
//bflb_eflash_loader_printf("exit\n");
|
||||
bflb_eflash_loader_cmd_ack(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t bflb_eflash_loader_cmd_readSha_flash( uint16_t cmd, uint8_t *data, uint16_t len)
|
||||
{
|
||||
return BFLB_EFLASH_LOADER_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t bflb_eflash_loader_cmd_xip_readSha_flash( uint16_t cmd, uint8_t *data, uint16_t len)
|
||||
{
|
||||
int32_t ret=BFLB_EFLASH_LOADER_SUCCESS;
|
||||
uint32_t startaddr,read_len;
|
||||
SEC_Eng_SHA256_Ctx sha_ctx;
|
||||
SEC_ENG_SHA_ID_Type shaId=SEC_ENG_SHA_ID0;
|
||||
uint16_t sha_len=32;
|
||||
uint8_t *ackdata=(uint8_t *)eflash_loader_cmd_mass_ack_buf;
|
||||
bflb_eflash_loader_printf("XRSha\n");
|
||||
|
||||
if(len!=8){
|
||||
ret=BFLB_EFLASH_LOADER_FLASH_WRITE_PARA_ERROR;
|
||||
bflb_eflash_loader_cmd_ack(ret);
|
||||
}else{
|
||||
startaddr = p_iap_param.iap_start_addr;
|
||||
read_len = p_iap_param.iap_img_len;
|
||||
bflb_eflash_loader_printd("from%08x,%d\n",startaddr,read_len);
|
||||
//MSG("!!!Be careful that SHA input data should locate at OCRAM \n");
|
||||
/* Init SHA and input SHA temp buffer for scattered data and g_padding buffer */
|
||||
Sec_Eng_SHA256_Init(&sha_ctx,shaId,SEC_ENG_SHA256,g_sha_tmp_buf,g_padding );
|
||||
Sec_Eng_SHA_Start(shaId);
|
||||
while(read_len>0){
|
||||
if(read_len>BFLB_EFLASH_LOADER_READBUF_SIZE){
|
||||
flash_read_xip(startaddr,(uint8_t *)g_sha_in_buf,BFLB_EFLASH_LOADER_READBUF_SIZE);
|
||||
/*cal sha here*/
|
||||
Sec_Eng_SHA256_Update(&sha_ctx,shaId,(uint8_t *)g_sha_in_buf,BFLB_EFLASH_LOADER_READBUF_SIZE );
|
||||
read_len-=BFLB_EFLASH_LOADER_READBUF_SIZE;
|
||||
startaddr+=BFLB_EFLASH_LOADER_READBUF_SIZE;
|
||||
}else{
|
||||
flash_read_xip(startaddr,(uint8_t *)g_sha_in_buf,read_len);
|
||||
/*cal sha here*/
|
||||
Sec_Eng_SHA256_Update(&sha_ctx,shaId,(uint8_t *)g_sha_in_buf,read_len );
|
||||
read_len-=read_len;
|
||||
startaddr+=read_len;
|
||||
}
|
||||
}
|
||||
Sec_Eng_SHA256_Finish(&sha_ctx,shaId,&ackdata[4]);
|
||||
for(sha_len=0;sha_len<32;sha_len++){
|
||||
bflb_eflash_loader_printf("\r\n");
|
||||
bflb_eflash_loader_printx(ackdata[4+sha_len]);
|
||||
}
|
||||
|
||||
sha_len=32;
|
||||
/*ack read data */
|
||||
ackdata[0]=BFLB_EFLASH_LOADER_CMD_ACK&0xff;
|
||||
ackdata[1]=(BFLB_EFLASH_LOADER_CMD_ACK>>8)&0xff;
|
||||
ackdata[2]=sha_len&0xff;
|
||||
ackdata[3]=(sha_len>>8)&0xff;
|
||||
bflb_eflash_loader_uart_send((uint32_t*)ackdata,sha_len+4);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t bflb_eflash_loader_cmd_write_flash_check( uint16_t cmd, uint8_t *data, uint16_t len)
|
||||
{
|
||||
bflb_eflash_loader_printf("WC\n");
|
||||
|
||||
bflb_eflash_loader_cmd_ack(g_eflash_loader_error);
|
||||
|
||||
return BFLB_EFLASH_LOADER_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t bflb_eflash_loader_cmd_set_flash_para( uint16_t cmd, uint8_t *data, uint16_t len)
|
||||
{
|
||||
bflb_eflash_loader_cmd_ack(BFLB_EFLASH_LOADER_SUCCESS);
|
||||
return BFLB_EFLASH_LOADER_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t bflb_eflash_loader_cmd_process(uint8_t cmdid,uint8_t *data,uint16_t len)
|
||||
{
|
||||
int i=0;
|
||||
int32_t ret=BFLB_EFLASH_LOADER_SUCCESS;
|
||||
for(i=0;i<sizeof(eflash_loader_cmds)/sizeof(eflash_loader_cmds[0]);i++)
|
||||
{
|
||||
if(eflash_loader_cmds[i].cmd==cmdid){
|
||||
if(EFLASH_LOADER_CMD_ENABLE==eflash_loader_cmds[i].enabled&&NULL!=eflash_loader_cmds[i].cmd_process){
|
||||
ret=eflash_loader_cmds[i].cmd_process(cmdid,data,len);
|
||||
}else{
|
||||
return BFLB_EFLASH_LOADER_CMD_ID_ERROR;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
112
examples/boot2_iap/bflb_eflash_loader_cmds.h
Normal file
112
examples/boot2_iap/bflb_eflash_loader_cmds.h
Normal file
@ -0,0 +1,112 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file blsp_eflash_loader_cmds.h
|
||||
* @version V1.2
|
||||
* @date
|
||||
* @brief This file is the peripheral case header file
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT(c) 2018 Bouffalo Lab</center></h2>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of Bouffalo Lab nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef __BFLB_EFLASH_LOADER_CMDS_H__
|
||||
#define __BFLB_EFLASH_LOADER_CMDS_H__
|
||||
|
||||
#include "stdint.h"
|
||||
|
||||
#define BFLB_EFLASH_LOADER_CMD_GET_BOOTINFO 0x0010
|
||||
#define BFLB_EFLASH_LOADER_CMD_LOAD_BOOTHEADER 0x0011
|
||||
#define BFLB_EFLASH_LOADER_CMD_LOAD_PUBLICKEY 0x0012
|
||||
#define BFLB_EFLASH_LOADER_CMD_LOAD_PUBLICKEY2 0x0013
|
||||
#define BFLB_EFLASH_LOADER_CMD_LOAD_SIGNATURE 0x0014
|
||||
#define BFLB_EFLASH_LOADER_CMD_LOAD_SIGNATURE2 0x0015
|
||||
#define BFLB_EFLASH_LOADER_CMD_LOAD_AESIV 0x0016
|
||||
#define BFLB_EFLASH_LOADER_CMD_LOAD_SEGHEADER 0x0017
|
||||
#define BFLB_EFLASH_LOADER_CMD_LOAD_SEGDATA 0x0018
|
||||
#define BFLB_EFLASH_LOADER_CMD_CHECK_IMG 0x0019
|
||||
#define BFLB_EFLASH_LOADER_CMD_RUN 0x001A
|
||||
|
||||
#define BFLB_EFLASH_LOADER_CMD_CHANGE_RATE 0x0020
|
||||
#define BFLB_EFLASH_LOADER_CMD_RESET 0x0021
|
||||
|
||||
#define BFLB_EFLASH_LOADER_CMD_FLASH_ERASE 0x0030
|
||||
#define BFLB_EFLASH_LOADER_CMD_FLASH_WRITE 0x0031
|
||||
#define BFLB_EFLASH_LOADER_CMD_FLASH_READ 0x0032
|
||||
#define BFLB_EFLASH_LOADER_CMD_FLASH_BOOT 0x0033
|
||||
#define BFLB_EFLASH_LOADER_CMD_FLASH_WRITE_CHECK 0x003A
|
||||
#define BFLB_EFLASH_LOADER_CMD_FLASH_SET_PARA 0x003B
|
||||
#define BFLB_EFLASH_LOADER_CMD_FLASH_CHIPERASE 0x003C
|
||||
#define BFLB_EFLASH_LOADER_CMD_FLASH_READSHA 0x003D
|
||||
#define BFLB_EFLASH_LOADER_CMD_FLASH_XIP_READSHA 0x003E
|
||||
|
||||
#define BFLB_EFLASH_LOADER_CMD_FLASH_XIP_READ 0x0034
|
||||
#define BFLB_EFLASH_LOADER_CMD_FLASH_SBUS_XIP_READ 0x0035
|
||||
|
||||
#define BFLB_EFLASH_LOADER_CMD_FLASH_READ_JEDECID 0x0036
|
||||
#define BFLB_EFLASH_LOADER_CMD_FLASH_READ_STATUS_REG 0x0037
|
||||
#define BFLB_EFLASH_LOADER_CMD_FLASH_WRITE_STATUS_REG 0x0038
|
||||
|
||||
#define BFLB_EFLASH_LOADER_CMD_EFUSE_WRITE 0x0040
|
||||
#define BFLB_EFLASH_LOADER_CMD_EFUSE_READ 0x0041
|
||||
#define BFLB_EFLASH_LOADER_CMD_EFUSE_READ_MAC_ADDR 0x0042
|
||||
|
||||
#define BFLB_EFLASH_LOADER_CMD_MEM_WRITE 0x0050
|
||||
#define BFLB_EFLASH_LOADER_CMD_MEM_READ 0x0051
|
||||
|
||||
#define BFLB_EFLASH_LOADER_CMD_LOG_READ 0x0071
|
||||
|
||||
#define BFLB_EFLASH_LOADER_CMD_XIP_READ_START 0x0060
|
||||
#define BFLB_EFLASH_LOADER_CMD_XIP_READ_FINISH 0x0061
|
||||
|
||||
#define BFLB_EFLASH_LOADER_CMD_GET_ECDH_PK 0x0090
|
||||
#define BFLB_EFLASH_LOADER_CMD_ECDH_CHANLLENGE 0x0091
|
||||
|
||||
|
||||
/* public key hash type and length */
|
||||
#define BFLB_EFLASH_LOADER_PK_HASH_TYPE BFLB_HASH_TYPE_SHA256
|
||||
#define BFLB_EFLASH_LOADER_PK_HASH_SIZE 256/8
|
||||
#define BFLB_EFLASH_LOADER_HASH_TYPE BFLB_HASH_TYPE_SHA256
|
||||
#define BFLB_EFLASH_LOADER_AES_TYPE BFLB_CRYPT_TYPE_AES_CBC
|
||||
#define BFLB_EFLASH_LOADER_HASH_SIZE 256/8
|
||||
|
||||
void bflb_eflash_loader_cmd_init(void);
|
||||
void bflb_eflash_loader_cmd_disable(uint8_t cmdid);
|
||||
void bflb_eflash_loader_cmd_enable(uint8_t cmdid);
|
||||
int32_t bflb_eflash_loader_cmd_process(uint8_t cmdid, uint8_t *data, uint16_t len);
|
||||
|
||||
|
||||
|
||||
typedef int32_t (*pfun_cmd_process)( uint16_t cmd, uint8_t *data, uint16_t len);
|
||||
|
||||
struct eflash_loader_cmd_cfg_t
|
||||
{
|
||||
uint8_t cmd;
|
||||
uint8_t enabled;
|
||||
pfun_cmd_process cmd_process;
|
||||
};
|
||||
|
||||
#endif
|
340
examples/boot2_iap/bflb_eflash_loader_uart.c
Normal file
340
examples/boot2_iap/bflb_eflash_loader_uart.c
Normal file
@ -0,0 +1,340 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file blsp_eflash_loader_uart.c
|
||||
* @version V1.2
|
||||
* @date
|
||||
* @brief This file is the peripheral case header file
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT(c) 2018 Bouffalo Lab</center></h2>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of Bouffalo Lab nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
#include "bflb_eflash_loader_uart.h"
|
||||
#include "bflb_eflash_loader_cmds.h"
|
||||
#include "bflb_eflash_loader.h"
|
||||
#include "bflb_platform.h"
|
||||
#include "partition.h"
|
||||
#include "hal_uart.h"
|
||||
#include "drv_device.h"
|
||||
|
||||
#define LOCAL_FILE_NUM (0x0003)
|
||||
#define UART_CLOCK (40000000)
|
||||
|
||||
static uint32_t g_detected_baudrate;
|
||||
|
||||
|
||||
/* data buffer for read data and decrypt */
|
||||
volatile uint32_t g_rx_buf_index=0;
|
||||
volatile uint32_t g_rx_buf_len=0;
|
||||
uint32_t g_eflash_loader_readbuf[2][(BFLB_EFLASH_LOADER_READBUF_SIZE+3)/4];
|
||||
uint32_t g_eflash_loader_cmd_ack_buf[16];
|
||||
static void bflb_eflash_loader_usart_if_deinit();
|
||||
struct device * download_uart = NULL;
|
||||
|
||||
|
||||
enum uart_index_type board_get_debug_uart_index(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void ATTR_TCM_SECTION uart0_irq_callback(struct device *dev, void *args, uint32_t size, uint32_t state)
|
||||
{
|
||||
uint8_t *buf=(uint8_t *)g_eflash_loader_readbuf[g_rx_buf_index];
|
||||
|
||||
if (state == UART_EVENT_RX_FIFO)
|
||||
{
|
||||
//g_rx_buf_len += device_read(download_uart,0,buf,BFLB_EFLASH_LOADER_READBUF_SIZE-g_rx_buf_len);
|
||||
BL702_MemCpy(buf+g_rx_buf_len,args,size);
|
||||
g_rx_buf_len += size;
|
||||
}
|
||||
else if (state == UART_EVENT_RTO)
|
||||
{
|
||||
//g_rx_buf_len += device_read(download_uart,0,buf,BFLB_EFLASH_LOADER_READBUF_SIZE-g_rx_buf_len);
|
||||
BL702_MemCpy(buf+g_rx_buf_len,args,size);
|
||||
g_rx_buf_len += size;
|
||||
}
|
||||
}
|
||||
|
||||
static void bflb_eflash_loader_usart_if_init(uint32_t bdrate)
|
||||
{
|
||||
uart_register(0, "download_uart", DEVICE_OFLAG_RDWR);
|
||||
download_uart = device_find("download_uart");
|
||||
|
||||
if (download_uart)
|
||||
{
|
||||
UART_DEV(download_uart)->fifo_threshold = 16;
|
||||
device_open(download_uart, DEVICE_OFLAG_STREAM_TX);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void bflb_eflash_loader_usart_if_enable_int(void)
|
||||
{
|
||||
struct device *uart = device_find("download_uart");
|
||||
|
||||
if(uart){
|
||||
device_close(uart);
|
||||
device_open(download_uart, DEVICE_OFLAG_STREAM_TX | DEVICE_OFLAG_INT_RX);
|
||||
device_set_callback(uart, uart0_irq_callback);
|
||||
device_control(uart, DEVICE_CTRL_SET_INT, (void *)(UART_RX_FIFO_IT|UART_RTO_IT));
|
||||
}
|
||||
}
|
||||
|
||||
void bflb_eflash_loader_usart_if_send(uint8_t *data,uint32_t len)
|
||||
{
|
||||
device_write(download_uart, 0, data, len);
|
||||
}
|
||||
|
||||
int32_t bflb_eflash_loader_usart_if_wait_tx_idle(uint32_t timeout)
|
||||
{
|
||||
/*UART now can't judge tx idle now*/
|
||||
bflb_platform_delay_ms(timeout);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static uint32_t *bflb_eflash_loader_usart_if_receive(uint32_t *recv_len,uint16_t maxlen,uint16_t timeout)
|
||||
{
|
||||
uint8_t *buf=(uint8_t *)g_eflash_loader_readbuf[g_rx_buf_index];
|
||||
uint16_t datalen=0;
|
||||
|
||||
bflb_platform_clear_time();
|
||||
do
|
||||
{
|
||||
if(g_rx_buf_len>=4){
|
||||
/* receive cmd id and data len*/
|
||||
datalen=buf[2]+(buf[3]<<8);
|
||||
if(g_rx_buf_len==datalen+4){
|
||||
/*receive all the payload,return */
|
||||
/* move on to next buffer */
|
||||
g_rx_buf_index=(g_rx_buf_index+1)%2;
|
||||
g_rx_buf_len=0;
|
||||
|
||||
if(datalen<=BFLB_EFLASH_LOADER_CMD_DATA_MAX_LEN){
|
||||
*recv_len=datalen+4;
|
||||
return (uint32_t *)buf;
|
||||
} else {
|
||||
*recv_len=0;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}while(bflb_platform_get_time_ms()<timeout);
|
||||
|
||||
*recv_len=0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void bflb_eflash_loader_usart_if_deinit()
|
||||
{
|
||||
struct device *uart = device_find("download_uart");
|
||||
|
||||
if (uart)
|
||||
{
|
||||
device_close(uart);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t bflb_eflash_loader_uart_init()
|
||||
{
|
||||
//bflb_eflash_loader_usart_if_deinit();
|
||||
bflb_eflash_loader_usart_if_init(0);
|
||||
|
||||
return BFLB_EFLASH_LOADER_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t bflb_eflash_loader_uart_handshake_poll()
|
||||
{
|
||||
uint8_t buf[128];
|
||||
uint32_t i;
|
||||
uint32_t handshake_count = 0;
|
||||
uint32_t rcv_buf_len=0;
|
||||
//rcv_buf_len = UART_ReceiveData(g_uart_if_id,buf,128);
|
||||
struct device *download_uart = device_find("download_uart");
|
||||
|
||||
if (download_uart)
|
||||
{
|
||||
rcv_buf_len = device_read(download_uart, 0,buf,128);
|
||||
}
|
||||
//while(1)
|
||||
{
|
||||
if(rcv_buf_len>=16)
|
||||
{
|
||||
for(i = 0; i < 16; i++)
|
||||
{
|
||||
if(buf[i] == BFLB_EFLASH_LOADER_HAND_SHAKE_BYTE){
|
||||
handshake_count++;
|
||||
if(handshake_count > BFLB_EFLASH_LAODER_HAND_SHAKE_SUSS_COUNT)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(handshake_count >= BFLB_EFLASH_LAODER_HAND_SHAKE_SUSS_COUNT){
|
||||
//reinit uart
|
||||
bflb_eflash_loader_printf("handshake %d 0x55 rcv\r\n",handshake_count);
|
||||
|
||||
}
|
||||
else{
|
||||
//bflb_eflash_loader_printf("handshake err\r\n");
|
||||
return BFLB_EFLASH_LOADER_HANDSHAKE_FAIL;
|
||||
}
|
||||
/*receive shake hanad signal*/
|
||||
bflb_eflash_loader_usart_if_send((uint8_t*)"OK",2);
|
||||
bflb_platform_delay_ms(400);
|
||||
|
||||
/* consume the remaining bytes when shake hand(0x55) if needed */
|
||||
rcv_buf_len = device_read(download_uart, 0,buf,128);//UART_ReceiveData(g_uart_if_id,buf,128);
|
||||
bflb_eflash_loader_printf("bflb_eflash_loader_usart_if_receive len %d\r\n",rcv_buf_len);
|
||||
/*init rx info */
|
||||
g_rx_buf_index=0;
|
||||
g_rx_buf_len=0;
|
||||
BL_WR_WORD(g_eflash_loader_readbuf[g_rx_buf_index],0);
|
||||
bflb_eflash_loader_usart_if_enable_int();
|
||||
|
||||
|
||||
|
||||
return BFLB_EFLASH_LOADER_HANDSHAKE_SUSS;
|
||||
|
||||
|
||||
}
|
||||
|
||||
uint32_t *bflb_eflash_loader_uart_recv(uint32_t *recv_len,uint32_t maxlen,uint32_t timeout)
|
||||
{
|
||||
return bflb_eflash_loader_usart_if_receive(recv_len,maxlen,timeout);
|
||||
}
|
||||
|
||||
int32_t bflb_eflash_loader_uart_send(uint32_t *data,uint32_t len)
|
||||
{
|
||||
bflb_eflash_loader_usart_if_send((uint8_t*)data,len);
|
||||
|
||||
return BFLB_EFLASH_LOADER_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t bflb_eflash_loader_usart_wait_tx_idle(uint32_t timeout)
|
||||
{
|
||||
return bflb_eflash_loader_usart_if_wait_tx_idle(timeout);
|
||||
}
|
||||
|
||||
int32_t bflb_eflash_loader_uart_change_rate(uint32_t oldval, uint32_t newval)
|
||||
{
|
||||
uint32_t b=(uint32_t)((g_detected_baudrate*1.0*newval)/oldval);
|
||||
|
||||
bflb_eflash_loader_printf("BDR:");
|
||||
bflb_eflash_loader_printx(oldval);
|
||||
bflb_eflash_loader_printx(newval);
|
||||
bflb_eflash_loader_printx(g_detected_baudrate);
|
||||
bflb_eflash_loader_printx(b);
|
||||
|
||||
|
||||
bflb_eflash_loader_usart_if_wait_tx_idle(BFLB_EFLASH_LOADER_IF_TX_IDLE_TIMEOUT);
|
||||
|
||||
bflb_eflash_loader_usart_if_init(b);
|
||||
bflb_eflash_loader_usart_if_send((uint8_t *)"OK",2);
|
||||
|
||||
return BFLB_EFLASH_LOADER_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t bflb_eflash_loader_uart_deinit()
|
||||
{
|
||||
|
||||
/* delete uart deinit, when uart tx(gpio16) set input function, uart send 0xFF to uart tx fifo
|
||||
bflb_eflash_loader_deinit_uart_gpio(g_abr_gpio_sel);
|
||||
|
||||
bflb_eflash_loader_usart_if_deinit();
|
||||
*/
|
||||
|
||||
return BFLB_EFLASH_LOADER_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
void bflb_eflash_loader_main()
|
||||
{
|
||||
int32_t ret;
|
||||
uint32_t total_len;
|
||||
uint32_t i,tmp,cmd_len;
|
||||
uint8_t *recv_buf=NULL;
|
||||
uint8_t err_cnt=0;
|
||||
uint8_t to_cnt=0;
|
||||
|
||||
bflb_eflash_loader_printf("bflb_eflash_loader_main\r\n");
|
||||
pt_table_dump();
|
||||
pt_table_get_iap_para(&p_iap_param);
|
||||
bflb_eflash_loader_cmd_init();
|
||||
while(1){
|
||||
to_cnt=0;
|
||||
total_len=0;
|
||||
do{
|
||||
total_len=0;
|
||||
recv_buf=(uint8_t *)bflb_eflash_loader_uart_recv(&total_len,BFLB_EFLASH_LOADER_READBUF_SIZE,BFLB_EFLASH_LOADER_IF_UART_RX_TIMEOUT);
|
||||
if(total_len<=0){
|
||||
to_cnt++;
|
||||
}
|
||||
}while(to_cnt<2&&total_len<=0);
|
||||
if(to_cnt>=2||total_len<=0){
|
||||
bflb_eflash_loader_printf("rcv err break\r\n");
|
||||
break;
|
||||
}
|
||||
//bflb_eflash_loader_printf("Recv\r\n");
|
||||
//eflash_loader_dump_data(recv_buf,total_len);
|
||||
cmd_len=recv_buf[2]+(recv_buf[3]<<8);
|
||||
bflb_eflash_loader_printf("cmd_len %d\r\n",cmd_len);
|
||||
/* Check checksum*/
|
||||
if(recv_buf[1]!=0){
|
||||
tmp=0;
|
||||
for(i=2;i<cmd_len+4;i++){
|
||||
tmp+=recv_buf[i];
|
||||
}
|
||||
if((tmp&0xff)!=recv_buf[1]){
|
||||
/* FL+Error code(2bytes) */
|
||||
bflb_eflash_loader_printf("Checksum error %02x\r\n",tmp&0xff);
|
||||
g_eflash_loader_cmd_ack_buf[0]=BFLB_EFLASH_LOADER_CMD_NACK|((BFLB_EFLASH_LOADER_CMD_CRC_ERROR<<16)&0xffff0000);
|
||||
bflb_eflash_loader_uart_send(g_eflash_loader_cmd_ack_buf,4);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
ret=bflb_eflash_loader_cmd_process(recv_buf[0],recv_buf+4,cmd_len);
|
||||
if(ret!=BFLB_EFLASH_LOADER_SUCCESS){
|
||||
bflb_eflash_loader_printf(" CMD Pro Ret %d\r\n",ret);
|
||||
|
||||
err_cnt++;
|
||||
if(err_cnt>2){
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* read data finished,deinit and go on*/
|
||||
bflb_eflash_loader_uart_deinit();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
72
examples/boot2_iap/bflb_eflash_loader_uart.h
Normal file
72
examples/boot2_iap/bflb_eflash_loader_uart.h
Normal file
@ -0,0 +1,72 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file blsp_eflash_loader_uart.h
|
||||
* @version V1.2
|
||||
* @date
|
||||
* @brief This file is the peripheral case header file
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT(c) 2018 Bouffalo Lab</center></h2>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of Bouffalo Lab nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef __BFLB_EFLASH_LOADER_UART_H__
|
||||
#define __BFLB_EFLASH_LOADER_UART_H__
|
||||
|
||||
#include "stdint.h"
|
||||
|
||||
int32_t bflb_eflash_loader_uart_init();
|
||||
|
||||
int32_t bflb_eflash_loader_uart_handshake_poll();
|
||||
|
||||
uint32_t *bflb_eflash_loader_uart_recv(uint32_t *recv_len,uint32_t maxlen,uint32_t timeout);
|
||||
|
||||
int32_t bflb_eflash_loader_uart_send(uint32_t *data,uint32_t len);
|
||||
|
||||
int32_t bflb_eflash_loader_usart_wait_tx_idle(uint32_t timeout);
|
||||
|
||||
int32_t bflb_eflash_loader_uart_change_rate(uint32_t oldval,uint32_t newval);
|
||||
|
||||
int32_t bflb_eflash_loader_uart_deinit(void);
|
||||
|
||||
void bflb_eflash_loader_main();
|
||||
|
||||
|
||||
typedef enum{
|
||||
BFLB_EFLASH_LOADER_HANDSHAKE_SUSS = 0,
|
||||
BFLB_EFLASH_LOADER_HANDSHAKE_FAIL,
|
||||
}eflash_handshake_ret;
|
||||
|
||||
|
||||
#define AUTO_BAUDRATE_CHECK_TIME_MAX_MS 2
|
||||
#define BFLB_EFLASH_LOADER_IF_TX_IDLE_TIMEOUT 4 /*ms*/
|
||||
#define BFLB_EFLASH_LOADER_IF_UART_RX_TIMEOUT 8000 /*ms*/
|
||||
#define BFLB_EFLASH_LOADER_HAND_SHAKE_BYTE 0x55
|
||||
#define BFLB_EFLASH_LAODER_HAND_SHAKE_SUSS_COUNT 5
|
||||
|
||||
|
||||
|
||||
#endif
|
495
examples/boot2_iap/blsp_boot2_iap.c
Normal file
495
examples/boot2_iap/blsp_boot2_iap.c
Normal file
@ -0,0 +1,495 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file blsp_boot2.c
|
||||
* @version V1.2
|
||||
* @date
|
||||
* @brief This file is the peripheral case c file
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT(c) 2020 Bouffalo Lab</center></h2>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of Bouffalo Lab nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include "bflb_platform.h"
|
||||
#include "blsp_port.h"
|
||||
#include "blsp_bootinfo.h"
|
||||
#include "blsp_media_boot.h"
|
||||
#include "partition.h"
|
||||
#include "blsp_boot_decompress.h"
|
||||
#include "blsp_common.h"
|
||||
#include "softcrc.h"
|
||||
#include "bflb_eflash_loader_uart.h"
|
||||
#include "hal_uart.h"
|
||||
#include "hal_flash.h"
|
||||
#include "blsp_version.h"
|
||||
|
||||
|
||||
/** @addtogroup BL606_BLSP_Boot2
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup BLSP_BOOT2
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup BLSP_BOOT2_Private_Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*@} end of group BLSP_BOOT2_Private_Macros */
|
||||
|
||||
/** @defgroup BLSP_BOOT2_Private_Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*@} end of group BLSP_BOOT2_Private_Types */
|
||||
|
||||
/** @defgroup BLSP_BOOT2_Private_Variables
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*@} end of group BLSP_BOOT2_Private_Variables */
|
||||
|
||||
/** @defgroup BLSP_BOOT2_Global_Variables
|
||||
* @{
|
||||
*/
|
||||
uint8_t g_boot2_read_buf[BFLB_BOOT2_READBUF_SIZE] __attribute__((section(".noinit_data")));
|
||||
boot_image_config g_boot_img_cfg[2];
|
||||
boot_cpu_config g_boot_cpu_cfg[2]=
|
||||
{
|
||||
/*CPU0 boot cfg*/
|
||||
{
|
||||
.msp_store_addr=0,
|
||||
.pc_store_addr=0,
|
||||
.default_xip_addr=0x23000000,
|
||||
},
|
||||
/*CPU1 boot cfg*/
|
||||
{
|
||||
.msp_store_addr=BFLB_BOOT2_CPU1_APP_MSP_ADDR,
|
||||
.pc_store_addr=BFLB_BOOT2_CPU1_APP_PC_ADDR,
|
||||
.default_xip_addr=0x23000000,
|
||||
}
|
||||
};
|
||||
boot_efuse_hw_config g_efuse_cfg;
|
||||
uint8_t g_ps_mode=BFLB_PSM_ACTIVE;
|
||||
uint8_t g_cpu_count;
|
||||
uint32_t g_user_hash_ignored=0;
|
||||
int32_t blsp_boot2_get_clk_cfg(boot_clk_config *cfg);
|
||||
void blsp_boot2_get_efuse_cfg(boot_efuse_hw_config *g_efuse_cfg);
|
||||
|
||||
/*@} end of group BLSP_BOOT2_Global_Variables */
|
||||
|
||||
/** @defgroup BLSP_BOOT2_Private_Fun_Declaration
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*@} end of group BLSP_BOOT2_Private_Fun_Declaration */
|
||||
|
||||
/** @defgroup BLSP_BOOT2_Private_Functions_User_Define
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*@} end of group BLSP_BOOT2_Private_Functions_User_Define */
|
||||
|
||||
/** @defgroup BLSP_BOOT2_Private_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief Boot2 runs error call back function
|
||||
*
|
||||
* @param log: Log to print
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************/
|
||||
static void blsp_boot2_on_error(void *log)
|
||||
{
|
||||
while(1){
|
||||
if(BFLB_EFLASH_LOADER_HANDSHAKE_SUSS == bflb_eflash_loader_uart_handshake_poll()){
|
||||
bflb_eflash_loader_main();
|
||||
}
|
||||
MSG_ERR("%s\r\n",(char*)log);
|
||||
ARCH_Delay_MS(500);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief Boot2 Dump partition entry
|
||||
*
|
||||
* @param ptEntry: Partition entry pointer to dump
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************/
|
||||
static void blsp_dump_pt_entry(pt_table_entry_config *pt_entry)
|
||||
{
|
||||
MSG("Name=%s\r\n",pt_entry->name);
|
||||
MSG("Age=%d\r\n",(unsigned int)pt_entry->age);
|
||||
MSG("active Index=%d\r\n",(unsigned int)pt_entry->active_index);
|
||||
MSG("active start_address=%08x\r\n",(unsigned int)pt_entry->start_address[pt_entry->active_index]);
|
||||
}
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief Boot2 check XZ FW and do decompression
|
||||
*
|
||||
* @param activeID: Active partition table ID
|
||||
* @param ptStuff: Pointer of partition table stuff
|
||||
* @param ptEntry: Pointer of active entry
|
||||
*
|
||||
* @return 1 for find XZ FW and decompress success, 0 for other cases
|
||||
*
|
||||
*******************************************************************************/
|
||||
#if 0
|
||||
static int BLSP_Boot2_Check_XZ_FW(pt_table_id_type activeID,pt_table_stuff_config *ptStuff,pt_table_entry_config *ptEntry)
|
||||
{
|
||||
uint8_t buf[6];
|
||||
|
||||
if(BFLB_BOOT2_SUCCESS!=blsp_mediaboot_read(ptEntry->start_address[ptEntry->active_index],buf,sizeof(buf))){
|
||||
MSG_ERR("Read fw fail\r\n");
|
||||
return 0;
|
||||
}
|
||||
if(blsp_boot2_dump_critical_flag()){
|
||||
blsp_dump_data(buf,sizeof(buf));
|
||||
}
|
||||
if(blsp_boot2_verify_xz_header(buf)==1){
|
||||
MSG_DBG("XZ image\r\n");
|
||||
if(BFLB_BOOT2_SUCCESS==blsp_boot2_update_fw(activeID,ptStuff,ptEntry)){
|
||||
return 1;
|
||||
}else{
|
||||
MSG_ERR("Img decompress fail\r\n");
|
||||
/* Set flag to make it not boot */
|
||||
ptEntry->active_index=0;
|
||||
ptEntry->start_address[0]=0;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
/****************************************************************************//**
|
||||
* @brief Boot2 copy firmware from OTA region to normal region
|
||||
*
|
||||
* @param activeID: Active partition table ID
|
||||
* @param ptStuff: Pointer of partition table stuff
|
||||
* @param ptEntry: Pointer of active entry
|
||||
*
|
||||
* @return BL_Err_Type
|
||||
*
|
||||
*******************************************************************************/
|
||||
static int blsp_boot2_do_fw_copy(pt_table_id_type active_id,pt_table_stuff_config *pt_stuff,pt_table_entry_config *pt_entry)
|
||||
{
|
||||
uint8_t active_index=pt_entry->active_index;
|
||||
uint32_t src_address=pt_entry->start_address[active_index&0x01];
|
||||
uint32_t dest_address=pt_entry->start_address[!(active_index&0x01)];
|
||||
uint32_t dest_max_size= pt_entry->max_len[!(active_index&0x01)];
|
||||
uint32_t total_len=pt_entry->len;
|
||||
uint32_t deal_len=0;
|
||||
uint32_t cur_len=0;
|
||||
|
||||
if(SUCCESS!=flash_erase_xip(dest_address,dest_address+dest_max_size-1)){
|
||||
MSG_ERR("Erase flash fail");
|
||||
return BFLB_BOOT2_FLASH_ERASE_ERROR;
|
||||
}
|
||||
|
||||
while(deal_len<total_len){
|
||||
cur_len=total_len-deal_len;
|
||||
if(cur_len>sizeof(g_boot2_read_buf)){
|
||||
cur_len=sizeof(g_boot2_read_buf);
|
||||
}
|
||||
if(BFLB_BOOT2_SUCCESS!=blsp_mediaboot_read(src_address,g_boot2_read_buf,cur_len)){
|
||||
MSG_ERR("Read FW fail when copy\r\n");
|
||||
return BFLB_BOOT2_FLASH_READ_ERROR;
|
||||
}
|
||||
if(SUCCESS!=flash_write_xip(dest_address,g_boot2_read_buf,cur_len)){
|
||||
MSG_ERR("Write flash fail");
|
||||
return BFLB_BOOT2_FLASH_WRITE_ERROR;
|
||||
}
|
||||
src_address+=cur_len;
|
||||
dest_address+=cur_len;
|
||||
deal_len+=cur_len;
|
||||
}
|
||||
return BFLB_BOOT2_SUCCESS;
|
||||
}
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief Boot2 deal with one firmware
|
||||
*
|
||||
* @param activeID: Active partition table ID
|
||||
* @param ptStuff: Pointer of partition table stuff
|
||||
* @param ptEntry: Pointer of active entry
|
||||
* @param fwName: Firmware name pointer
|
||||
* @param type: Firmware name ID
|
||||
*
|
||||
* @return 0 for partition table changed,need re-parse,1 for partition table or entry parsed successfully
|
||||
*
|
||||
*******************************************************************************/
|
||||
static int blsp_boot2_deal_one_fw(pt_table_id_type active_id,pt_table_stuff_config *pt_stuff,
|
||||
pt_table_entry_config *pt_entry,uint8_t *fw_name,
|
||||
pt_table_entry_type type)
|
||||
{
|
||||
uint32_t ret;
|
||||
|
||||
if(fw_name!=NULL){
|
||||
MSG_DBG("Get FW:%s\r\n",fw_name);
|
||||
ret=pt_table_get_active_entries_by_name(pt_stuff,fw_name,pt_entry);
|
||||
}else{
|
||||
MSG_DBG("Get FW ID:%d\r\n",type);
|
||||
ret=pt_table_get_active_entries_by_id(pt_stuff,type,pt_entry);
|
||||
}
|
||||
|
||||
if(PT_ERROR_SUCCESS!=ret){
|
||||
MSG_ERR("Entry not found\r\n");
|
||||
}else{
|
||||
blsp_dump_pt_entry(pt_entry);
|
||||
MSG_DBG("Check Img\r\n");
|
||||
//if(BLSP_Boot2_Check_XZ_FW(activeID,ptStuff,ptEntry)==1){
|
||||
//return 0;
|
||||
//}
|
||||
/* Check if this partition need copy */
|
||||
if(pt_entry->active_index>=2){
|
||||
if(BFLB_BOOT2_SUCCESS==blsp_boot2_do_fw_copy(active_id,pt_stuff,pt_entry)){
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief Boot2 Roll back pt entry
|
||||
*
|
||||
* @param activeID: Active partition table ID
|
||||
* @param ptStuff: Pointer of partition table stuff
|
||||
* @param ptEntry: Pointer of active entry
|
||||
*
|
||||
* @return boot_error_code
|
||||
*
|
||||
*******************************************************************************/
|
||||
#ifdef BLSP_BOOT2_ROLLBACK
|
||||
static int32_t blsp_boot2_rollback_ptentry(pt_table_id_type active_id,pt_table_stuff_config *pt_stuff,pt_table_entry_config *pt_entry)
|
||||
{
|
||||
int32_t ret;
|
||||
|
||||
pt_entry->active_index=!(pt_entry->active_index&0x01);
|
||||
pt_entry->age++;
|
||||
ret=pt_table_update_entry((pt_table_id_type)(!active_id),pt_stuff,pt_entry);
|
||||
if(ret!=PT_ERROR_SUCCESS){
|
||||
MSG_ERR("Update PT entry fail\r\n");
|
||||
return BFLB_BOOT2_FAIL;
|
||||
}
|
||||
return BFLB_BOOT2_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*@} end of group BLSP_BOOT2_Private_Functions */
|
||||
|
||||
/** @defgroup BLSP_BOOT2_Public_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief Boot2 main function
|
||||
*
|
||||
* @param None
|
||||
*
|
||||
* @return Return value
|
||||
*
|
||||
*******************************************************************************/
|
||||
int main(void)
|
||||
{
|
||||
uint32_t ret=0,i=0;
|
||||
pt_table_stuff_config pt_table_stuff[2];
|
||||
pt_table_id_type active_id;
|
||||
/* Init to zero incase only one cpu boot up*/
|
||||
pt_table_entry_config pt_entry[BFLB_BOOT2_CPU_MAX]={0};
|
||||
uint32_t boot_header_addr[BFLB_BOOT2_CPU_MAX]={0};
|
||||
uint8_t boot_rollback[BFLB_BOOT2_CPU_MAX]={0};
|
||||
uint8_t pt_parsed=1;
|
||||
#ifdef BLSP_BOOT2_ROLLBACK
|
||||
uint8_t roll_backed=0;
|
||||
#endif
|
||||
uint8_t temp_mode=0;
|
||||
//boot_clk_config clk_cfg;
|
||||
uint8_t flash_cfg_buf[4+sizeof(SPI_Flash_Cfg_Type)+4]={0};
|
||||
|
||||
|
||||
bflb_eflash_loader_uart_init();
|
||||
bflb_platform_init(0);
|
||||
flash_init();
|
||||
|
||||
bflb_platform_print_set(blsp_boot2_get_log_disable_flag());
|
||||
bflb_platform_deinit_time();
|
||||
if(blsp_boot2_get_feature_flag()==BLSP_BOOT2_CP_FLAG){
|
||||
MSG_DBG("BLSP_Boot2_CP:%s,%s\r\n",__DATE__,__TIME__);
|
||||
}else if(blsp_boot2_get_feature_flag()==BLSP_BOOT2_MP_FLAG){
|
||||
MSG_DBG("BLSP_Boot2_MC:%s,%s\r\n",__DATE__,__TIME__);
|
||||
}else{
|
||||
MSG_DBG("BLSP_Boot2_SP:%s,%s\r\n",__DATE__,__TIME__);
|
||||
}
|
||||
#ifdef BL_SDK_VER
|
||||
MSG_DBG("SDK:%s\r\n",BL_SDK_VER);
|
||||
#else
|
||||
MSG_DBG("MCU SDK:%s\r\n",MCU_SDK_VERSION);
|
||||
MSG_DBG("BSP Driver:%s\r\n",BSP_DRIVER_VERSION);
|
||||
MSG_DBG("BSP Common:%s\r\n",BSP_COMMON_VERSION);
|
||||
#endif
|
||||
if(blsp_boot2_dump_critical_flag()){
|
||||
//blsp_dump_data(&clk_cfg,16);
|
||||
}
|
||||
|
||||
MSG_DBG("Get efuse config\r\n");
|
||||
blsp_boot2_get_efuse_cfg(&g_efuse_cfg);
|
||||
|
||||
/* Reset Sec_Eng for using */
|
||||
blsp_boot2_reset_sec_eng();
|
||||
|
||||
if(blsp_boot2_get_feature_flag()!=BLSP_BOOT2_SP_FLAG){
|
||||
/* Get cpu count info */
|
||||
g_cpu_count=blsp_boot2_get_cpu_count();
|
||||
}else{
|
||||
g_cpu_count=1;
|
||||
}
|
||||
|
||||
/* Get power save mode */
|
||||
g_ps_mode=blsp_read_power_save_mode();
|
||||
|
||||
/* Get User specified FW */
|
||||
//ARCH_MemCpy_Fast(userFwName,blsp_get_user_specified_fw(),4);
|
||||
if(blsp_boot2_8m_support_flag()){
|
||||
/* Set flash operation function, read via sbus */
|
||||
pt_table_set_flash_operation(flash_erase_xip,flash_write_xip,flash_read_xip);
|
||||
}else{
|
||||
/* Set flash operation function, read via xip */
|
||||
pt_table_set_flash_operation(flash_erase_xip,flash_write_xip,flash_read_xip);
|
||||
}
|
||||
|
||||
while(1){
|
||||
|
||||
temp_mode=0;
|
||||
do{
|
||||
active_id=pt_table_get_active_partition_need_lock(pt_table_stuff);
|
||||
|
||||
if(PT_TABLE_ID_INVALID==active_id){
|
||||
blsp_boot2_on_error("No valid PT\r\n");
|
||||
}
|
||||
MSG_DBG("Active PT:%d,%d\r\n",active_id,pt_table_stuff[active_id].pt_table.age);
|
||||
|
||||
|
||||
pt_parsed=blsp_boot2_deal_one_fw(active_id,&pt_table_stuff[active_id],&pt_entry[0],NULL,PT_ENTRY_FW_CPU0);
|
||||
if(pt_parsed==0){
|
||||
continue;
|
||||
}
|
||||
|
||||
pt_parsed=1;
|
||||
}while(pt_parsed==0);
|
||||
|
||||
|
||||
|
||||
/* Pass data to App*/
|
||||
blsp_boot2_pass_parameter(NULL,0);
|
||||
/* Pass active partition table ID */
|
||||
blsp_boot2_pass_parameter(&active_id,4);
|
||||
/* Pass active partition table content: table header+ entries +crc32 */
|
||||
blsp_boot2_pass_parameter(&pt_table_stuff[active_id],sizeof(pt_table_config)+4+
|
||||
pt_table_stuff[active_id].pt_table.entryCnt*sizeof(pt_table_entry_config));
|
||||
/* Pass flash config */
|
||||
if(pt_entry[0].start_address[pt_entry[0].active_index]!=0){
|
||||
XIP_SFlash_Read_Via_Cache_Need_Lock(BLSP_BOOT2_XIP_BASE+pt_entry[0].start_address[pt_entry[0].active_index]+8,flash_cfg_buf,sizeof(flash_cfg_buf));
|
||||
/* Include magic and CRC32 */
|
||||
blsp_boot2_pass_parameter(flash_cfg_buf,sizeof(flash_cfg_buf));
|
||||
}
|
||||
|
||||
MSG_DBG("Boot start\r\n");
|
||||
|
||||
for(i=0;i<g_cpu_count;i++){
|
||||
boot_header_addr[i]=pt_entry[i].start_address[pt_entry[i].active_index];
|
||||
}
|
||||
#ifdef BLSP_BOOT2_ROLLBACK
|
||||
/* Test mode is not need roll back */
|
||||
if(roll_backed==0 && temp_mode==0){
|
||||
ret=blsp_mediaboot_main(boot_header_addr,boot_rollback,1);
|
||||
}else{
|
||||
ret=blsp_mediaboot_main(boot_header_addr,boot_rollback,0);
|
||||
}
|
||||
#else
|
||||
ret=blsp_mediaboot_main(boot_header_addr,boot_rollback,0);
|
||||
#endif
|
||||
|
||||
|
||||
/* Fail in temp mode,continue to boot normal image */
|
||||
if(temp_mode==1){
|
||||
continue;
|
||||
}
|
||||
#ifdef BLSP_BOOT2_ROLLBACK
|
||||
/* If rollback is done, we still fail, break */
|
||||
if(roll_backed){
|
||||
break;
|
||||
}
|
||||
MSG_DBG("Boot return %d\r\n",ret);
|
||||
MSG_DBG("Check Rollback\r\n");
|
||||
for(i=0;i<g_cpu_count;i++){
|
||||
if(boot_rollback[i]!=0){
|
||||
MSG_DBG("Rollback %d\r\n",i);
|
||||
if(BFLB_BOOT2_SUCCESS==blsp_boot2_rollback_ptentry(active_id,&pt_table_stuff[active_id],&pt_entry[i])){
|
||||
roll_backed=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* If need no rollback, boot fail due to other reseaon instead of imgae issue,break */
|
||||
if(roll_backed==0){
|
||||
break;
|
||||
}
|
||||
#else
|
||||
break;
|
||||
#endif
|
||||
|
||||
}
|
||||
/* We should never get here unless boot fail */
|
||||
MSG_ERR("Media boot return %d\r\n",ret);
|
||||
while(1){
|
||||
if(BFLB_EFLASH_LOADER_HANDSHAKE_SUSS == bflb_eflash_loader_uart_handshake_poll()){
|
||||
bflb_eflash_loader_main();
|
||||
}
|
||||
MSG_ERR("BLSP boot2 fail\r\n");
|
||||
ARCH_Delay_MS(500);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void bfl_main()
|
||||
{
|
||||
main();
|
||||
}
|
||||
|
||||
/*@} end of group BLSP_BOOT2_Public_Functions */
|
||||
|
||||
/*@} end of group BLSP_BOOT2 */
|
||||
|
||||
/*@} end of group BL606_BLSP_Boot2 */
|
203
examples/boot2_iap/blsp_boot2_iap_flash.ld
Normal file
203
examples/boot2_iap/blsp_boot2_iap_flash.ld
Normal file
@ -0,0 +1,203 @@
|
||||
/****************************************************************************************
|
||||
* @file map.txt
|
||||
*
|
||||
* @brief This file is the map file (gnuarm or armgcc).
|
||||
*
|
||||
* Copyright (C) BouffaloLab 2018
|
||||
*
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/* configure the CPU type */
|
||||
OUTPUT_ARCH( "riscv" )
|
||||
/* link with the standard c library */
|
||||
INPUT(-lc)
|
||||
/* link with the standard GCC library */
|
||||
INPUT(-lgcc)
|
||||
/* configure the entry point */
|
||||
ENTRY(_enter)
|
||||
|
||||
StackSize = 0x1000; /* 4KB */
|
||||
HeapSize = 0x1000; /* 4KB */
|
||||
|
||||
MEMORY
|
||||
{
|
||||
xip_memory (rx) : ORIGIN = 0x23000000, LENGTH = 64K
|
||||
itcm_memory (rx) : ORIGIN = 0x22014000, LENGTH = 16K
|
||||
dtcm_memory (rx) : ORIGIN = 0x42018000, LENGTH = 32K
|
||||
ram_memory (!rx) : ORIGIN = 0x42020000, LENGTH = 60K
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
PROVIDE(__metal_chicken_bit = 0);
|
||||
|
||||
.text :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__text_code_start__ = .;
|
||||
|
||||
KEEP (*(.text.metal.init.enter))
|
||||
KEEP (*(SORT_NONE(.init)))
|
||||
/* section information for finsh shell */
|
||||
. = ALIGN(4);
|
||||
_shell_command_start = .;
|
||||
KEEP(*(shellCommand))
|
||||
_shell_command_end = .;
|
||||
|
||||
*(.text)
|
||||
*(.text.*)
|
||||
*(.rodata)
|
||||
*(.rodata.*)
|
||||
*(.srodata)
|
||||
*(.srodata.*)
|
||||
|
||||
. = ALIGN(4);
|
||||
__text_code_end__ = .;
|
||||
} > xip_memory
|
||||
|
||||
. = ALIGN(4);
|
||||
__itcm_load_addr = .;
|
||||
|
||||
.itcm_region : AT (__itcm_load_addr)
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__tcm_code_start__ = .;
|
||||
*(.tcm_code)
|
||||
*(.tcm_const)
|
||||
*(.sclock_rlt_code)
|
||||
*(.sclock_rlt_const)
|
||||
*bl602_romapi.o(.text)
|
||||
*bl602_romapi.o(.text.*)
|
||||
*bl602_romapi.o(.rodata)
|
||||
*bl602_romapi.o(.rodata.*)
|
||||
*bl602_romapi.o(.srodata)
|
||||
*bl602_romapi.o(.srodata.*)
|
||||
. = ALIGN(4);
|
||||
__tcm_code_end__ = .;
|
||||
|
||||
} > itcm_memory
|
||||
|
||||
__dtcm_load_addr = __itcm_load_addr + SIZEOF(.itcm_region);
|
||||
|
||||
.dtcm_region : AT (__dtcm_load_addr)
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__tcm_data_start__ = .;
|
||||
|
||||
*(.tcm_data)
|
||||
/* *finger_print.o(.data*) */
|
||||
|
||||
. = ALIGN(4);
|
||||
__tcm_data_end__ = .;
|
||||
} > dtcm_memory
|
||||
|
||||
/* .heap_dummy section doesn't contains any symbols. It is only
|
||||
* used for linker to calculate size of heap sections, and assign
|
||||
* values to heap symbols later */
|
||||
.heap_dummy (NOLOAD):
|
||||
{
|
||||
. = ALIGN(0x4);
|
||||
. = . + HeapSize;
|
||||
. = ALIGN(0x4);
|
||||
} > dtcm_memory
|
||||
|
||||
_HeapBase = ORIGIN(dtcm_memory) + LENGTH(dtcm_memory) - StackSize - HeapSize;
|
||||
_HeapSize = HeapSize;
|
||||
|
||||
/* Check if data + heap + stack exceeds RAM limit */
|
||||
ASSERT(_HeapBase >= __tcm_data_end__, "region RAM overflowed with stack")
|
||||
|
||||
/*************************************************************************/
|
||||
/* .stack_dummy section doesn't contains any symbols. It is only
|
||||
* used for linker to calculate size of stack sections, and assign
|
||||
* values to stack symbols later */
|
||||
.stack_dummy (NOLOAD):
|
||||
{
|
||||
. = ALIGN(0x4);
|
||||
. = . + StackSize;
|
||||
. = ALIGN(0x4);
|
||||
} > dtcm_memory
|
||||
|
||||
/* Set stack top to end of RAM, and stack limit move down by
|
||||
* size of stack_dummy section */
|
||||
__StackTop = ORIGIN(dtcm_memory) + LENGTH(dtcm_memory);
|
||||
__StackLimit = __StackTop - SIZEOF(.stack_dummy);
|
||||
|
||||
/* Check if data + heap + stack exceeds RAM limit */
|
||||
ASSERT(__StackLimit >= __tcm_data_end__, "region RAM overflowed with stack")
|
||||
/*************************************************************************/
|
||||
|
||||
__system_ram_load_addr = __dtcm_load_addr + SIZEOF(.dtcm_region);
|
||||
|
||||
.system_ram_data_region : AT (__system_ram_load_addr)
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__system_ram_data_start__ = .;
|
||||
|
||||
*(.system_ram)
|
||||
|
||||
. = ALIGN(4);
|
||||
__system_ram_data_end__ = .;
|
||||
} > ram_memory
|
||||
|
||||
__ram_load_addr = __system_ram_load_addr + SIZEOF(.system_ram_data_region);
|
||||
|
||||
/* Data section */
|
||||
RAM_DATA : AT (__ram_load_addr)
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__ram_data_start__ = .;
|
||||
|
||||
PROVIDE( __global_pointer$ = . + 0x800 );
|
||||
|
||||
*(.data)
|
||||
*(.data.*)
|
||||
*(.sdata)
|
||||
*(.sdata.*)
|
||||
*(.sdata2)
|
||||
*(.sdata2.*)
|
||||
|
||||
. = ALIGN(4);
|
||||
__ram_data_end__ = .;
|
||||
} > ram_memory
|
||||
|
||||
.bss (NOLOAD) :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__bss_start__ = .;
|
||||
|
||||
*(.bss*)
|
||||
*(.sbss*)
|
||||
*(COMMON)
|
||||
|
||||
. = ALIGN(4);
|
||||
__bss_end__ = .;
|
||||
} > ram_memory
|
||||
|
||||
.noinit_data (NOLOAD) :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__noinit_data_start__ = .;
|
||||
|
||||
*(.noinit_data*)
|
||||
|
||||
. = ALIGN(4);
|
||||
__noinit_data_end__ = .;
|
||||
} > ram_memory
|
||||
|
||||
.heap (NOLOAD):
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__HeapBase = .;
|
||||
|
||||
/*__end__ = .;*/
|
||||
/*end = __end__;*/
|
||||
KEEP(*(.heap*))
|
||||
|
||||
. = ALIGN(4);
|
||||
__HeapLimit = .;
|
||||
} > ram_memory
|
||||
|
||||
}
|
||||
|
299
examples/boot2_iap/blsp_boot_decompress.c
Normal file
299
examples/boot2_iap/blsp_boot_decompress.c
Normal file
@ -0,0 +1,299 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file blsp_boot_decompress.c
|
||||
* @version V1.2
|
||||
* @date
|
||||
* @brief This file is the peripheral case c file
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT(c) 2018 Bouffalo Lab</center></h2>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of Bouffalo Lab nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include "xz.h"
|
||||
#include "blsp_bootinfo.h"
|
||||
#include "blsp_common.h"
|
||||
#include "blsp_media_boot.h"
|
||||
#include "bflb_platform.h"
|
||||
#include "softcrc.h"
|
||||
#include "partition.h"
|
||||
#include "hal_flash.h"
|
||||
|
||||
|
||||
/** @addtogroup BL606_BLSP_Boot2
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup BLSP_BOOT_DECOMPRESS
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup BLSP_BOOT_DECOMPRESS_Private_Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*@} end of group BLSP_BOOT_DECOMPRESS_Private_Macros */
|
||||
|
||||
/** @defgroup BLSP_BOOT_DECOMPRESS_Private_Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*@} end of group BLSP_BOOT_DECOMPRESS_Private_Types */
|
||||
|
||||
/** @defgroup BLSP_BOOT_DECOMPRESS_Private_Variables
|
||||
* @{
|
||||
*/
|
||||
static uint8_t g_xz_output[BFLB_BOOT2_READBUF_SIZE] __attribute__((section(".noinit_data")));
|
||||
static uint8_t g_malloc_buf[64*1024] __attribute__((section(".noinit_data")));
|
||||
|
||||
/*@} end of group BLSP_BOOT_DECOMPRESS_Private_Variables */
|
||||
|
||||
/** @defgroup BLSP_BOOT_DECOMPRESS_Global_Variables
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*@} end of group BLSP_BOOT_DECOMPRESS_Global_Variables */
|
||||
|
||||
/** @defgroup BLSP_BOOT_DECOMPRESS_Private_Fun_Declaration
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*@} end of group BLSP_BOOT_DECOMPRESS_Private_Fun_Declaration */
|
||||
|
||||
/** @defgroup BLSP_BOOT_DECOMPRESS_Private_Functions_User_Define
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*@} end of group BLSP_BOOT_DECOMPRESS_Private_Functions_User_Define */
|
||||
|
||||
/** @defgroup BLSP_BOOT_DECOMPRESS_Private_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief Decompress XZ Firmware
|
||||
*
|
||||
* @param srcAddress: Source address on flash
|
||||
* @param destAddress: Destination address on flash
|
||||
* @param destMaxSize: Destination flash region size for erase
|
||||
* @param pDestSize: Pointer for output destination firmware size
|
||||
*
|
||||
* @return Decompress result status
|
||||
*
|
||||
*******************************************************************************/
|
||||
static int32_t blsp_boot2_fw_decompress(uint32_t src_address,uint32_t dest_address,uint32_t dest_max_size,uint32_t *p_dest_size)
|
||||
{
|
||||
struct xz_buf b;
|
||||
struct xz_dec *s;
|
||||
enum xz_ret ret;
|
||||
|
||||
*p_dest_size=0;
|
||||
if(dest_max_size>0){
|
||||
flash_erase_xip(dest_address,dest_address+dest_max_size-1);
|
||||
}
|
||||
xz_crc32_init();
|
||||
simple_malloc_init(g_malloc_buf,sizeof(g_malloc_buf));
|
||||
|
||||
/*
|
||||
* Support up to 32k dictionary. The actually needed memory
|
||||
* is allocated once the headers have been parsed.
|
||||
*/
|
||||
s = xz_dec_init(XZ_PREALLOC, 1 << 15);
|
||||
if (s == NULL) {
|
||||
MSG_ERR("Memory allocation failed\n");
|
||||
return BFLB_BOOT2_MEM_ERROR;
|
||||
}
|
||||
|
||||
b.in = g_boot2_read_buf;
|
||||
b.in_pos = 0;
|
||||
b.in_size = 0;
|
||||
b.out = g_xz_output;
|
||||
b.out_pos = 0;
|
||||
b.out_size = sizeof(g_xz_output);
|
||||
|
||||
while (1) {
|
||||
if (b.in_pos == b.in_size) {
|
||||
MSG_DBG("XZ Feeding\r\n");
|
||||
if(BFLB_BOOT2_SUCCESS!=blsp_mediaboot_read(src_address,g_boot2_read_buf,sizeof(g_boot2_read_buf))){
|
||||
MSG_ERR("Read XZFW fail\r\n");
|
||||
return BFLB_BOOT2_FLASH_READ_ERROR;
|
||||
}
|
||||
b.in_size = sizeof(g_boot2_read_buf);
|
||||
b.in_pos = 0;
|
||||
src_address+=sizeof(g_boot2_read_buf);
|
||||
}
|
||||
|
||||
ret = xz_dec_run(s, &b);
|
||||
|
||||
if (b.out_pos == sizeof(g_xz_output)) {
|
||||
//if (fwrite(out, 1, b.out_pos, stdout) != b.out_pos) {
|
||||
// msg = "Write error\n";
|
||||
// goto error;
|
||||
//}
|
||||
MSG_DBG("XZ outputing\r\n");
|
||||
if(dest_max_size>0){
|
||||
flash_write_xip(dest_address,g_xz_output,sizeof(g_xz_output));
|
||||
}
|
||||
dest_address+=sizeof(g_xz_output);
|
||||
*p_dest_size+=sizeof(g_xz_output);
|
||||
b.out_pos = 0;
|
||||
}
|
||||
|
||||
if (ret == XZ_OK)
|
||||
continue;
|
||||
|
||||
//if (fwrite(out, 1, b.out_pos, stdout) != b.out_pos
|
||||
// || fclose(stdout)) {
|
||||
// msg = "Write error\n";
|
||||
// goto error;
|
||||
//}
|
||||
if(b.out_pos>0){
|
||||
if(dest_max_size>0){
|
||||
flash_write_xip(dest_address,g_xz_output,b.out_pos);
|
||||
}
|
||||
dest_address+=b.out_pos;
|
||||
*p_dest_size+=b.out_pos;
|
||||
}
|
||||
|
||||
switch (ret) {
|
||||
case XZ_STREAM_END:
|
||||
xz_dec_end(s);
|
||||
return 0;
|
||||
|
||||
case XZ_MEM_ERROR:
|
||||
MSG_ERR("Memory allocation failed\n");
|
||||
goto error;
|
||||
|
||||
case XZ_MEMLIMIT_ERROR:
|
||||
MSG_ERR("Memory usage limit reached\n");
|
||||
goto error;
|
||||
|
||||
case XZ_FORMAT_ERROR:
|
||||
MSG_ERR("Not a .xz file\n");
|
||||
goto error;
|
||||
|
||||
case XZ_OPTIONS_ERROR:
|
||||
MSG_ERR("Unsupported options in the .xz headers\n");
|
||||
goto error;
|
||||
|
||||
case XZ_DATA_ERROR:
|
||||
case XZ_BUF_ERROR:
|
||||
MSG_ERR("File is corrupt\n");
|
||||
goto error;
|
||||
|
||||
default:
|
||||
MSG_ERR("XZ Bug!\n");
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
error:
|
||||
xz_dec_end(s);
|
||||
return BFLB_BOOT2_FAIL;
|
||||
}
|
||||
|
||||
/*@} end of group BLSP_BOOT_DECOMPRESS_Private_Functions */
|
||||
|
||||
/** @defgroup BLSP_BOOT_DECOMPRESS_Public_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief Update decompressed firmware to flash according to XZ firmware
|
||||
*
|
||||
* @param activeID: Active partition table ID
|
||||
* @param ptStuff: Pointer of partition table stuff
|
||||
* @param ptEntry: Pointer of active entry
|
||||
*
|
||||
* @return XZ firmware update result status
|
||||
*
|
||||
*******************************************************************************/
|
||||
int32_t blsp_boot2_update_fw(pt_table_id_type active_id,pt_table_stuff_config *pt_stuff,pt_table_entry_config *pt_entry)
|
||||
{
|
||||
uint8_t active_index=pt_entry->active_index;
|
||||
uint32_t new_fw_len;
|
||||
int32_t ret;
|
||||
#ifdef BLSP_BOOT2_ROLLBACK
|
||||
/* Try to check Image integrity: try to decompress */
|
||||
if(BFLB_BOOT2_SUCCESS!=blsp_boot2_fw_decompress(pt_entry->start_address[active_index],
|
||||
pt_entry->start_address[!(active_index&0x01)],
|
||||
0,&new_fw_len)){
|
||||
/* Decompress fail, try to rollback to old one */
|
||||
pt_entry->active_index=!(active_index&0x01);
|
||||
pt_entry->age++;
|
||||
ret=pt_table_update_entry((pt_table_id_type)(!active_id),pt_stuff,pt_entry);
|
||||
if(ret!=PT_ERROR_SUCCESS){
|
||||
MSG_ERR("Rollback Update Partition table entry fail\r\n");
|
||||
return BFLB_BOOT2_FAIL;
|
||||
}
|
||||
return BFLB_BOOT2_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
/* Do decompress */
|
||||
if(BFLB_BOOT2_SUCCESS==blsp_boot2_fw_decompress(pt_entry->start_address[active_index],
|
||||
pt_entry->start_address[!(active_index&0x01)],
|
||||
pt_entry->max_len[!(active_index&0x01)],&new_fw_len)){
|
||||
pt_entry->active_index=!(active_index&0x01);
|
||||
pt_entry->len=new_fw_len;
|
||||
pt_entry->age++;
|
||||
ret=pt_table_update_entry((pt_table_id_type)(!active_id),pt_stuff,pt_entry);
|
||||
if(ret!=PT_ERROR_SUCCESS){
|
||||
MSG_ERR("Do Decompress Update Partition table entry fail\r\n");
|
||||
return BFLB_BOOT2_FAIL;
|
||||
}
|
||||
}else{
|
||||
MSG_ERR("XZ Decompress fail\r\n");
|
||||
return BFLB_BOOT2_FAIL;
|
||||
}
|
||||
return BFLB_BOOT2_SUCCESS;
|
||||
}
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief Check if buffer is XZ header
|
||||
*
|
||||
* @param buffer: Buffer of firmware
|
||||
*
|
||||
* @return 1 for XZ firmware and 0 for not
|
||||
*
|
||||
*******************************************************************************/
|
||||
int blsp_boot2_verify_xz_header(uint8_t *buffer)
|
||||
{
|
||||
const uint8_t xz_header[6] = { 0xFD, '7', 'z', 'X', 'Z', 0x00 };
|
||||
//const uint8_t xz_header[6] = { 0x42, 0x46, 0x4e, 0x50, 0x01, 0x00 };
|
||||
if (buffer) {
|
||||
if (!memcmp(buffer, xz_header, 6)){
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*@} end of group BLSP_BOOT_DECOMPRESS_Public_Functions */
|
||||
|
||||
/*@} end of group BLSP_BOOT_DECOMPRESS */
|
||||
|
||||
/*@} end of group BL606_BLSP_Boot2 */
|
79
examples/boot2_iap/blsp_boot_decompress.h
Normal file
79
examples/boot2_iap/blsp_boot_decompress.h
Normal file
@ -0,0 +1,79 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file blsp_boot_decompress.h
|
||||
* @version V1.2
|
||||
* @date
|
||||
* @brief This file is the peripheral case header file
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT(c) 2018 Bouffalo Lab</center></h2>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of Bouffalo Lab nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef __BLSP_BOOT_DECOMPRESS_H__
|
||||
#define __BLSP_BOOT_DECOMPRESS_H__
|
||||
|
||||
#include "stdint.h"
|
||||
|
||||
/** @addtogroup BL606_BLSP_Boot2
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup BLSP_BOOT_DECOMPRESS
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup BLSP_BOOT_DECOMPRESS_Public_Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*@} end of group BLSP_BOOT_DECOMPRESS_Public_Types */
|
||||
|
||||
/** @defgroup BLSP_BOOT_DECOMPRESS_Public_Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*@} end of group BLSP_BOOT_DECOMPRESS_Public_Constants */
|
||||
|
||||
/** @defgroup BLSP_BOOT_DECOMPRESS_Public_Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*@} end of group BLSP_BOOT_DECOMPRESS_Public_Macros */
|
||||
|
||||
/** @defgroup BLSP_BOOT_DECOMPRESS_Public_Functions
|
||||
* @{
|
||||
*/
|
||||
int32_t blsp_boot2_update_fw(pt_table_id_type activeID,pt_table_stuff_config *ptStuff,pt_table_entry_config *ptEntry);
|
||||
int blsp_boot2_verify_xz_header(uint8_t *buffer);
|
||||
|
||||
/*@} end of group BLSP_BOOT_DECOMPRESS_Public_Functions */
|
||||
|
||||
/*@} end of group BLSP_BOOT_DECOMPRESS */
|
||||
|
||||
/*@} end of group BL606_BLSP_Boot2 */
|
||||
|
||||
#endif /* __BLSP_BOOT_DECOMPRESS_H__ */
|
430
examples/boot2_iap/blsp_boot_parser.c
Normal file
430
examples/boot2_iap/blsp_boot_parser.c
Normal file
@ -0,0 +1,430 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file blsp_boot_parser.c
|
||||
* @version V1.2
|
||||
* @date
|
||||
* @brief This file is the peripheral case c file
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT(c) 2018 Bouffalo Lab</center></h2>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of Bouffalo Lab nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include "blsp_common.h"
|
||||
#include "bflb_platform.h"
|
||||
#include "blsp_bootinfo.h"
|
||||
#include "blsp_boot_parser.h"
|
||||
#include "softcrc.h"
|
||||
#include "blsp_port.h"
|
||||
|
||||
/** @addtogroup BL606_BLSP_Boot2
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup BLSP_BOOT_PARSER
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup BLSP_BOOT_PARSER_Private_Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*@} end of group BLSP_BOOT_PARSER_Private_Macros */
|
||||
|
||||
/** @defgroup BLSP_BOOT_PARSER_Private_Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*@} end of group BLSP_BOOT_PARSER_Private_Types */
|
||||
|
||||
/** @defgroup BLSP_BOOT_PARSER_Private_Variables
|
||||
* @{
|
||||
*/
|
||||
static uint32_t g_sha_tmp_buf[16]={0};
|
||||
static uint32_t g_padding[16]={0};
|
||||
SEC_Eng_SHA256_Ctx g_sha_ctx;
|
||||
extern uint32_t g_user_hash_ignored;
|
||||
/*@} end of group BLSP_BOOT_PARSER_Private_Variables */
|
||||
|
||||
/** @defgroup BLSP_BOOT_PARSER_Global_Variables
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*@} end of group BLSP_BOOT_PARSER_Global_Variables */
|
||||
|
||||
/** @defgroup BLSP_BOOT_PARSER_Private_Fun_Declaration
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*@} end of group BLSP_BOOT_PARSER_Private_Fun_Declaration */
|
||||
|
||||
/** @defgroup BLSP_BOOT_PARSER_Private_Functions_User_Define
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*@} end of group BLSP_BOOT_PARSER_Private_Functions_User_Define */
|
||||
|
||||
/** @defgroup BLSP_BOOT_PARSER_Private_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief Check if the input public key is the same as burned in the efuse
|
||||
*
|
||||
* @param cpu_type: CPU Type
|
||||
* @param pkhash: Public key hash pointer
|
||||
*
|
||||
* @return 1 for valid and 0 for invalid
|
||||
*
|
||||
*******************************************************************************/
|
||||
static uint32_t blsp_boot_parse_is_pkhash_valid(uint8_t cpu_type,uint8_t *pkhash)
|
||||
{
|
||||
if(cpu_type==BFLB_BOOT2_CPU_0){
|
||||
if(0==memcmp(g_efuse_cfg.pk_hash_cpu0,pkhash,BFLB_BOOT2_PK_HASH_SIZE)){
|
||||
return 1;
|
||||
}
|
||||
}else if(cpu_type==BFLB_BOOT2_CPU_1){
|
||||
if(0==memcmp(g_efuse_cfg.pk_hash_cpu1,pkhash,BFLB_BOOT2_PK_HASH_SIZE)){
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*@} end of group BLSP_BOOT_PARSER_Private_Functions */
|
||||
|
||||
/** @defgroup BLSP_BOOT_PARSER_Public_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief Check if the input public key is the same as burned in the efuse
|
||||
*
|
||||
* @param g_boot_img_cfg: Boot image config pointer
|
||||
* @param data: Image data pointer
|
||||
*
|
||||
* @return boot_error_code type
|
||||
*
|
||||
*******************************************************************************/
|
||||
int32_t blsp_boot_parse_bootheader(boot_image_config *g_boot_img_cfg,uint8_t *data)
|
||||
{
|
||||
boot_header_config *header=(boot_header_config *)data;
|
||||
uint32_t crc;
|
||||
uint32_t crc_pass=0;
|
||||
uint32_t i=0;
|
||||
uint32_t *phash=(uint32_t *)header->hash;
|
||||
|
||||
if(header->bootCfg.bval.crcIgnore==1&&header->crc32==BFLB_BOOT2_DEADBEEF_VAL){
|
||||
MSG_DBG("Crc ignored\r\n");
|
||||
crc_pass=1;
|
||||
}else{
|
||||
crc=BFLB_Soft_CRC32((uint8_t *)header,sizeof(boot_header_config)-sizeof(header->crc32));
|
||||
if(header->crc32==crc){
|
||||
crc_pass=1;
|
||||
}
|
||||
}
|
||||
if(crc_pass){
|
||||
if(header->bootCfg.bval.notLoadInBoot){
|
||||
return BFLB_BOOT2_IMG_BOOTHEADER_NOT_LOAD_ERROR;
|
||||
}
|
||||
|
||||
/* Get which CPU's img it is*/
|
||||
for(i=0;i<BFLB_BOOT2_CPU_MAX;i++){
|
||||
if(0==memcmp((void *)&header->magicCode,BFLB_BOOT2_CPU0_MAGIC,
|
||||
sizeof(header->magicCode))){
|
||||
break;
|
||||
}else if(0==memcmp((void *)&header->magicCode,BFLB_BOOT2_CPU1_MAGIC,
|
||||
sizeof(header->magicCode))){
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(i==BFLB_BOOT2_CPU_MAX){
|
||||
/* No cpu img magic match */
|
||||
MSG_ERR("Magic code error\r\n");
|
||||
return BFLB_BOOT2_IMG_BOOTHEADER_MAGIC_ERROR;
|
||||
}
|
||||
|
||||
g_boot_img_cfg->cpu_type=i;
|
||||
g_boot_img_cfg->entry_point=0;
|
||||
/* Set image valid 0 as default */
|
||||
g_boot_img_cfg->img_valid=0;
|
||||
|
||||
/* Deal with pll config */
|
||||
|
||||
/* Encrypt and sign */
|
||||
g_boot_img_cfg->encrypt_type=header->bootCfg.bval.encrypt_type;
|
||||
g_boot_img_cfg->sign_type=header->bootCfg.bval.sign;
|
||||
g_boot_img_cfg->key_sel=header->bootCfg.bval.key_sel;
|
||||
|
||||
/* Xip relative */
|
||||
g_boot_img_cfg->no_segment=header->bootCfg.bval.no_segment;
|
||||
g_boot_img_cfg->cache_enable=header->bootCfg.bval.cache_enable;
|
||||
g_boot_img_cfg->aes_region_lock=header->bootCfg.bval.aes_region_lock;
|
||||
g_boot_img_cfg->halt_cpu1=header->bootCfg.bval.halt_cpu1;
|
||||
g_boot_img_cfg->cache_way_disable=header->bootCfg.bval.cache_way_disable;
|
||||
g_boot_img_cfg->hash_ignore=header->bootCfg.bval.hash_ignore;
|
||||
|
||||
/* Firmware len*/
|
||||
g_boot_img_cfg->img_segment_info.img_len=header->img_segment_info.img_len;
|
||||
|
||||
/* Boot entry and flash offset */
|
||||
g_boot_img_cfg->entry_point=header->bootEntry;
|
||||
g_boot_img_cfg->img_start.flash_offset=header->img_start.flash_offset;
|
||||
|
||||
MSG_DBG("sign %d,encrypt:%d\r\n",g_boot_img_cfg->sign_type,
|
||||
g_boot_img_cfg->encrypt_type);
|
||||
|
||||
/* Check encrypt and sign match*/
|
||||
if(g_efuse_cfg.encrypted[i]!=0){
|
||||
if(g_boot_img_cfg->encrypt_type==0){
|
||||
MSG_ERR("Encrypt not fit\r\n");
|
||||
return BFLB_BOOT2_IMG_BOOTHEADER_ENCRYPT_NOTFIT;
|
||||
}
|
||||
}
|
||||
|
||||
if(g_efuse_cfg.sign[i]^g_boot_img_cfg->sign_type){
|
||||
MSG_ERR("sign not fit\r\n");
|
||||
g_boot_img_cfg->sign_type=g_efuse_cfg.sign[i];
|
||||
return BFLB_BOOT2_IMG_BOOTHEADER_SIGN_NOTFIT;
|
||||
}
|
||||
|
||||
if(g_ps_mode==BFLB_PSM_HBN && (!g_efuse_cfg.hbn_check_sign)){
|
||||
/* In HBN Mode, if user select to ignore hash and sign*/
|
||||
g_boot_img_cfg->hash_ignore=1;
|
||||
}else if((g_boot_img_cfg->hash_ignore==1&& *phash!=BFLB_BOOT2_DEADBEEF_VAL)||
|
||||
g_efuse_cfg.sign[i]!=0 ){
|
||||
/* If signed or user not really want to ignore, hash can't be ignored*/
|
||||
g_boot_img_cfg->hash_ignore=0;
|
||||
}
|
||||
if(g_user_hash_ignored){
|
||||
g_boot_img_cfg->hash_ignore=1;
|
||||
}
|
||||
|
||||
ARCH_MemCpy_Fast(g_boot_img_cfg->img_hash,header->hash,sizeof(header->hash));
|
||||
|
||||
if(g_boot_img_cfg->img_segment_info.img_len==0){
|
||||
return BFLB_BOOT2_IMG_SEGMENT_CNT_ERROR;
|
||||
}
|
||||
|
||||
/* Start hash here*/
|
||||
Sec_Eng_SHA256_Init(&g_sha_ctx,SEC_ENG_SHA_ID0,SEC_ENG_SHA256, g_sha_tmp_buf,g_padding);
|
||||
Sec_Eng_SHA_Start(SEC_ENG_SHA_ID0);
|
||||
|
||||
}else{
|
||||
MSG_ERR("bootheader crc error\r\n");
|
||||
blsp_dump_data((uint8_t *)&crc,4);
|
||||
return BFLB_BOOT2_IMG_BOOTHEADER_CRC_ERROR;
|
||||
}
|
||||
|
||||
return BFLB_BOOT2_SUCCESS;
|
||||
}
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief Parse public key
|
||||
*
|
||||
* @param g_boot_img_cfg: Boot image config pointer
|
||||
* @param data: Public key data pointer
|
||||
* @param own: 1 for current CPU, 0 for other(s)
|
||||
*
|
||||
* @return boot_error_code type
|
||||
*
|
||||
*******************************************************************************/
|
||||
int32_t blsp_boot_parse_pkey(boot_image_config *g_boot_img_cfg,uint8_t *data,uint8_t own)
|
||||
{
|
||||
boot_pk_config *cfg=(boot_pk_config*)data;
|
||||
uint32_t pk_hash[BFLB_BOOT2_PK_HASH_SIZE/4];
|
||||
|
||||
if(cfg->crc32==BFLB_Soft_CRC32((uint8_t*)cfg,sizeof(boot_pk_config)-4)){
|
||||
|
||||
/* Check public key with data info in OTP*/
|
||||
Sec_Eng_SHA256_Update(&g_sha_ctx,SEC_ENG_SHA_ID0,data,BFLB_BOOT2_ECC_KEYXSIZE+BFLB_BOOT2_ECC_KEYYSIZE);
|
||||
Sec_Eng_SHA256_Finish(&g_sha_ctx,SEC_ENG_SHA_ID0,(uint8_t *)pk_hash);
|
||||
|
||||
Sec_Eng_SHA256_Init(&g_sha_ctx,SEC_ENG_SHA_ID0,SEC_ENG_SHA256, g_sha_tmp_buf,g_padding);
|
||||
Sec_Eng_SHA_Start(SEC_ENG_SHA_ID0);
|
||||
|
||||
/* Check pk is valid */
|
||||
if(own==1){
|
||||
if(1!=blsp_boot_parse_is_pkhash_valid(g_boot_img_cfg->cpu_type,
|
||||
(uint8_t *)pk_hash)){
|
||||
MSG_ERR("PK sha error\r\n");
|
||||
return BFLB_BOOT2_IMG_PK_HASH_ERROR;
|
||||
}
|
||||
}
|
||||
if(own==1){
|
||||
ARCH_MemCpy_Fast(g_boot_img_cfg->eckye_x,cfg->eckye_x,sizeof(cfg->eckye_x));
|
||||
ARCH_MemCpy_Fast(g_boot_img_cfg->eckey_y,cfg->eckey_y,sizeof(cfg->eckey_y));
|
||||
}
|
||||
}else{
|
||||
MSG_ERR("PK crc error\r\n");
|
||||
return BFLB_BOOT2_IMG_PK_CRC_ERROR;
|
||||
}
|
||||
|
||||
return BFLB_BOOT2_SUCCESS;
|
||||
}
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief Parse signature
|
||||
*
|
||||
* @param g_boot_img_cfg: Boot image config pointer
|
||||
* @param data: Signature data pointer
|
||||
* @param own: 1 for current CPU, 0 for other(s)
|
||||
*
|
||||
* @return boot_error_code type
|
||||
*
|
||||
*******************************************************************************/
|
||||
int32_t blsp_boot_parse_signature(boot_image_config *g_boot_img_cfg,uint8_t *data,uint8_t own)
|
||||
{
|
||||
boot_sign_config *cfg=(boot_sign_config*)data;
|
||||
uint32_t crc;
|
||||
if(cfg->sig_len>sizeof(g_boot_img_cfg->signature)){
|
||||
return BFLB_BOOT2_IMG_SIGNATURE_LEN_ERROR;
|
||||
}
|
||||
|
||||
/* CRC include sig_len*/
|
||||
crc=BFLB_Soft_CRC32((uint8_t *)&cfg->sig_len,cfg->sig_len+sizeof(cfg->sig_len));
|
||||
if(memcmp(&crc,&cfg->signature[cfg->sig_len],4)==0){
|
||||
if(own==1){
|
||||
ARCH_MemCpy_Fast(g_boot_img_cfg->signature,cfg->signature,cfg->sig_len);
|
||||
g_boot_img_cfg->sig_len=cfg->sig_len;
|
||||
}else{
|
||||
ARCH_MemCpy_Fast(g_boot_img_cfg->signature2,cfg->signature,cfg->sig_len);
|
||||
g_boot_img_cfg->sig_len2=cfg->sig_len;
|
||||
}
|
||||
}else{
|
||||
MSG_ERR("SIG crc error\r\n");
|
||||
return BFLB_BOOT2_IMG_SIGNATURE_CRC_ERROR;
|
||||
}
|
||||
|
||||
return BFLB_BOOT2_SUCCESS;
|
||||
}
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief Parse ASE IV
|
||||
*
|
||||
* @param g_boot_img_cfg: Boot image config pointer
|
||||
* @param data: AES IV data pointer
|
||||
*
|
||||
* @return boot_error_code type
|
||||
*
|
||||
*******************************************************************************/
|
||||
int32_t blsp_boot_parse_aesiv(boot_image_config *g_boot_img_cfg,uint8_t *data)
|
||||
{
|
||||
boot_aes_config *cfg=(boot_aes_config *)data;
|
||||
|
||||
if(cfg->crc32==BFLB_Soft_CRC32(cfg->aes_iv,sizeof(cfg->aes_iv))){
|
||||
memcpy(g_boot_img_cfg->aes_iv,cfg->aes_iv,sizeof(boot_aes_config));
|
||||
/* Update image hash */
|
||||
if(!g_boot_img_cfg->hash_ignore){
|
||||
Sec_Eng_SHA256_Update(&g_sha_ctx,SEC_ENG_SHA_ID0,data,sizeof(boot_aes_config));
|
||||
}
|
||||
}else{
|
||||
MSG_ERR("AES IV crc error\r\n");
|
||||
return BFLB_BOOT2_IMG_AES_IV_CRC_ERROR;
|
||||
}
|
||||
|
||||
return BFLB_BOOT2_SUCCESS;
|
||||
}
|
||||
|
||||
#if 0
|
||||
/****************************************************************************//**
|
||||
* @brief Check signature is valid
|
||||
*
|
||||
* @param g_boot_img_cfg: Boot image config pointer
|
||||
*
|
||||
* @return boot_error_code type
|
||||
*
|
||||
*******************************************************************************/
|
||||
int32_t blsp_boot_parser_check_signature(boot_image_config *g_boot_img_cfg)
|
||||
{
|
||||
int32_t ret=0;
|
||||
uint64_t startTime=0;
|
||||
BFLB_ECDSA_Handle_t ecdsaHandle;
|
||||
|
||||
MSG_DBG("%d,%d\r\n",g_ps_mode,g_efuse_cfg.hbn_check_sign);
|
||||
if(g_ps_mode==BFLB_PSM_HBN&&(!g_efuse_cfg.hbn_check_sign)){
|
||||
return BFLB_BOOT2_SUCCESS;
|
||||
}
|
||||
if(g_boot_img_cfg->sign_type){
|
||||
MSG_DBG("Check sig1\r\n");
|
||||
startTime=bflb_platform_get_time_ms();
|
||||
|
||||
bflb_ecdsa_init(&ecdsaHandle,ECP_SECP256R1);
|
||||
ecdsaHandle.publicKeyx=(uint32_t *)g_boot_img_cfg->eckye_x;
|
||||
ecdsaHandle.publicKeyy=(uint32_t *)g_boot_img_cfg->eckey_y;
|
||||
bflb_ecdsa_verify(&ecdsaHandle,(uint32_t *)g_boot_img_cfg->img_hash,sizeof(g_boot_img_cfg->img_hash)/4,
|
||||
(uint32_t *)g_boot_img_cfg->signature,(uint32_t *)&g_boot_img_cfg->signature[32]);
|
||||
//ret=bflb_ecdsa_verify(0,(uint32_t *)g_boot_img_cfg->img_hash,sizeof(g_boot_img_cfg->img_hash),
|
||||
// (uint32_t *)g_boot_img_cfg->eckye_x,(uint32_t *)g_boot_img_cfg->eckey_y,
|
||||
// (uint32_t *)g_boot_img_cfg->signature,(uint32_t *)&g_boot_img_cfg->signature[32]);
|
||||
if (ret!=0) {
|
||||
MSG_ERR("verify failed\n");
|
||||
return BFLB_BOOT2_IMG_SIGN_ERROR;
|
||||
}
|
||||
MSG_DBG("Time=%d ms\r\n",(unsigned int)(bflb_platform_get_time_ms()-startTime));
|
||||
}
|
||||
MSG_DBG("Success\r\n");
|
||||
return BFLB_BOOT2_SUCCESS;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief Check hash is valid
|
||||
*
|
||||
* @param g_boot_img_cfg: Boot image config pointer
|
||||
*
|
||||
* @return boot_error_code type
|
||||
*
|
||||
*******************************************************************************/
|
||||
int32_t blsp_boot_parser_check_hash(boot_image_config *g_boot_img_cfg)
|
||||
{
|
||||
uint32_t img_hash_cal[BFLB_BOOT2_HASH_SIZE/4];
|
||||
|
||||
if(!g_boot_img_cfg->hash_ignore){
|
||||
Sec_Eng_SHA256_Finish(&g_sha_ctx,SEC_ENG_SHA_ID0,(uint8_t *)img_hash_cal);
|
||||
if(memcmp(img_hash_cal,g_boot_img_cfg->img_hash ,
|
||||
sizeof(g_boot_img_cfg->img_hash))!=0){
|
||||
MSG_ERR("Hash error\r\n");
|
||||
blsp_dump_data(img_hash_cal,BFLB_BOOT2_HASH_SIZE);
|
||||
blsp_dump_data(g_boot_img_cfg->img_hash,BFLB_BOOT2_HASH_SIZE);
|
||||
return BFLB_BOOT2_IMG_HASH_ERROR;
|
||||
}else{
|
||||
MSG_DBG("Success\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
return BFLB_BOOT2_SUCCESS;
|
||||
}
|
||||
|
||||
/*@} end of group BLSP_BOOT_PARSER_Public_Functions */
|
||||
|
||||
/*@} end of group BLSP_BOOT_PARSER */
|
||||
|
||||
/*@} end of group BL606_BLSP_Boot2 */
|
83
examples/boot2_iap/blsp_boot_parser.h
Normal file
83
examples/boot2_iap/blsp_boot_parser.h
Normal file
@ -0,0 +1,83 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file blsp_boot_parser.h
|
||||
* @version V1.2
|
||||
* @date
|
||||
* @brief This file is the peripheral case header file
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT(c) 2018 Bouffalo Lab</center></h2>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of Bouffalo Lab nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef __BLSP_BOOT_PARSER_H__
|
||||
#define __BLSP_BOOT_PARSER_H__
|
||||
|
||||
#include "stdint.h"
|
||||
|
||||
/** @addtogroup BL606_BLSP_Boot2
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup BLSP_BOOT_PARSER
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup BLSP_BOOT_PARSER_Public_Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*@} end of group BLSP_BOOT_PARSER_Public_Types */
|
||||
|
||||
/** @defgroup BLSP_BOOT_PARSER_Public_Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*@} end of group BLSP_BOOT_PARSER_Public_Constants */
|
||||
|
||||
/** @defgroup BLSP_BOOT_PARSER_Public_Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*@} end of group BLSP_BOOT_PARSER_Public_Macros */
|
||||
|
||||
/** @defgroup BLSP_BOOT_PARSER_Public_Functions
|
||||
* @{
|
||||
*/
|
||||
int32_t blsp_boot_parse_bootheader(boot_image_config *g_boot_img_cfg,uint8_t *data);
|
||||
int32_t blsp_boot_parse_pkey(boot_image_config *g_boot_img_cfg,uint8_t *data,uint8_t own);
|
||||
int32_t blsp_boot_parse_signature(boot_image_config *g_boot_img_cfg,uint8_t *data,uint8_t own);
|
||||
int32_t blsp_boot_parse_aesiv(boot_image_config *g_boot_img_cfg,uint8_t *data);
|
||||
//int32_t blsp_boot_parser_check_signature(boot_image_config *g_boot_img_cfg);
|
||||
int32_t blsp_boot_parser_check_hash(boot_image_config *g_boot_img_cfg);
|
||||
|
||||
/*@} end of group BLSP_BOOT_PARSER_Public_Functions */
|
||||
|
||||
/*@} end of group BLSP_BOOT_PARSER */
|
||||
|
||||
/*@} end of group BL606_BLSP_Boot2 */
|
||||
|
||||
#endif /* __BLSP_BOOT_PARSER_H__ */
|
308
examples/boot2_iap/blsp_bootinfo.h
Normal file
308
examples/boot2_iap/blsp_bootinfo.h
Normal file
@ -0,0 +1,308 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file blsp_bootinfo.h
|
||||
* @version V1.2
|
||||
* @date
|
||||
* @brief This file is the peripheral case header file
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT(c) 2018 Bouffalo Lab</center></h2>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of Bouffalo Lab nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef __BLSP_BOOTINFO_H__
|
||||
#define __BLSP_BOOTINFO_H__
|
||||
|
||||
#include "stdint.h"
|
||||
#include "blsp_port.h"
|
||||
|
||||
/** @addtogroup BL606_BLSP_Boot2
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup BLSP_BOOTINFO
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup BLSP_BOOTINFO_Public_Macros
|
||||
* @{
|
||||
*/
|
||||
#define BFLB_BOOT2_CPU0_MAGIC "BFNP"
|
||||
#define BFLB_BOOT2_CPU1_MAGIC "BFAP"
|
||||
#define BFLB_BOOT2_FLASH_CFG_MAGIC "FCFG"
|
||||
#define BFLB_BOOT2_PLL_CFG_MAGICCODE "PCFG"
|
||||
#define BFLB_BOOT2_FLASH_TZC_MAGIC "TCFG"
|
||||
#define BFLB_BOOT2_DEADBEEF_VAL 0xdeadbeef
|
||||
|
||||
#define BFLB_BOOT2_READBUF_SIZE 4*1024
|
||||
#define BFLB_FW_IMG_OFFSET_AFTER_HEADER 4*1024
|
||||
|
||||
/* Image owner type */
|
||||
#define BFLB_BOOT2_CPU_0 0
|
||||
#define BFLB_BOOT2_CPU_1 1
|
||||
#define BFLB_BOOT2_CPU_MAX 2
|
||||
|
||||
/* Public key hash size */
|
||||
#define BFLB_BOOT2_PK_HASH_SIZE 256/8
|
||||
#define BFLB_BOOT2_HASH_SIZE 256/8
|
||||
/* Public key type */
|
||||
#define BFLB_BOOT2_ECC_KEYXSIZE 256/8
|
||||
#define BFLB_BOOT2_ECC_KEYYSIZE 256/8
|
||||
#define BFLB_BOOT2_SIGN_MAXSIZE 2048/8
|
||||
|
||||
/* Power save define */
|
||||
#define BFLB_PSM_ACTIVE 0
|
||||
#define BFLB_PSM_HBN 1
|
||||
|
||||
/*@} end of group BLSP_BOOTINFO_Public_Macros */
|
||||
|
||||
/** @defgroup BLSP_BOOTINFO_Public_Types
|
||||
* @{
|
||||
*/
|
||||
typedef enum {
|
||||
BFLB_BOOT2_SUCCESS=0x00,
|
||||
|
||||
/* Flash*/
|
||||
BFLB_BOOT2_FLASH_INIT_ERROR=0x0001,
|
||||
BFLB_BOOT2_FLASH_ERASE_PARA_ERROR=0x0002,
|
||||
BFLB_BOOT2_FLASH_ERASE_ERROR=0x0003,
|
||||
BFLB_BOOT2_FLASH_WRITE_PARA_ERROR=0x0004,
|
||||
BFLB_BOOT2_FLASH_WRITE_ADDR_ERROR=0x0005,
|
||||
BFLB_BOOT2_FLASH_WRITE_ERROR=0x0006,
|
||||
BFLB_BOOT2_FLASH_BOOT_PARA=0x0007,
|
||||
BFLB_BOOT2_FLASH_READ_ERROR=0x0008,
|
||||
|
||||
/* Image*/
|
||||
BFLB_BOOT2_IMG_BOOTHEADER_LEN_ERROR=0x0201,
|
||||
BFLB_BOOT2_IMG_BOOTHEADER_NOT_LOAD_ERROR=0x0202,
|
||||
BFLB_BOOT2_IMG_BOOTHEADER_MAGIC_ERROR=0x0203,
|
||||
BFLB_BOOT2_IMG_BOOTHEADER_CRC_ERROR=0x0204,
|
||||
BFLB_BOOT2_IMG_BOOTHEADER_ENCRYPT_NOTFIT=0x0205,
|
||||
BFLB_BOOT2_IMG_BOOTHEADER_SIGN_NOTFIT=0x0206,
|
||||
BFLB_BOOT2_IMG_SEGMENT_CNT_ERROR=0x0207,
|
||||
BFLB_BOOT2_IMG_AES_IV_LEN_ERROR=0x0208,
|
||||
BFLB_BOOT2_IMG_AES_IV_CRC_ERROR=0x0209,
|
||||
BFLB_BOOT2_IMG_PK_LEN_ERROR=0x020a,
|
||||
BFLB_BOOT2_IMG_PK_CRC_ERROR=0x020b,
|
||||
BFLB_BOOT2_IMG_PK_HASH_ERROR=0x020c,
|
||||
BFLB_BOOT2_IMG_SIGNATURE_LEN_ERROR=0x020d,
|
||||
BFLB_BOOT2_IMG_SIGNATURE_CRC_ERROR=0x020e,
|
||||
BFLB_BOOT2_IMG_SECTIONHEADER_LEN_ERROR=0x020f,
|
||||
BFLB_BOOT2_IMG_SECTIONHEADER_CRC_ERROR=0x0210,
|
||||
BFLB_BOOT2_IMG_SECTIONHEADER_DST_ERROR=0x0211,
|
||||
BFLB_BOOT2_IMG_SECTIONDATA_LEN_ERROR=0x0212,
|
||||
BFLB_BOOT2_IMG_SECTIONDATA_DEC_ERROR=0x0213,
|
||||
BFLB_BOOT2_IMG_SECTIONDATA_TLEN_ERROR=0x0214,
|
||||
BFLB_BOOT2_IMG_SECTIONDATA_CRC_ERROR=0x0215,
|
||||
BFLB_BOOT2_IMG_HALFBAKED_ERROR=0x0216,
|
||||
BFLB_BOOT2_IMG_HASH_ERROR=0x0217,
|
||||
BFLB_BOOT2_IMG_SIGN_PARSE_ERROR=0x0218,
|
||||
BFLB_BOOT2_IMG_SIGN_ERROR=0x0219,
|
||||
BFLB_BOOT2_IMG_DEC_ERROR=0x021a,
|
||||
BFLB_BOOT2_IMG_ALL_INVALID_ERROR=0x021b,
|
||||
BFLB_BOOT2_IMG_Roll_Back=0x021c,
|
||||
|
||||
/* MISC*/
|
||||
BFLB_BOOT2_MEM_ERROR=0xfffb,
|
||||
BFLB_BOOT2_PLL_ERROR=0xfffc,
|
||||
BFLB_BOOT2_INVASION_ERROR=0xfffd,
|
||||
BFLB_BOOT2_POLLING=0xfffe,
|
||||
BFLB_BOOT2_FAIL=0xffff,
|
||||
|
||||
}boot_error_code;
|
||||
|
||||
typedef struct {
|
||||
uint8_t encrypted[BFLB_BOOT2_CPU_MAX];
|
||||
uint8_t sign[BFLB_BOOT2_CPU_MAX];
|
||||
uint8_t hbn_check_sign;
|
||||
uint8_t rsvd[3];
|
||||
uint8_t chip_id[8];
|
||||
uint8_t pk_hash_cpu0[BFLB_BOOT2_PK_HASH_SIZE];
|
||||
uint8_t pk_hash_cpu1[BFLB_BOOT2_PK_HASH_SIZE];
|
||||
}boot_efuse_hw_config;
|
||||
|
||||
typedef struct {
|
||||
uint32_t magicCode; /*'FCFG'*/
|
||||
SPI_Flash_Cfg_Type cfg;
|
||||
uint32_t crc32;
|
||||
}boot_flash_config;
|
||||
|
||||
typedef struct {
|
||||
uint8_t xtal_type;
|
||||
uint8_t pll_clk;
|
||||
uint8_t hclk_div;
|
||||
uint8_t bclk_div;
|
||||
|
||||
uint8_t flash_clk_type;
|
||||
uint8_t flash_clk_div;
|
||||
uint8_t rsvd[2];
|
||||
}boot_sys_clk_config;
|
||||
|
||||
typedef struct {
|
||||
uint32_t magicCode; /*'PCFG'*/
|
||||
boot_sys_clk_config cfg;
|
||||
uint32_t crc32;
|
||||
}boot_clk_config;
|
||||
|
||||
typedef struct {
|
||||
uint32_t magicCode; /*'BFXP'*/
|
||||
uint32_t rivison;
|
||||
boot_flash_config flash_cfg;
|
||||
boot_clk_config clk_cfg;
|
||||
__PACKED_UNION {
|
||||
__PACKED_STRUCT {
|
||||
uint32_t sign : 2; /* [1: 0] for sign*/
|
||||
uint32_t encrypt_type : 2; /* [3: 2] for encrypt */
|
||||
uint32_t key_sel : 2; /* [5: 4] for key sel in boot interface*/
|
||||
uint32_t rsvd6_7 : 2; /* [7: 6] for encrypt*/
|
||||
uint32_t no_segment : 1; /* [8] no segment info */
|
||||
uint32_t cache_enable : 1; /* [9] for cache */
|
||||
uint32_t notLoadInBoot : 1; /* [10] not load this img in bootrom */
|
||||
uint32_t aes_region_lock : 1; /* [11] aes region lock */
|
||||
uint32_t cache_way_disable : 4; /* [15: 12] cache way disable info*/
|
||||
uint32_t crcIgnore : 1; /* [16] ignore crc */
|
||||
uint32_t hash_ignore : 1; /* [17] hash crc */
|
||||
uint32_t halt_cpu1 : 1; /* [18] halt ap */
|
||||
uint32_t rsvd19_31 : 13; /* [31:19] rsvd */
|
||||
} bval;
|
||||
uint32_t wval;
|
||||
}bootCfg ;
|
||||
|
||||
__PACKED_UNION {
|
||||
uint32_t segment_cnt;
|
||||
uint32_t img_len;
|
||||
}img_segment_info;
|
||||
|
||||
uint32_t bootEntry; /* entry point of the image*/
|
||||
__PACKED_UNION {
|
||||
uint32_t ram_addr;
|
||||
uint32_t flash_offset;
|
||||
}img_start;
|
||||
|
||||
uint8_t hash[BFLB_BOOT2_HASH_SIZE]; /*hash of the image*/
|
||||
|
||||
uint32_t rsv1;
|
||||
uint32_t rsv2;
|
||||
uint32_t crc32;
|
||||
}boot_header_config;
|
||||
|
||||
typedef struct {
|
||||
uint8_t aes_iv[16];
|
||||
uint32_t crc32;
|
||||
}boot_aes_config;
|
||||
|
||||
typedef struct {
|
||||
uint8_t eckye_x[BFLB_BOOT2_ECC_KEYXSIZE]; //ec key in boot header
|
||||
uint8_t eckey_y[BFLB_BOOT2_ECC_KEYYSIZE]; //ec key in boot header
|
||||
uint32_t crc32;
|
||||
}boot_pk_config;
|
||||
|
||||
typedef struct {
|
||||
uint32_t sig_len;
|
||||
uint8_t signature[BFLB_BOOT2_SIGN_MAXSIZE];
|
||||
uint32_t crc32;
|
||||
}boot_sign_config;
|
||||
|
||||
typedef struct {
|
||||
uint8_t encrypt_type;
|
||||
uint8_t sign_type;
|
||||
uint8_t key_sel;
|
||||
uint8_t img_valid;
|
||||
|
||||
uint8_t no_segment;
|
||||
uint8_t cache_enable;
|
||||
uint8_t cache_way_disable;
|
||||
uint8_t hash_ignore;
|
||||
|
||||
uint8_t aes_region_lock;
|
||||
uint8_t halt_cpu1;
|
||||
uint8_t cpu_type;
|
||||
uint8_t r[1];
|
||||
|
||||
__PACKED_UNION {
|
||||
uint32_t segment_cnt;
|
||||
uint32_t img_len;
|
||||
}img_segment_info;
|
||||
|
||||
uint32_t msp_val;
|
||||
uint32_t entry_point;
|
||||
__PACKED_UNION {
|
||||
uint32_t ram_addr;
|
||||
uint32_t flash_offset;
|
||||
}img_start;
|
||||
uint32_t sig_len;
|
||||
uint32_t sig_len2;
|
||||
|
||||
uint32_t deal_len;
|
||||
uint32_t max_input_len;
|
||||
|
||||
uint8_t img_hash[BFLB_BOOT2_HASH_SIZE]; //hash of the whole (all)images
|
||||
uint8_t aes_iv[16+4]; //iv in boot header
|
||||
|
||||
uint8_t eckye_x[BFLB_BOOT2_ECC_KEYXSIZE]; //ec key in boot header
|
||||
uint8_t eckey_y[BFLB_BOOT2_ECC_KEYYSIZE]; //ec key in boot header
|
||||
uint8_t eckey_x2[BFLB_BOOT2_ECC_KEYXSIZE]; //ec key in boot header
|
||||
uint8_t eckey_y2[BFLB_BOOT2_ECC_KEYYSIZE]; //ec key in boot header
|
||||
|
||||
uint8_t signature[BFLB_BOOT2_SIGN_MAXSIZE]; //signature in boot header
|
||||
uint8_t signature2[BFLB_BOOT2_SIGN_MAXSIZE]; //signature in boot header
|
||||
|
||||
}boot_image_config;
|
||||
|
||||
typedef struct {
|
||||
uint32_t msp_store_addr;
|
||||
uint32_t pc_store_addr;
|
||||
uint32_t default_xip_addr;
|
||||
}boot_cpu_config;
|
||||
|
||||
typedef void (*pentry_t)(void );
|
||||
|
||||
extern boot_cpu_config g_boot_cpu_cfg[2];
|
||||
extern boot_image_config g_boot_img_cfg[2];
|
||||
extern boot_efuse_hw_config g_efuse_cfg;
|
||||
extern uint8_t g_ps_mode;
|
||||
extern uint8_t g_cpu_count;
|
||||
extern uint8_t g_boot2_read_buf[BFLB_BOOT2_READBUF_SIZE];
|
||||
|
||||
/*@} end of group BLSP_BOOTINFO_Public_Types */
|
||||
|
||||
/** @defgroup BLSP_BOOTINFO_Public_Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*@} end of group BLSP_BOOTINFO_Public_Constants */
|
||||
|
||||
/** @defgroup BLSP_BOOTINFO_Public_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*@} end of group BLSP_BOOTINFO_Public_Functions */
|
||||
|
||||
/*@} end of group BLSP_BOOTINFO */
|
||||
|
||||
/*@} end of group BL606_BLSP_Boot2 */
|
||||
|
||||
#endif /* __BLSP_BOOTINFO_H__ */
|
243
examples/boot2_iap/blsp_common.c
Normal file
243
examples/boot2_iap/blsp_common.c
Normal file
@ -0,0 +1,243 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file blsp_common.c
|
||||
* @version V1.2
|
||||
* @date
|
||||
* @brief This file is the peripheral case c file
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT(c) 2018 Bouffalo Lab</center></h2>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of Bouffalo Lab nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include "stdio.h"
|
||||
#include "stdint.h"
|
||||
#include "string.h"
|
||||
#include "blsp_port.h"
|
||||
#include "bflb_platform.h"
|
||||
#include "blsp_bootinfo.h"
|
||||
#include "blsp_common.h"
|
||||
#include "blsp_media_boot.h"
|
||||
#include "hal_flash.h"
|
||||
#include "bflb_eflash_loader.h"
|
||||
|
||||
/** @addtogroup BL606_BLSP_Boot2
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup BLSP_COMMON
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup BLSP_COMMON_Private_Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*@} end of group BLSP_COMMON_Private_Macros */
|
||||
|
||||
/** @defgroup BLSP_COMMON_Private_Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*@} end of group BLSP_COMMON_Private_Types */
|
||||
|
||||
/** @defgroup BLSP_COMMON_Private_Variables
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*@} end of group BLSP_COMMON_Private_Variables */
|
||||
|
||||
/** @defgroup BLSP_COMMON_Global_Variables
|
||||
* @{
|
||||
*/
|
||||
int32_t blsp_boot2_set_encrypt(uint8_t index,boot_image_config *g_boot_img_cfg);
|
||||
int32_t blsp_boot2_set_cache(uint8_t cont_read,SPI_Flash_Cfg_Type *flash_cfg,boot_image_config *g_boot_img_cfg);
|
||||
|
||||
/*@} end of group BLSP_COMMON_Global_Variables */
|
||||
|
||||
/** @defgroup BLSP_COMMON_Private_Fun_Declaration
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*@} end of group BLSP_COMMON_Private_Fun_Declaration */
|
||||
|
||||
/** @defgroup BLSP_COMMON_Private_Functions_User_Define
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*@} end of group BLSP_COMMON_Private_Functions_User_Define */
|
||||
|
||||
/** @defgroup BLSP_COMMON_Private_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief Dump data
|
||||
*
|
||||
* @param datain: Data pointer to dump
|
||||
* @param len: Data length to dump
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************/
|
||||
void blsp_dump_data(void *datain,int len)
|
||||
{
|
||||
int i=0;
|
||||
uint8_t *data=(uint8_t *)datain;
|
||||
data = data;
|
||||
|
||||
for(i=0;i<len;i++){
|
||||
if(i%16==0&&i!=0){
|
||||
bflb_eflash_loader_printf("\r\n");
|
||||
}
|
||||
bflb_eflash_loader_printf("%02x ",data[i]);
|
||||
}
|
||||
bflb_eflash_loader_printf("\r\n");
|
||||
}
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief Media boot pre-jump
|
||||
*
|
||||
* @param None
|
||||
*
|
||||
* @return BL_Err_Type
|
||||
*
|
||||
*******************************************************************************/
|
||||
int32_t blsp_mediaboot_pre_jump(void)
|
||||
{
|
||||
/* Sec eng deinit*/
|
||||
blsp_boot2_reset_sec_eng();
|
||||
|
||||
/* Platform deinit */
|
||||
bflb_platform_deinit();
|
||||
|
||||
/* Jump to entry */
|
||||
blsp_boot2_jump_entry();
|
||||
|
||||
return BFLB_BOOT2_SUCCESS;
|
||||
}
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief Boot2 exit with error and will stay forever
|
||||
*
|
||||
* @param None
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************/
|
||||
void blsp_boot2_exit(void)
|
||||
{
|
||||
uint32_t i=0;
|
||||
|
||||
blsp_sboot_finish();
|
||||
/* Prepare release Other CPUs anyway */
|
||||
/* Deal Other CPU's entry point */
|
||||
for(i=1;i<g_cpu_count;i++){
|
||||
BL_WR_WORD(g_boot_cpu_cfg[i].msp_store_addr,0);
|
||||
BL_WR_WORD(g_boot_cpu_cfg[i].pc_store_addr,0);
|
||||
}
|
||||
/* Release other CPUs*/
|
||||
if(g_cpu_count!=1&&!g_boot_img_cfg[0].halt_cpu1){
|
||||
blsp_boot2_releae_other_cpu();
|
||||
}
|
||||
/* Stay here */
|
||||
while(1){
|
||||
/* Use soft delay only */
|
||||
ARCH_Delay_MS(100);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief Boot2 jump to entry_point
|
||||
*
|
||||
* @param None
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************/
|
||||
void ATTR_TCM_SECTION blsp_boot2_jump_entry(void)
|
||||
{
|
||||
pentry_t pentry;
|
||||
uint32_t i=0;
|
||||
int32_t ret;
|
||||
|
||||
blsp_sboot_finish();
|
||||
|
||||
/*Note:enable cache with flash offset, after this, should be no flash directl read,
|
||||
If need read, should take flash offset into consideration */
|
||||
if(0!=g_efuse_cfg.encrypted[0]){
|
||||
/*for encrypted img, use none-continuos read*/
|
||||
ret=flash_set_cache(0,g_boot_img_cfg[0].cache_enable,g_boot_img_cfg[0].cache_way_disable,g_boot_img_cfg[0].img_start.flash_offset);
|
||||
}else{
|
||||
/*for unencrypted img, use continuos read*/
|
||||
ret=flash_set_cache(1,g_boot_img_cfg[0].cache_enable,g_boot_img_cfg[0].cache_way_disable,g_boot_img_cfg[0].img_start.flash_offset);
|
||||
}
|
||||
if(ret!=BFLB_BOOT2_SUCCESS){
|
||||
return;
|
||||
}
|
||||
|
||||
/* Deal Other CPUs' entry point */
|
||||
/* Prepare release CPU1 anyway */
|
||||
for(i=1;i<g_cpu_count;i++){
|
||||
if(g_boot_img_cfg[i].img_valid){
|
||||
BL_WR_WORD(g_boot_cpu_cfg[i].msp_store_addr,g_boot_img_cfg[i].msp_val);
|
||||
BL_WR_WORD(g_boot_cpu_cfg[i].pc_store_addr,g_boot_img_cfg[i].entry_point);
|
||||
}else{
|
||||
BL_WR_WORD(g_boot_cpu_cfg[i].msp_store_addr,0);
|
||||
BL_WR_WORD(g_boot_cpu_cfg[i].pc_store_addr,0);
|
||||
}
|
||||
}
|
||||
/* Deal CPU0's entry point */
|
||||
if(g_boot_img_cfg[0].img_valid){
|
||||
pentry=(pentry_t)g_boot_img_cfg[0].entry_point;
|
||||
if(g_boot_img_cfg[0].msp_val!=0){
|
||||
__set_MSP(g_boot_img_cfg[0].msp_val);
|
||||
}
|
||||
/* Release other CPUs unless user halt it */
|
||||
if(g_cpu_count!=1&&!g_boot_img_cfg[0].halt_cpu1){
|
||||
blsp_boot2_releae_other_cpu();
|
||||
}
|
||||
if(pentry!=NULL){
|
||||
pentry();
|
||||
}
|
||||
}
|
||||
/* Release other CPUs unless user halt it */
|
||||
if(g_cpu_count!=1&&!g_boot_img_cfg[0].halt_cpu1){
|
||||
blsp_boot2_releae_other_cpu();
|
||||
}
|
||||
/* If cann't jump stay here */
|
||||
while(1){
|
||||
/*use soft delay only */
|
||||
ARCH_Delay_MS(100);
|
||||
}
|
||||
}
|
||||
|
||||
/*@} end of group BLSP_COMMON_Public_Functions */
|
||||
|
||||
/*@} end of group BLSP_COMMON */
|
||||
|
||||
/*@} end of group BL606_BLSP_Boot2 */
|
89
examples/boot2_iap/blsp_common.h
Normal file
89
examples/boot2_iap/blsp_common.h
Normal file
@ -0,0 +1,89 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file blsp_common.h
|
||||
* @version V1.2
|
||||
* @date
|
||||
* @brief This file is the peripheral case header file
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT(c) 2018 Bouffalo Lab</center></h2>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of Bouffalo Lab nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef __BLSP_COMMON_H__
|
||||
#define __BLSP_COMMON_H__
|
||||
|
||||
#include "stdint.h"
|
||||
|
||||
/** @addtogroup BL606_BLSP_Boot2
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup BLSP_COMMON
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup BLSP_COMMON_Public_Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*@} end of group BLSP_COMMON_Public_Types */
|
||||
|
||||
/** @defgroup BLSP_COMMON_Public_Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*@} end of group BLSP_COMMON_Public_Constants */
|
||||
|
||||
/** @defgroup BLSP_COMMON_Public_Macros
|
||||
* @{
|
||||
*/
|
||||
#define BLSP_BOOT2_CP_FLAG 0x02
|
||||
#define BLSP_BOOT2_MP_FLAG 0x01
|
||||
#define BLSP_BOOT2_SP_FLAG 0x00
|
||||
/*@} end of group BLSP_COMMON_Public_Macros */
|
||||
|
||||
/** @defgroup BLSP_COMMON_Public_Functions
|
||||
* @{
|
||||
*/
|
||||
void blsp_dump_data(void *datain,int len);
|
||||
void blsp_fix_invalid_msp_pc(void);
|
||||
void blsp_boot2_jump_entry(void);
|
||||
int32_t blsp_mediaboot_pre_jump(void);
|
||||
uint8_t blsp_boot2_get_feature_flag(void);
|
||||
uint8_t blsp_boot2_get_log_disable_flag(void);
|
||||
uint8_t blsp_boot2_8m_support_flag(void);
|
||||
uint8_t blsp_boot2_dump_critical_flag(void);
|
||||
uint32_t blsp_boot2_get_baudrate(void);
|
||||
uint8_t blsp_boot2_get_tx_gpio(void);
|
||||
|
||||
/*@} end of group BLSP_COMMON_Public_Functions */
|
||||
|
||||
/*@} end of group BLSP_COMMON */
|
||||
|
||||
/*@} end of group BL606_BLSP_Boot2 */
|
||||
|
||||
#endif /* __BLSP_COMMON_H__ */
|
365
examples/boot2_iap/blsp_media_boot.c
Normal file
365
examples/boot2_iap/blsp_media_boot.c
Normal file
@ -0,0 +1,365 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file blsp_media_boot.c
|
||||
* @version V1.2
|
||||
* @date
|
||||
* @brief This file is the peripheral case c file
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT(c) 2018 Bouffalo Lab</center></h2>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of Bouffalo Lab nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include "stdint.h"
|
||||
#include "string.h"
|
||||
#include "blsp_port.h"
|
||||
#include "bflb_platform.h"
|
||||
#include "blsp_bootinfo.h"
|
||||
#include "blsp_common.h"
|
||||
#include "blsp_boot_parser.h"
|
||||
#include "blsp_media_boot.h"
|
||||
#include "softcrc.h"
|
||||
#include "bflb_eflash_loader_uart.h"
|
||||
|
||||
/** @addtogroup BL606_BLSP_Boot2
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup BLSP_MEDIA_BOOT
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup BLSP_MEDIA_BOOT_Private_Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*@} end of group BLSP_MEDIA_BOOT_Private_Macros */
|
||||
|
||||
/** @defgroup BLSP_MEDIA_BOOT_Private_Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*@} end of group BLSP_MEDIA_BOOT_Private_Types */
|
||||
|
||||
/** @defgroup BLSP_MEDIA_BOOT_Private_Variables
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*@} end of group BLSP_MEDIA_BOOT_Private_Variables */
|
||||
|
||||
/** @defgroup BLSP_MEDIA_BOOT_Global_Variables
|
||||
* @{
|
||||
*/
|
||||
extern SEC_Eng_SHA256_Ctx g_sha_ctx;
|
||||
|
||||
/*@} end of group BLSP_MEDIA_BOOT_Global_Variables */
|
||||
|
||||
/** @defgroup BLSP_MEDIA_BOOT_Private_Fun_Declaration
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*@} end of group BLSP_MEDIA_BOOT_Private_Fun_Declaration */
|
||||
|
||||
/** @defgroup BLSP_MEDIA_BOOT_Private_Functions_User_Define
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*@} end of group BLSP_MEDIA_BOOT_Private_Functions_User_Define */
|
||||
|
||||
/** @defgroup BLSP_MEDIA_BOOT_Private_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief Media boot calculate hash
|
||||
*
|
||||
* @param startAddr: Start address to calculate
|
||||
* @param totalLen: Data length to calculate
|
||||
*
|
||||
* @return BL_Err_Type
|
||||
*
|
||||
*******************************************************************************/
|
||||
static int32_t blsp_mediaboot_cal_hash(uint32_t start_addr,uint32_t total_len)
|
||||
{
|
||||
int32_t deal_len=0;
|
||||
int32_t read_len=0;
|
||||
uint32_t addr=start_addr;
|
||||
int32_t ret;
|
||||
uint32_t dump_cnt=0;
|
||||
|
||||
while(deal_len<total_len){
|
||||
|
||||
read_len=total_len-deal_len;
|
||||
if(read_len>BFLB_BOOT2_READBUF_SIZE){
|
||||
read_len=BFLB_BOOT2_READBUF_SIZE;
|
||||
}
|
||||
|
||||
ret=blsp_mediaboot_read(addr,g_boot2_read_buf,read_len);
|
||||
if(ret!=BFLB_BOOT2_SUCCESS){
|
||||
return ret;
|
||||
}
|
||||
if(dump_cnt==0){
|
||||
if(blsp_boot2_dump_critical_flag()){
|
||||
blsp_dump_data(g_boot2_read_buf,read_len);
|
||||
}
|
||||
dump_cnt=1;
|
||||
}
|
||||
/* Update hash*/
|
||||
Sec_Eng_SHA256_Update(&g_sha_ctx,SEC_ENG_SHA_ID0,(uint8_t *)g_boot2_read_buf,read_len);
|
||||
//blsp_dump_data((uint8_t *)g_boot2_read_buf,readLen);
|
||||
|
||||
addr+=read_len;
|
||||
deal_len+=read_len;
|
||||
}
|
||||
return BFLB_BOOT2_SUCCESS;
|
||||
}
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief Media boot read signature
|
||||
*
|
||||
* @param addr: Start address to read signature
|
||||
* @param len: Signature length pointer
|
||||
*
|
||||
* @return BL_Err_Type
|
||||
*
|
||||
*******************************************************************************/
|
||||
#if 0
|
||||
static int32_t BLSP_MediaBoot_Read_Signaure(uint32_t addr,uint32_t *len)
|
||||
{
|
||||
int32_t ret=BFLB_BOOT2_SUCCESS;
|
||||
uint32_t sig_len=0;
|
||||
uint8_t *ptmp;
|
||||
|
||||
/* Read signature*/
|
||||
ret=blsp_mediaboot_read(addr,(uint8_t*)&sig_len,sizeof(sig_len));
|
||||
if(ret!=BFLB_BOOT2_SUCCESS){
|
||||
return ret;
|
||||
}
|
||||
addr+=sizeof(sig_len);
|
||||
if(sig_len>BFLB_BOOT2_SIGN_MAXSIZE){
|
||||
return BFLB_BOOT2_IMG_SIGNATURE_LEN_ERROR;
|
||||
}
|
||||
/* Tail 4 bytes for crc */
|
||||
ptmp=((uint8_t *)g_boot2_read_buf);
|
||||
ret=blsp_mediaboot_read(addr,(uint8_t *)(ptmp+sizeof(sig_len)),sig_len+4);
|
||||
if(ret!=BFLB_BOOT2_SUCCESS){
|
||||
return ret;
|
||||
}
|
||||
ARCH_MemCpy_Fast(g_boot2_read_buf,&sig_len,sizeof(sig_len));
|
||||
addr+=(sig_len+4);
|
||||
*len=sig_len;
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
/****************************************************************************//**
|
||||
* @brief Media boot parse one firmware
|
||||
*
|
||||
* @param g_boot_img_cfg: Boot image config pointer to hold parsed information
|
||||
* @param bootheaderAddr: Bootheader start address
|
||||
* @param imgAddr: Image start address
|
||||
*
|
||||
* @return BL_Err_Type
|
||||
*
|
||||
*******************************************************************************/
|
||||
static int32_t blsp_mediaboot_parse_one_fw(boot_image_config *boot_img_cfg,uint32_t boot_header_addr,uint32_t img_addr)
|
||||
{
|
||||
uint32_t addr=boot_header_addr;
|
||||
int32_t ret;
|
||||
// uint32_t sig_len=0;
|
||||
|
||||
/* Read boot header*/
|
||||
MSG_DBG("R header from %08x\r\n",addr);
|
||||
ret=blsp_mediaboot_read(addr,g_boot2_read_buf,sizeof(boot_header_config));
|
||||
if(ret!=BFLB_BOOT2_SUCCESS){
|
||||
return ret;
|
||||
}
|
||||
if(blsp_boot2_dump_critical_flag()){
|
||||
blsp_dump_data(g_boot2_read_buf,sizeof(boot_header_config));
|
||||
}
|
||||
|
||||
addr+=sizeof(boot_header_config);
|
||||
ret=blsp_boot_parse_bootheader(boot_img_cfg,(uint8_t *)g_boot2_read_buf);
|
||||
if(ret!=BFLB_BOOT2_SUCCESS){
|
||||
return ret;
|
||||
}
|
||||
/* Due to OTA, the flash_offset is changed, so copy from partition info */
|
||||
boot_img_cfg->img_start.flash_offset=img_addr;
|
||||
|
||||
if(boot_img_cfg->no_segment){
|
||||
/* Flash image */
|
||||
if(!boot_img_cfg->hash_ignore){
|
||||
MSG_DBG("Cal hash\r\n");
|
||||
ret= blsp_mediaboot_cal_hash(img_addr,
|
||||
boot_img_cfg->img_segment_info.img_len);
|
||||
if(ret!=BFLB_BOOT2_SUCCESS){
|
||||
return ret;
|
||||
}
|
||||
ret= blsp_boot_parser_check_hash(boot_img_cfg);
|
||||
if(ret!=BFLB_BOOT2_SUCCESS){
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
// ret=blsp_boot_parser_check_signature(g_boot_img_cfg);
|
||||
// if(ret!=BFLB_BOOT2_SUCCESS){
|
||||
// return ret;
|
||||
// }
|
||||
boot_img_cfg->img_valid=1;
|
||||
}else{
|
||||
boot_img_cfg->img_valid=0;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*@} end of group BLSP_MEDIA_BOOT_Private_Functions */
|
||||
|
||||
/** @defgroup BLSP_MEDIA_BOOT_Public_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief Media boot read data
|
||||
*
|
||||
* @param addr: Start address to read
|
||||
* @param data: Data buffer to hold read data
|
||||
* @param len: Data length to read
|
||||
*
|
||||
* @return BL_Err_Type
|
||||
*
|
||||
*******************************************************************************/
|
||||
int32_t ATTR_TCM_SECTION blsp_mediaboot_read(uint32_t addr,uint8_t *data, uint32_t len)
|
||||
{
|
||||
XIP_SFlash_Read_Via_Cache_Need_Lock(BLSP_BOOT2_XIP_BASE+addr,data,len);
|
||||
|
||||
return BFLB_BOOT2_SUCCESS;
|
||||
}
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief Media boot main process
|
||||
*
|
||||
* @param cpuBootheaderAddr[BFLB_BOOT2_CPU_MAX]: CPU bootheader address list
|
||||
* @param cpuRollBack[BFLB_BOOT2_CPU_MAX]: CPU need roll back flag hold list
|
||||
* @param rollBack: 1 for rollback when imge error occurs, 0 for not rollback when imge error occurs
|
||||
*
|
||||
* @return BL_Err_Type
|
||||
*
|
||||
*******************************************************************************/
|
||||
int32_t blsp_mediaboot_main(uint32_t cpu_boot_header_addr[BFLB_BOOT2_CPU_MAX],uint8_t cpu_roll_back[BFLB_BOOT2_CPU_MAX],uint8_t roll_back)
|
||||
{
|
||||
int32_t ret;
|
||||
uint32_t i=0;
|
||||
uint32_t valid_img_found=0;
|
||||
uint32_t boot_header_addr[BFLB_BOOT2_CPU_MAX];
|
||||
MSG_DBG("Media boot main\r\n");
|
||||
/* Reset some parameters*/
|
||||
for(i=0;i<BFLB_BOOT2_CPU_MAX;i++){
|
||||
memset(&g_boot_img_cfg[i],0,sizeof(g_boot_img_cfg[i]));
|
||||
boot_header_addr[i]=cpu_boot_header_addr[i];
|
||||
cpu_roll_back[i]=0;
|
||||
}
|
||||
g_boot_img_cfg[0].halt_cpu1=0;
|
||||
|
||||
/* Try to boot from flash */
|
||||
for(i=0;i<g_cpu_count;i++){
|
||||
if(boot_header_addr[i]==0){
|
||||
MSG_ERR("CPU %d not boot\r\n",i);
|
||||
continue;
|
||||
}
|
||||
ret=blsp_mediaboot_parse_one_fw(&g_boot_img_cfg[i],boot_header_addr[i],
|
||||
boot_header_addr[i]+BFLB_FW_IMG_OFFSET_AFTER_HEADER);
|
||||
if(ret!=BFLB_BOOT2_SUCCESS){
|
||||
MSG_ERR("CPU %d boot fail\r\n",i);
|
||||
cpu_roll_back[i]=1;
|
||||
}else{
|
||||
valid_img_found++;
|
||||
}
|
||||
}
|
||||
if(valid_img_found!=g_cpu_count && 1==roll_back){
|
||||
/* For CP and DP, found CPU0 image is taken as correct when the other not found, others as wrong and try to rollback */
|
||||
if(boot_header_addr[1]==0 && valid_img_found==1){
|
||||
MSG_DBG("Found One img Only\r\n");
|
||||
}else{
|
||||
MSG_ERR("Image roll back\r\n");
|
||||
return BFLB_BOOT2_IMG_Roll_Back;
|
||||
}
|
||||
}
|
||||
if(valid_img_found==0){
|
||||
MSG_ERR("no valid img found\r\n");
|
||||
return BFLB_BOOT2_IMG_ALL_INVALID_ERROR;
|
||||
}
|
||||
|
||||
|
||||
/* Get msp and pc value */
|
||||
for(i=0;i<g_cpu_count;i++){
|
||||
if(g_boot_img_cfg[i].img_valid){
|
||||
if(g_boot_img_cfg[i].entry_point==0){
|
||||
#ifdef ARCH_ARM
|
||||
blsp_mediaboot_read(g_boot_img_cfg[i].img_start.flash_offset,
|
||||
(uint8_t *)&g_boot_img_cfg[i].msp_val,4);
|
||||
blsp_mediaboot_read(g_boot_img_cfg[i].img_start.flash_offset+4,
|
||||
(uint8_t *)&g_boot_img_cfg[i].entry_point,4);
|
||||
#endif
|
||||
#ifdef ARCH_RISCV
|
||||
g_boot_img_cfg[i].entry_point=g_boot_cpu_cfg[i].default_xip_addr;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
if(blsp_boot2_get_feature_flag()==BLSP_BOOT2_CP_FLAG){
|
||||
/*co-processor*/
|
||||
g_boot_img_cfg[1].img_start.flash_offset=g_boot_img_cfg[0].img_start.flash_offset;
|
||||
g_boot_img_cfg[1].msp_val=g_boot_img_cfg[0].msp_val;
|
||||
g_boot_img_cfg[1].entry_point=g_boot_img_cfg[0].entry_point;
|
||||
g_boot_img_cfg[1].cache_enable=g_boot_img_cfg[0].cache_enable;
|
||||
g_boot_img_cfg[1].img_valid=1;
|
||||
g_boot_img_cfg[1].cache_way_disable=0xf;
|
||||
}
|
||||
MSG_DBG("%08x,%08x\r\n",g_boot_img_cfg[0].msp_val,g_boot_img_cfg[0].entry_point);
|
||||
MSG_DBG("%08x,%08x\r\n",g_boot_img_cfg[1].msp_val,g_boot_img_cfg[1].entry_point);
|
||||
MSG_DBG("%08x,%08x\r\n",g_boot_img_cfg[0].img_start.flash_offset,g_boot_img_cfg[0].cache_way_disable);
|
||||
MSG_DBG("%08x,%08x\r\n",g_boot_img_cfg[1].img_start.flash_offset,g_boot_img_cfg[1].cache_way_disable);
|
||||
MSG_DBG("CPU Count %d,%d\r\n",g_cpu_count,g_boot_img_cfg[0].halt_cpu1);
|
||||
blsp_boot2_show_timer();
|
||||
|
||||
/* Fix invalid pc and msp */
|
||||
blsp_fix_invalid_msp_pc();
|
||||
if(BFLB_EFLASH_LOADER_HANDSHAKE_SUSS == bflb_eflash_loader_uart_handshake_poll()){
|
||||
bflb_eflash_loader_main();
|
||||
}
|
||||
/* Prepare jump to entry*/
|
||||
blsp_mediaboot_pre_jump();
|
||||
|
||||
/* We should never get here unless something is wrong */
|
||||
return BFLB_BOOT2_FAIL;
|
||||
}
|
||||
|
||||
/*@} end of group BLSP_MEDIA_BOOT_Public_Functions */
|
||||
|
||||
/*@} end of group BLSP_MEDIA_BOOT */
|
||||
|
||||
/*@} end of group BL606_BLSP_Boot2 */
|
85
examples/boot2_iap/blsp_media_boot.h
Normal file
85
examples/boot2_iap/blsp_media_boot.h
Normal file
@ -0,0 +1,85 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file blsp_media_boot.h
|
||||
* @version V1.2
|
||||
* @date
|
||||
* @brief This file is the peripheral case header file
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT(c) 2018 Bouffalo Lab</center></h2>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of Bouffalo Lab nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef __BLSP_MEDIA_BOOT_H__
|
||||
#define __BLSP_MEDIA_BOOT_H__
|
||||
|
||||
#include "stdint.h"
|
||||
#include "stdio.h"
|
||||
#include "string.h"
|
||||
|
||||
/** @addtogroup BL606_BLSP_Boot2
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup BLSP_MEDIA_BOOT
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup BLSP_MEDIA_BOOT_Public_Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*@} end of group BLSP_MEDIA_BOOT_Public_Types */
|
||||
|
||||
/** @defgroup BLSP_MEDIA_BOOT_Public_Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*@} end of group BLSP_MEDIA_BOOT_Public_Constants */
|
||||
|
||||
/** @defgroup BLSP_MEDIA_BOOT_Public_Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*@} end of group BLSP_MEDIA_BOOT_Public_Macros */
|
||||
|
||||
/** @defgroup BLSP_MEDIA_BOOT_Public_Functions
|
||||
* @{
|
||||
*/
|
||||
int32_t blsp_mediaboot_read(uint32_t addr,uint8_t *data, uint32_t len);
|
||||
//uint32_t BLSP_MediaBoot_Get_Flash_Cfg(uint32_t bootheaderAddr);
|
||||
//int32_t BLSP_MediaBoot_Cache_Enable(uint8_t contRead);
|
||||
int32_t blsp_mediaboot_main(uint32_t cpu_boot_header_addr[BFLB_BOOT2_CPU_MAX],uint8_t cpu_roll_back[BFLB_BOOT2_CPU_MAX],uint8_t roll_back);
|
||||
void blsp_boot2_show_timer(void);
|
||||
//int32_t ATTR_TCM_SECTION BLSP_MediaBoot_Set_Encrypt(uint8_t index,boot_image_config *g_boot_img_cfg);
|
||||
|
||||
/*@} end of group BLSP_MEDIA_BOOT_Public_Functions */
|
||||
|
||||
/*@} end of group BLSP_MEDIA_BOOT */
|
||||
|
||||
/*@} end of group BL606_BLSP_Boot2 */
|
||||
|
||||
#endif /* __BLSP_MEDIA_BOOT_H__ */
|
666
examples/boot2_iap/blsp_port.c
Normal file
666
examples/boot2_iap/blsp_port.c
Normal file
@ -0,0 +1,666 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file blsp_port.c
|
||||
* @version V1.2
|
||||
* @date
|
||||
* @brief This file is the peripheral case c file
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT(c) 2018 Bouffalo Lab</center></h2>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of Bouffalo Lab nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include "stdio.h"
|
||||
#include "stdint.h"
|
||||
#include "string.h"
|
||||
#include "blsp_port.h"
|
||||
#include "bflb_platform.h"
|
||||
#include "blsp_bootinfo.h"
|
||||
#include "blsp_common.h"
|
||||
#include "blsp_media_boot.h"
|
||||
#include "tzc_sec_reg.h"
|
||||
|
||||
/** @addtogroup BL606_BLSP_Boot2
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup BLSP_PORT
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup BLSP_PORT_Private_Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*@} end of group BLSP_PORT_Private_Macros */
|
||||
|
||||
/** @defgroup BLSP_PORT_Private_Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*@} end of group BLSP_PORT_Private_Types */
|
||||
|
||||
/** @defgroup BLSP_PORT_Private_Variables
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*@} end of group BLSP_PORT_Private_Variables */
|
||||
|
||||
/** @defgroup BLSP_PORT_Global_Variables
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*@} end of group BLSP_PORT_Global_Variables */
|
||||
|
||||
/** @defgroup BLSP_PORT_Private_Fun_Declaration
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*@} end of group BLSP_PORT_Private_Fun_Declaration */
|
||||
|
||||
/** @defgroup BLSP_PORT_Private_Functions_User_Define
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*@} end of group BLSP_PORT_Private_Functions_User_Define */
|
||||
|
||||
/** @defgroup BLSP_PORT_Private_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*@} end of group BLSP_PORT_Private_Functions */
|
||||
|
||||
/** @defgroup BLSP_PORT_Public_Functions
|
||||
* @{
|
||||
*/
|
||||
/****************************************************************************//**
|
||||
* @brief Boot2 init timer for cal boot time
|
||||
*
|
||||
* @param None
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************/
|
||||
void blsp_boot2_init_timer(void)
|
||||
{
|
||||
TIMER_CFG_Type timer_cfg = {
|
||||
TIMER_CH0, /* timer channel 0 */
|
||||
TIMER_CLKSRC_FCLK, /* timer clock source:bus clock */
|
||||
TIMER_PRELOAD_TRIG_NONE, /* reaload on comaparator 2 */
|
||||
TIMER_COUNT_FREERUN, /* preload when match occur */
|
||||
159, /* clock divider */
|
||||
0xfffffffe, /* match value 0 */
|
||||
0xfffffffe, /* match value 1 */
|
||||
0xfffffffe, /* match value 2 */
|
||||
0, /* preload value */
|
||||
};
|
||||
|
||||
/* Disable all interrupt */
|
||||
TIMER_IntMask(timer_cfg.timerCh, TIMER_INT_ALL, MASK);
|
||||
|
||||
/* Disable timer before config */
|
||||
TIMER_Disable(timer_cfg.timerCh);
|
||||
|
||||
/* Timer init with default configuration */
|
||||
TIMER_Init(&timer_cfg);
|
||||
|
||||
/* Enable timer */
|
||||
TIMER_Enable(timer_cfg.timerCh);
|
||||
}
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief Boot2 Disable other CPU cache
|
||||
*
|
||||
* @param None
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************/
|
||||
void blsp_boot2_disable_other_cache(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief Boot2 Flash Boot2 cache
|
||||
*
|
||||
* @param None
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************/
|
||||
void blsp_boot2_flush_xip_cache()
|
||||
{
|
||||
L1C_Cache_Flush(0xf);
|
||||
}
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief Boot2 Get fw clock config
|
||||
*
|
||||
* @param cfg: Clock config pointer
|
||||
*
|
||||
* @return boot_error_code
|
||||
*
|
||||
*******************************************************************************/
|
||||
int32_t ATTR_TCM_SECTION blsp_boot2_get_clk_cfg(boot_clk_config *cfg)
|
||||
{
|
||||
|
||||
XIP_SFlash_Read_Via_Cache_Need_Lock(8+sizeof(boot_flash_config)+BLSP_BOOT2_XIP_BASE,
|
||||
(uint8_t *)cfg,sizeof(boot_clk_config));
|
||||
|
||||
return BFLB_BOOT2_SUCCESS;
|
||||
}
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief Boot2 show timer for cal boot time
|
||||
*
|
||||
* @param None
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************/
|
||||
void blsp_boot2_show_timer(void)
|
||||
{
|
||||
MSG("Counter value=%d\n",(unsigned int)bflb_platform_get_time_ms());
|
||||
}
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief Boot2 get efuse config security
|
||||
*
|
||||
* @param None
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************/
|
||||
void ATTR_TCM_SECTION blsp_boot2_get_efuse_cfg(boot_efuse_hw_config *g_efuse_cfg)
|
||||
{
|
||||
uint32_t tmp;
|
||||
|
||||
HBN_Set_ROOT_CLK_Sel(HBN_ROOT_CLK_XTAL);
|
||||
|
||||
/* Get sign and aes type*/
|
||||
EF_Ctrl_Read_Secure_Boot((EF_Ctrl_Sign_Type*)g_efuse_cfg->sign, (EF_Ctrl_SF_AES_Type*)g_efuse_cfg->encrypted);
|
||||
/* Get hash:aes key slot 0 and slot1*/
|
||||
EF_Ctrl_Read_AES_Key(0,(uint32_t *)g_efuse_cfg->pk_hash_cpu0,8);
|
||||
EF_Ctrl_Read_Chip_ID(g_efuse_cfg->chip_id);
|
||||
/* Get HBN check sign config */
|
||||
EF_Ctrl_Read_Sw_Usage(0,&tmp);
|
||||
g_efuse_cfg->hbn_check_sign=(tmp>>22)&0x01;
|
||||
|
||||
GLB_Set_System_CLK_Div(0,1);
|
||||
HBN_Set_ROOT_CLK_Sel(HBN_ROOT_CLK_DLL);
|
||||
}
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief Boot2 reset sec_eng module
|
||||
*
|
||||
* @param None
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************/
|
||||
void blsp_boot2_reset_sec_eng(void)
|
||||
{
|
||||
GLB_AHB_Slave1_Reset(BL_AHB_SLAVE1_SEC);
|
||||
}
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief Boot2 init sec_eng PKA module
|
||||
*
|
||||
* @param None
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************/
|
||||
void BLSP_Boot2_Init_Sec_Eng_PKA(void)
|
||||
{
|
||||
Sec_Eng_PKA_Reset();
|
||||
Sec_Eng_PKA_BigEndian_Enable();
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief Boot2 get cpu count info
|
||||
*
|
||||
* @param None
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************/
|
||||
uint32_t blsp_boot2_get_cpu_count(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief Read power save mode
|
||||
*
|
||||
* @param None
|
||||
*
|
||||
* @return BFLB_PSM_ACTIVE or BFLB_PSM_HBN
|
||||
*
|
||||
*******************************************************************************/
|
||||
uint8_t blsp_read_power_save_mode(void)
|
||||
{
|
||||
if(HBN_Get_Status_Flag()==HBN_STATUS_WAKEUP_FLAG){
|
||||
return BFLB_PSM_HBN;
|
||||
}else{
|
||||
return BFLB_PSM_ACTIVE;
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief Boot2 Pass parameter to FW
|
||||
*
|
||||
* @param data: Data pointer to pass
|
||||
* @param len: Data length
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************/
|
||||
void blsp_boot2_pass_parameter(void *data,uint32_t len)
|
||||
{
|
||||
static uint8_t *p_parameter=NULL;
|
||||
if(len==0){
|
||||
GLB_Set_EM_Sel(0);
|
||||
p_parameter=(uint8_t *)(0x42020000+60*1024);
|
||||
return;
|
||||
}
|
||||
ARCH_MemCpy_Fast(p_parameter,data,len);
|
||||
p_parameter+=len;
|
||||
}
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief Boot2 Get XIP offset
|
||||
*
|
||||
* @param None
|
||||
*
|
||||
* @return XIP offset
|
||||
*
|
||||
*******************************************************************************/
|
||||
uint32_t blsp_boot2_get_xip_offset(void)
|
||||
{
|
||||
return SF_Ctrl_Get_Flash_Image_Offset();
|
||||
}
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief Get User specified firmware to boot up
|
||||
*
|
||||
* @param None
|
||||
*
|
||||
* @return User specified firmware name
|
||||
*
|
||||
*******************************************************************************/
|
||||
uint8_t* blsp_get_user_specified_fw(void)
|
||||
{
|
||||
return (uint8_t*)(HBN_BASE+HBN_RSV0_OFFSET);
|
||||
}
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief Clear User specified firmware to boot up
|
||||
*
|
||||
* @param None
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************/
|
||||
void blsp_clr_user_specified_fw(void)
|
||||
{
|
||||
uint32_t *p=(uint32_t*)(HBN_BASE+HBN_RSV0_OFFSET);
|
||||
|
||||
*p=0;
|
||||
}
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief Release other CPU
|
||||
*
|
||||
* @param None
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************/
|
||||
void ATTR_TCM_SECTION blsp_boot2_releae_other_cpu(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief Set encryption config
|
||||
*
|
||||
* @param index: Region index
|
||||
* @param g_boot_img_cfg: Boot image config pointer to hold parsed information
|
||||
*
|
||||
* @return BL_Err_Type
|
||||
*
|
||||
*******************************************************************************/
|
||||
int32_t ATTR_TCM_SECTION blsp_boot2_set_encrypt(uint8_t index,boot_image_config *g_boot_img_cfg)
|
||||
{
|
||||
uint32_t aes_enabled=0;
|
||||
uint32_t len=0;
|
||||
|
||||
/* FIXME:,1:lock, should be 1??*/
|
||||
if(g_boot_img_cfg->encrypt_type!=0){
|
||||
len=g_boot_img_cfg->img_segment_info.img_len;
|
||||
if(len!=0){
|
||||
SF_Ctrl_AES_Set_Key_BE(index,NULL,(SF_Ctrl_AES_Key_Type)(g_boot_img_cfg->encrypt_type-1));
|
||||
SF_Ctrl_AES_Set_IV_BE(index,g_boot_img_cfg->aes_iv,g_boot_img_cfg->img_start.flash_offset);
|
||||
|
||||
SF_Ctrl_AES_Set_Region(index,1/*enable this region*/,1/*hardware key*/,
|
||||
g_boot_img_cfg->img_start.flash_offset,
|
||||
g_boot_img_cfg->img_start.flash_offset+len-1,
|
||||
g_boot_img_cfg->aes_region_lock/*lock*/);
|
||||
aes_enabled=1;
|
||||
}
|
||||
}
|
||||
|
||||
if(aes_enabled){
|
||||
SF_Ctrl_AES_Enable_BE();
|
||||
SF_Ctrl_AES_Enable();
|
||||
}
|
||||
|
||||
return BFLB_BOOT2_SUCCESS;
|
||||
}
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief Media boot set cache according to image config
|
||||
*
|
||||
* @param None
|
||||
*
|
||||
* @return BL_Err_Type
|
||||
*
|
||||
*******************************************************************************/
|
||||
int32_t ATTR_TCM_SECTION blsp_boot2_set_cache(uint8_t cont_read,SPI_Flash_Cfg_Type *flash_cfg,boot_image_config *g_boot_img_cfg)
|
||||
{
|
||||
uint32_t tmp[1];
|
||||
uint32_t stat;
|
||||
|
||||
/* To make it simple, exit cont read anyway */
|
||||
SF_Ctrl_Set_Owner(SF_CTRL_OWNER_SAHB);
|
||||
|
||||
SFlash_Reset_Continue_Read(flash_cfg);
|
||||
if(flash_cfg->cReadSupport==0){
|
||||
cont_read=0;
|
||||
}
|
||||
|
||||
if(cont_read==1){
|
||||
stat=SFlash_Read(flash_cfg, flash_cfg->ioMode&0xf, 1, 0x00000000, (uint8_t *)tmp, sizeof(tmp));
|
||||
if(SUCCESS!=stat){
|
||||
return BFLB_BOOT2_FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Set default value */
|
||||
L1C_Cache_Enable_Set(0xf);
|
||||
|
||||
|
||||
if(g_boot_img_cfg[0].cache_enable){
|
||||
if((g_boot_img_cfg[0].entry_point&0xFF000000)==BLSP_BOOT2_XIP_BASE){
|
||||
SF_Ctrl_Set_Flash_Image_Offset(g_boot_img_cfg[0].img_start.flash_offset);
|
||||
SFlash_Cache_Read_Enable(flash_cfg, flash_cfg->ioMode&0xf, cont_read, g_boot_img_cfg[0].cache_way_disable);
|
||||
}else{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return BFLB_BOOT2_SUCCESS;
|
||||
}
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief Check if MSP is valid
|
||||
*
|
||||
* @param msp_val: MSP value
|
||||
*
|
||||
* @return 1 for valid and 0 for invalid
|
||||
*
|
||||
*******************************************************************************/
|
||||
int32_t blsp_is_msp_valid(uint32_t msp_val)
|
||||
{
|
||||
if(msp_val>BL702_WRAM_BASE&&msp_val<=BL702_WRAM_END){
|
||||
return 1;
|
||||
}else if(msp_val>BL702_WRAM_REMAP0_BASE&&msp_val<=BL702_WRAM_REMAP0_END){
|
||||
return 1;
|
||||
}else if(msp_val>BL702_WRAM_REMAP1_BASE&&msp_val<=BL702_WRAM_REMAP1_END){
|
||||
return 1;
|
||||
}else if(msp_val>BL702_WRAM_REMAP2_BASE&&msp_val<=BL702_WRAM_REMAP2_END){
|
||||
return 1;
|
||||
}else if(msp_val>BL702_TCM_BASE&&msp_val<=BL702_TCM_END){
|
||||
return 1;
|
||||
}else if(msp_val>BL702_TCM_REMAP0_BASE&&msp_val<=BL702_TCM_REMAP0_END){
|
||||
return 1;
|
||||
}else if(msp_val>BL702_TCM_REMAP1_BASE&&msp_val<=BL702_TCM_REMAP1_END){
|
||||
return 1;
|
||||
}else if(msp_val>BL702_TCM_REMAP2_BASE&&msp_val<=BL702_TCM_REMAP2_END){
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief Check if PC is valid
|
||||
*
|
||||
* @param pcVal: PC value
|
||||
*
|
||||
* @return 1 for valid and 0 for invalid
|
||||
*
|
||||
*******************************************************************************/
|
||||
int32_t blsp_is_pc_valid(uint32_t pc_val)
|
||||
{
|
||||
/* Check XIP memory */
|
||||
if(pc_val>=BL702_FLASH_XIP_BASE&&pc_val<BL702_FLASH_XIP_END){
|
||||
return 1;
|
||||
}else if(pc_val>=BL702_FLASH_XIP_REMAP0_BASE&&pc_val<BL702_FLASH_XIP_REMAP0_END){
|
||||
return 1;
|
||||
}else if(pc_val>=BL702_FLASH_XIP_REMAP1_BASE&&pc_val<BL702_FLASH_XIP_REMAP1_END){
|
||||
return 1;
|
||||
}else if(pc_val>=BL702_FLASH_XIP_REMAP2_BASE&&pc_val<BL702_FLASH_XIP_REMAP2_END){
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Check RAM memory */
|
||||
if(pc_val>=BL702_WRAM_BASE&&pc_val<BL702_WRAM_END){
|
||||
return 1;
|
||||
}else if(pc_val>=BL702_WRAM_REMAP0_BASE&&pc_val<BL702_WRAM_REMAP0_END){
|
||||
return 1;
|
||||
}else if(pc_val>=BL702_WRAM_REMAP1_BASE&&pc_val<BL702_WRAM_REMAP1_END){
|
||||
return 1;
|
||||
}else if(pc_val>=BL702_WRAM_REMAP2_BASE&&pc_val<BL702_WRAM_REMAP2_END){
|
||||
return 1;
|
||||
}else if(pc_val>=BL702_TCM_BASE&&pc_val<BL702_TCM_END){
|
||||
return 1;
|
||||
}else if(pc_val>=BL702_TCM_REMAP0_BASE&&pc_val<BL702_TCM_REMAP0_END){
|
||||
return 1;
|
||||
}else if(pc_val>=BL702_TCM_REMAP1_BASE&&pc_val<BL702_TCM_REMAP1_END){
|
||||
return 1;
|
||||
}else if(pc_val>=BL702_TCM_REMAP2_BASE&&pc_val<BL702_TCM_REMAP2_END){
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief Security boot finished
|
||||
*
|
||||
* @param None
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************/
|
||||
void ATTR_TCM_SECTION blsp_sboot_finish(void)
|
||||
{
|
||||
uint32_t tmp_val;
|
||||
|
||||
tmp_val=BL_RD_REG(TZC_SEC_BASE,TZC_SEC_TZC_ROM_CTRL);
|
||||
|
||||
tmp_val=BL_SET_REG_BITS_VAL(tmp_val,TZC_SEC_TZC_SBOOT_DONE,0xf);
|
||||
|
||||
BL_WR_REG(TZC_SEC_BASE,TZC_SEC_TZC_ROM_CTRL,tmp_val);
|
||||
}
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief Fix MSP and PC,if they are invalid
|
||||
*
|
||||
* @param None
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************/
|
||||
void blsp_fix_invalid_msp_pc(void)
|
||||
{
|
||||
uint32_t i=0;
|
||||
|
||||
for(i=0;i<BFLB_BOOT2_CPU_MAX;i++){
|
||||
if(!blsp_is_msp_valid(g_boot_img_cfg[i].msp_val)){
|
||||
g_boot_img_cfg[i].msp_val=0;
|
||||
}
|
||||
if(!blsp_is_pc_valid(g_boot_img_cfg[i].entry_point)){
|
||||
g_boot_img_cfg[i].entry_point=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
typedef void( *pFunc )( void );
|
||||
extern pFunc __Vectors[];
|
||||
/****************************************************************************//**
|
||||
* @brief Boot2 Get log tx GPIO
|
||||
*
|
||||
* @param None
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************/
|
||||
uint8_t ATTR_TCM_SECTION blsp_boot2_get_tx_gpio(void)
|
||||
{
|
||||
uint8_t *p=((uint8_t *)&__Vectors[9]+1);
|
||||
|
||||
return *p;
|
||||
}
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief Boot2 Get UART Port
|
||||
*
|
||||
* @param None
|
||||
*
|
||||
* @return 0(UART0)/1(UART1)
|
||||
*
|
||||
*******************************************************************************/
|
||||
uint8_t ATTR_TCM_SECTION blsp_boot2_get_uart_port(void)
|
||||
{
|
||||
uint8_t *p=((uint8_t *)&__Vectors[9]+2);
|
||||
|
||||
return *p;
|
||||
}
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief Boot2 Get Feature Flag
|
||||
*
|
||||
* @param None
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************/
|
||||
uint8_t ATTR_TCM_SECTION blsp_boot2_get_feature_flag(void)
|
||||
{
|
||||
static uint8_t boot2_flag=0xff;
|
||||
uint8_t *p=((uint8_t *)&__Vectors[10]+0);
|
||||
|
||||
if(boot2_flag==0xff){
|
||||
boot2_flag=*p;
|
||||
}
|
||||
return boot2_flag;
|
||||
}
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief Boot2 Get log disable Flag
|
||||
*
|
||||
* @param None
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************/
|
||||
uint8_t ATTR_TCM_SECTION blsp_boot2_get_log_disable_flag(void)
|
||||
{
|
||||
uint8_t *p=((uint8_t *)&__Vectors[10]+1);
|
||||
|
||||
return *p;
|
||||
}
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief Boot2 Get 8M Flash support Flag
|
||||
*
|
||||
* @param None
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************/
|
||||
uint8_t ATTR_TCM_SECTION blsp_boot2_8m_support_flag(void)
|
||||
{
|
||||
uint8_t *p=((uint8_t *)&__Vectors[10]+2);
|
||||
|
||||
return *p;
|
||||
}
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief Boot2 Get dump critical data flag
|
||||
*
|
||||
* @param None
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************/
|
||||
uint8_t ATTR_TCM_SECTION blsp_boot2_dump_critical_flag(void)
|
||||
{
|
||||
uint8_t *p=((uint8_t *)&__Vectors[10]+3);
|
||||
|
||||
return *p;
|
||||
}
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief Boot2 Get Baudrate
|
||||
*
|
||||
* @param None
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************/
|
||||
uint32_t ATTR_TCM_SECTION blsp_boot2_get_baudrate(void)
|
||||
{
|
||||
uint32_t *p=((uint32_t *)&__Vectors[13]);
|
||||
|
||||
return *p;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*@} end of group BLSP_PORT_Public_Functions */
|
||||
|
||||
/*@} end of group BLSP_PORT */
|
||||
|
||||
/*@} end of group BL606_BLSP_Boot2 */
|
123
examples/boot2_iap/blsp_port.h
Normal file
123
examples/boot2_iap/blsp_port.h
Normal file
@ -0,0 +1,123 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file blsp_port.h
|
||||
* @version V1.2
|
||||
* @date
|
||||
* @brief This file is the peripheral case header file
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT(c) 2018 Bouffalo Lab</center></h2>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of Bouffalo Lab nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef __BLSP_PORT_H__
|
||||
#define __BLSP_PORT_H__
|
||||
|
||||
#include "stdint.h"
|
||||
#include "bl702_glb.h"
|
||||
#include "bl702_aon.h"
|
||||
#include "bl702_hbn.h"
|
||||
#include "bl702_ef_ctrl.h"
|
||||
#include "bl702_sflash.h"
|
||||
#include "bl702_xip_sflash.h"
|
||||
#include "bl702_xip_sflash_ext.h"
|
||||
#include "bl702_sf_cfg.h"
|
||||
#include "bl702_timer.h"
|
||||
#include "bl702_sec_eng.h"
|
||||
//#include "bflb_ecdsa.h"
|
||||
|
||||
/** @addtogroup BL606_BLSP_Boot2
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup BLSP_PORT
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup BLSP_PORT_Public_Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*@} end of group BLSP_PORT_Public_Types */
|
||||
|
||||
/** @defgroup BLSP_PORT_Public_Constants
|
||||
* @{
|
||||
*/
|
||||
/*CPU1's MSP and PC from NP bootrom*/
|
||||
//#define BFLB_BOOT2_CPU1_APP_PC_ADDR (BL60X_SRAM_END-4)
|
||||
//#define BFLB_BOOT2_CPU1_APP_MSP_ADDR (BL60X_SRAM_END-8)
|
||||
//#define BFLB_BOOT2_CPU1_DBG_INFO_ADDR (BL60X_SRAM_END-12)
|
||||
#define BFLB_BOOT2_CPU1_APP_PC_ADDR (0)
|
||||
#define BFLB_BOOT2_CPU1_APP_MSP_ADDR (0)
|
||||
#define BFLB_BOOT2_CPU1_DBG_INFO_ADDR (0)
|
||||
#define MFG_START_REQUEST_OFFSET ((4+184)*1024)
|
||||
#define BLSP_BOOT2_XIP_BASE BL702_FLASH_XIP_BASE
|
||||
#define ARCH_Delay_MS BL702_Delay_MS
|
||||
|
||||
/*@} end of group BLSP_PORT_Public_Constants */
|
||||
|
||||
/** @defgroup BLSP_PORT_Public_Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*@} end of group BLSP_PORT_Public_Macros */
|
||||
|
||||
/** @defgroup BLSP_PORT_Public_Functions
|
||||
* @{
|
||||
*/
|
||||
void blsp_boot2_init_timer(void);
|
||||
void blsp_boot2_disable_other_cache(void);
|
||||
void blsp_boot2_flush_xip_cache(void);
|
||||
void blsp_boot2_show_timer(void);
|
||||
void blsp_boot2_reset_sec_eng(void);
|
||||
void blsp_boot2_init_sec_eng_pka(void);
|
||||
uint32_t blsp_boot2_get_cpu_count(void);
|
||||
uint8_t blsp_read_power_save_mode(void);
|
||||
void blsp_boot2_pass_parameter(void *data,uint32_t len);
|
||||
uint32_t blsp_boot2_get_xip_offset();
|
||||
uint8_t* blsp_get_user_specified_fw(void);
|
||||
void blsp_clr_user_specified_fw(void);
|
||||
void blsp_boot2_releae_other_cpu(void);
|
||||
int32_t blsp_is_msp_valid(uint32_t msp_val);
|
||||
int32_t blsp_is_pc_valid(uint32_t pc_val);
|
||||
void ATTR_TCM_SECTION blsp_sboot_finish(void);;
|
||||
void blsp_fix_invalid_msp_pc(void);
|
||||
uint8_t blsp_boot2_get_tx_gpio(void);
|
||||
uint8_t blsp_boot2_get_uart_port(void);
|
||||
uint8_t blsp_boot2_get_feature_flag(void);
|
||||
uint8_t blsp_boot2_get_log_disable_flag(void);
|
||||
uint8_t blsp_boot2_8m_support_flag(void);
|
||||
uint8_t blsp_boot2_dump_critical_flag(void);
|
||||
uint32_t blsp_boot2_get_baudrate(void);
|
||||
void blsp_boot2_init_gpio_for_bootrom();
|
||||
|
||||
/*@} end of group BLSP_PORT_Public_Functions */
|
||||
|
||||
/*@} end of group BLSP_PORT */
|
||||
|
||||
/*@} end of group BL606_BLSP_Boot2 */
|
||||
|
||||
#endif /* __BLSP_PORT_H__ */
|
41
examples/boot2_iap/blsp_version.h
Normal file
41
examples/boot2_iap/blsp_version.h
Normal file
@ -0,0 +1,41 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file blsp_version.h
|
||||
* @version V1.2
|
||||
* @date
|
||||
* @brief This file is the peripheral case header file
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT(c) 2018 Bouffalo Lab</center></h2>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of Bouffalo Lab nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef __MCU_SDK_VERSION_H__
|
||||
#define __MCU_SDK_VERSION_H__
|
||||
|
||||
#define BL_SDK_VER "1.00"
|
||||
|
||||
#endif
|
1
examples/boot2_iap/compile_cmd.txt
Normal file
1
examples/boot2_iap/compile_cmd.txt
Normal file
@ -0,0 +1 @@
|
||||
make build SUPPORT_XZ=y APP=boot2 BOARD=bl706_avb
|
29
examples/boot2_iap/partition_cfg_1M.toml
Normal file
29
examples/boot2_iap/partition_cfg_1M.toml
Normal file
@ -0,0 +1,29 @@
|
||||
[pt_table]
|
||||
#partition table is 4K in size
|
||||
address0 = 0xE000
|
||||
address1 = 0xF000
|
||||
|
||||
[[pt_entry]]
|
||||
type = 0
|
||||
name = "FW"
|
||||
device = 0
|
||||
address0 = 0x010000
|
||||
size0 = 0x60000
|
||||
address1 = 0x70000
|
||||
size1 = 0x60000
|
||||
# compressed image must set len,normal image can left it to 0
|
||||
len = 0
|
||||
|
||||
|
||||
|
||||
[[pt_entry]]
|
||||
type = 7
|
||||
name = "factory"
|
||||
device = 0
|
||||
address0 = 0x0FB000
|
||||
size0 = 0x4000
|
||||
address1 = 0
|
||||
size1 = 0
|
||||
# compressed image must set len,normal image can left it to 0
|
||||
len = 0
|
||||
|
6
examples/camera/camera_interleave/CMakeLists.txt
Normal file
6
examples/camera/camera_interleave/CMakeLists.txt
Normal file
@ -0,0 +1,6 @@
|
||||
set(BSP_COMMON_DIR ${CMAKE_SOURCE_DIR}/bsp/bsp_common)
|
||||
set(LINKER_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/bl706_camera.ld)
|
||||
set(TARGET_REQUIRED_PRIVATE_INCLUDE ${BSP_COMMON_DIR}/image_sensor)
|
||||
set(TARGET_REQUIRED_SRCS ${BSP_COMMON_DIR}/image_sensor/bsp_image_sensor.c)
|
||||
set(mains main.c)
|
||||
generate_bin()
|
227
examples/camera/camera_interleave/bl706_camera.ld
Normal file
227
examples/camera/camera_interleave/bl706_camera.ld
Normal file
@ -0,0 +1,227 @@
|
||||
/****************************************************************************************
|
||||
* @file map.txt
|
||||
*
|
||||
* @brief This file is the map file (gnuarm or armgcc).
|
||||
*
|
||||
* Copyright (C) BouffaloLab 2018
|
||||
*
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/* configure the CPU type */
|
||||
OUTPUT_ARCH( "riscv" )
|
||||
/* link with the standard c library */
|
||||
INPUT(-lc)
|
||||
/* link with the standard GCC library */
|
||||
INPUT(-lgcc)
|
||||
/* configure the entry point */
|
||||
ENTRY(_enter)
|
||||
|
||||
StackSize = 0x1000; /* 4KB */
|
||||
HeapSize = 0x1000; /* 4KB */
|
||||
|
||||
MEMORY
|
||||
{
|
||||
xip_memory (rx) : ORIGIN = 0x23000000, LENGTH = 1024K
|
||||
itcm_memory (rx) : ORIGIN = 0x22014000, LENGTH = 10K
|
||||
dtcm_memory (rx) : ORIGIN = 0x42016800, LENGTH = 10K
|
||||
ram_memory (!rx) : ORIGIN = 0x42019000, LENGTH = 20K
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
PROVIDE(__metal_chicken_bit = 0);
|
||||
|
||||
.text :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__text_code_start__ = .;
|
||||
|
||||
KEEP (*(.text.metal.init.enter))
|
||||
KEEP (*(SORT_NONE(.init)))
|
||||
/* section information for finsh shell */
|
||||
. = ALIGN(4);
|
||||
_shell_command_start = .;
|
||||
KEEP(*(shellCommand))
|
||||
_shell_command_end = .;
|
||||
|
||||
/* section information for usb desc */
|
||||
. = ALIGN(4);
|
||||
_usb_desc_start = .;
|
||||
KEEP(*(usb_desc))
|
||||
. = ALIGN(4);
|
||||
_usb_desc_end = .;
|
||||
|
||||
*(.text)
|
||||
*(.text.*)
|
||||
|
||||
/*put .rodata**/
|
||||
*(EXCLUDE_FILE( *bl702_glb.o \
|
||||
*bl702_pds.o \
|
||||
*bl702_common.o \
|
||||
*bl702_sf_cfg.o \
|
||||
*bl702_sf_ctrl.o \
|
||||
*bl702_sflash.o \
|
||||
*bl702_xip_sflash.o \
|
||||
*bl702_ef_ctrl.o) .rodata*)
|
||||
*(.rodata)
|
||||
*(.rodata.*)
|
||||
|
||||
*(.srodata)
|
||||
*(.srodata.*)
|
||||
|
||||
. = ALIGN(4);
|
||||
__text_code_end__ = .;
|
||||
} > xip_memory
|
||||
|
||||
. = ALIGN(4);
|
||||
__itcm_load_addr = .;
|
||||
|
||||
.itcm_region : AT (__itcm_load_addr)
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__tcm_code_start__ = .;
|
||||
|
||||
*(.tcm_code)
|
||||
*(.tcm_const)
|
||||
*(.sclock_rlt_code)
|
||||
*(.sclock_rlt_const)
|
||||
|
||||
*bl702_glb.o*(.rodata*)
|
||||
*bl702_pds.o*(.rodata*)
|
||||
*bl702_common.o*(.rodata*)
|
||||
*bl702_sf_cfg.o*(.rodata*)
|
||||
*bl702_sf_ctrl.o*(.rodata*)
|
||||
*bl702_sflash.o*(.rodata*)
|
||||
*bl702_xip_sflash.o*(.rodata*)
|
||||
*bl702_ef_ctrl.o*(.rodata*)
|
||||
|
||||
. = ALIGN(4);
|
||||
__tcm_code_end__ = .;
|
||||
} > itcm_memory
|
||||
|
||||
__dtcm_load_addr = __itcm_load_addr + SIZEOF(.itcm_region);
|
||||
|
||||
.dtcm_region : AT (__dtcm_load_addr)
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__tcm_data_start__ = .;
|
||||
|
||||
*(.tcm_data)
|
||||
/* *finger_print.o(.data*) */
|
||||
|
||||
. = ALIGN(4);
|
||||
__tcm_data_end__ = .;
|
||||
} > dtcm_memory
|
||||
|
||||
/* .heap_dummy section doesn't contains any symbols. It is only
|
||||
* used for linker to calculate size of heap sections, and assign
|
||||
* values to heap symbols later */
|
||||
.heap_dummy (NOLOAD):
|
||||
{
|
||||
. = ALIGN(0x4);
|
||||
. = . + HeapSize;
|
||||
. = ALIGN(0x4);
|
||||
} > dtcm_memory
|
||||
|
||||
_HeapBase = ORIGIN(dtcm_memory) + LENGTH(dtcm_memory) - StackSize - HeapSize;
|
||||
_HeapSize = HeapSize;
|
||||
|
||||
/* Check if data + heap + stack exceeds RAM limit */
|
||||
ASSERT(_HeapBase >= __tcm_data_end__, "region RAM overflowed with stack")
|
||||
|
||||
/*************************************************************************/
|
||||
/* .stack_dummy section doesn't contains any symbols. It is only
|
||||
* used for linker to calculate size of stack sections, and assign
|
||||
* values to stack symbols later */
|
||||
.stack_dummy (NOLOAD):
|
||||
{
|
||||
. = ALIGN(0x4);
|
||||
. = . + StackSize;
|
||||
. = ALIGN(0x4);
|
||||
} > dtcm_memory
|
||||
|
||||
/* Set stack top to end of RAM, and stack limit move down by
|
||||
* size of stack_dummy section */
|
||||
__StackTop = ORIGIN(dtcm_memory) + LENGTH(dtcm_memory);
|
||||
PROVIDE( __freertos_irq_stack_top = __StackTop);
|
||||
__StackLimit = __StackTop - SIZEOF(.stack_dummy);
|
||||
|
||||
/* Check if data + heap + stack exceeds RAM limit */
|
||||
ASSERT(__StackLimit >= __tcm_data_end__, "region RAM overflowed with stack")
|
||||
/*************************************************************************/
|
||||
|
||||
__system_ram_load_addr = __dtcm_load_addr + SIZEOF(.dtcm_region);
|
||||
|
||||
.system_ram_data_region : AT (__system_ram_load_addr)
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__system_ram_data_start__ = .;
|
||||
|
||||
*(.system_ram)
|
||||
|
||||
. = ALIGN(4);
|
||||
__system_ram_data_end__ = .;
|
||||
} > ram_memory
|
||||
|
||||
__ram_load_addr = __system_ram_load_addr + SIZEOF(.system_ram_data_region);
|
||||
|
||||
/* Data section */
|
||||
RAM_DATA : AT (__ram_load_addr)
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__ram_data_start__ = .;
|
||||
|
||||
PROVIDE( __global_pointer$ = . + 0x800 );
|
||||
|
||||
*(.data)
|
||||
*(.data.*)
|
||||
*(.sdata)
|
||||
*(.sdata.*)
|
||||
*(.sdata2)
|
||||
*(.sdata2.*)
|
||||
|
||||
. = ALIGN(4);
|
||||
__ram_data_end__ = .;
|
||||
} > ram_memory
|
||||
|
||||
.bss (NOLOAD) :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__bss_start__ = .;
|
||||
|
||||
*(.bss*)
|
||||
*(.sbss*)
|
||||
*(COMMON)
|
||||
|
||||
. = ALIGN(4);
|
||||
__bss_end__ = .;
|
||||
} > ram_memory
|
||||
|
||||
.noinit_data (NOLOAD) :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__noinit_data_start__ = .;
|
||||
|
||||
*(.noinit_data*)
|
||||
|
||||
. = ALIGN(4);
|
||||
__noinit_data_end__ = .;
|
||||
} > ram_memory
|
||||
|
||||
.heap (NOLOAD):
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__HeapBase = .;
|
||||
|
||||
/*__end__ = .;*/
|
||||
/*end = __end__;*/
|
||||
KEEP(*(.heap*))
|
||||
|
||||
. = ALIGN(4);
|
||||
__HeapLimit = .;
|
||||
} > ram_memory
|
||||
__HeapLimit = ORIGIN(ram_memory) + LENGTH(ram_memory);
|
||||
|
||||
}
|
||||
|
732
examples/camera/camera_interleave/cdk/camera_interleave.cdkproj
Normal file
732
examples/camera/camera_interleave/cdk/camera_interleave.cdkproj
Normal file
@ -0,0 +1,732 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Project Name="camera_interleave" Version="1" Language="C">
|
||||
<Description>CPU: RV32IMAFC
|
||||
Chip: bl70x
|
||||
Board: bl70x_iot
|
||||
</Description>
|
||||
<Dependencies Name="Debug"/>
|
||||
<VirtualDirectory Name="app">
|
||||
<File Name="../main.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
</VirtualDirectory>
|
||||
<VirtualDirectory Name="chip">
|
||||
<VirtualDirectory Name="riscv">
|
||||
<File Name="../../../../drivers/bl702_driver/startup/interrupt.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/startup/system_bl702.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
</VirtualDirectory>
|
||||
<VirtualDirectory Name="startup">
|
||||
<File Name="../../../../drivers/bl702_driver/startup/GCC/entry.S">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/startup/GCC/start_load.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
</VirtualDirectory>
|
||||
</VirtualDirectory>
|
||||
<VirtualDirectory Name="hal">
|
||||
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_adc.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_dac.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_dma.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_gpio.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_i2c.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_i2s.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_mtimer.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_pwm.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_spi.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_timer.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_uart.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_usb.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_clock.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_cam.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_mjpeg.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
</VirtualDirectory>
|
||||
<VirtualDirectory Name="std">
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_acomp.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_adc.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_aon.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_cam.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_clock.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_dac.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_dma.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_ef_ctrl.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_emac.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_glb.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_hbn.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_i2c.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_i2c_gpio_sim.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_i2s.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_ir.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_common.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_kys.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_l1c.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_mjpeg.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_pds.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_psram.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_pwm.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_qdec.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_romapi.c" ExcludeProjConfig="BuildSet">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_romdriver.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_sec_dbg.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_sec_eng.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_sf_cfg.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_sf_cfg_ext.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_sf_ctrl.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_sflash.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_sflash_ext.c" ExcludeProjConfig="">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_spi.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_timer.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_uart.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_usb.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_xip_sflash.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_xip_sflash_ext.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
</VirtualDirectory>
|
||||
<VirtualDirectory Name="board">
|
||||
<File Name="../../../../bsp/board/bl706_iot/board.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../bsp/bsp_common/platform/bflb_platform.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../bsp/bsp_common/image_sensor/bsp_image_sensor.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
</VirtualDirectory>
|
||||
<VirtualDirectory Name="common">
|
||||
<File Name="../../../../common/device/drv_device.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/memheap/drv_mmheap.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/ring_buffer/ring_buffer.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/soft_crc/softcrc.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<VirtualDirectory Name="libc">
|
||||
<File Name="../../../../common/libc/src/atof.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/atoi.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/atol.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/atoll.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/atox.c" ExcludeProjConfig="BuildSet">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/bsearch.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/common.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/ctype_isalnum.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/ctype_isalpha.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/ctype_isascii.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/ctype_isblank.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/ctype_iscntrl.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/ctype_isdigit.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/ctype_isgraph.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/ctype_islower.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/ctype_isprint.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/ctype_ispunct.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/ctype_isspace.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/ctype_isupper.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/ctype_isxdigit.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/ctype_tolower.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/ctype_toupper.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/ctypes.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/fnmatch.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/jrand48.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/lrand48.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/memccpy.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/memchr.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/memcmp.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/memcpy.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/memmem.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/memrchr.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/memset.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/memswap.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/mrand48.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/nrand48.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/qsort.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/seed48.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/snprintf.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/sprintf.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/srand48.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/sscanf.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/stdlib.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strcasecmp.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strcat.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strchr.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strcmp.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strcpy.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strcspn.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strlcat.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strlcpy.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strlen.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strncasecmp.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strncat.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strncmp.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strncpy.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strnlen.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strntoimax.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strntoumax.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strpbrk.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strrchr.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strsep.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strspn.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strstr.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strtoimax.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strtok.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strtok_r.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strtol.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strtoll.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strtoul.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strtoull.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strtoumax.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strtox.c" ExcludeProjConfig="BuildSet">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strxspn.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/vsnprintf.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/vsprintf.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/vsscanf.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
</VirtualDirectory>
|
||||
<File Name="../../../../common/misc/misc.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
</VirtualDirectory>
|
||||
<VirtualDirectory Name="script">
|
||||
<File Name="../../../../tools/openocd/bl70x_gdb.init">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/regs/bl70x_reg.svc">
|
||||
<FileOption/>
|
||||
</File>
|
||||
</VirtualDirectory>
|
||||
<MonitorProgress>
|
||||
<DebugLaunch>154</DebugLaunch>
|
||||
<FlashOperate>104</FlashOperate>
|
||||
</MonitorProgress>
|
||||
<VirtualDirectory Name="components">
|
||||
<VirtualDirectory Name="fatfs">
|
||||
<File Name="../../../../components/fatfs/diskio.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../components/fatfs/ff.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../components/fatfs/ffsystem.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../components/fatfs/ffunicode.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
</VirtualDirectory>
|
||||
<VirtualDirectory Name="shell">
|
||||
<File Name="../../../../components/shell/drv_shell.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
</VirtualDirectory>
|
||||
<VirtualDirectory Name="usb_stack">
|
||||
<VirtualDirectory Name="class">
|
||||
<VirtualDirectory Name="cdc">
|
||||
<File Name="../../../../components/usb_stack/class/cdc/usbd_cdc.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
</VirtualDirectory>
|
||||
<VirtualDirectory Name="hid">
|
||||
<File Name="../../../../components/usb_stack/class/hid/usbd_hid.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
</VirtualDirectory>
|
||||
<VirtualDirectory Name="msc">
|
||||
<File Name="../../../../components/usb_stack/class/msc/usbd_msc.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
</VirtualDirectory>
|
||||
</VirtualDirectory>
|
||||
<VirtualDirectory Name="core">
|
||||
<File Name="../../../../components/usb_stack/core/usbd_core.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
</VirtualDirectory>
|
||||
</VirtualDirectory>
|
||||
</VirtualDirectory>
|
||||
<Dependencies Name="BuildSet"/>
|
||||
<DebugSessions>
|
||||
<watchExpressions/>
|
||||
<memoryExpressions>;;;</memoryExpressions>
|
||||
<statistics>;;MHZ;</statistics>
|
||||
<peripheralTabs>
|
||||
<Tab disFormat="Hex">glb</Tab>
|
||||
<Tab disFormat="Hex">uart</Tab>
|
||||
</peripheralTabs>
|
||||
<WatchDisplayFormat>1</WatchDisplayFormat>
|
||||
<LocalDisplayFormat>1</LocalDisplayFormat>
|
||||
<debugLayout/>
|
||||
<memoryTabColSizeExpressions>100:8;100:8;100:8;100:8;</memoryTabColSizeExpressions>
|
||||
</DebugSessions>
|
||||
<DebugSessions>
|
||||
<watchExpressions/>
|
||||
<memoryExpressions>;;;</memoryExpressions>
|
||||
<statistics>;;MHZ;</statistics>
|
||||
<peripheralTabs>
|
||||
<Tab disFormat="Hex">glb</Tab>
|
||||
<Tab disFormat="Hex">uart</Tab>
|
||||
</peripheralTabs>
|
||||
<WatchDisplayFormat>1</WatchDisplayFormat>
|
||||
<LocalDisplayFormat>1</LocalDisplayFormat>
|
||||
<debugLayout/>
|
||||
<memoryTabColSizeExpressions>100:8;100:8;100:8;100:8;</memoryTabColSizeExpressions>
|
||||
</DebugSessions>
|
||||
<BuildConfigs>
|
||||
<BuildConfig Name="BuildSet">
|
||||
<Target>
|
||||
<ROMBank Selected="1">
|
||||
<ROM1>
|
||||
<InUse>no</InUse>
|
||||
<Start>0x23000000</Start>
|
||||
<Size>0x100000</Size>
|
||||
</ROM1>
|
||||
<ROM2>
|
||||
<InUse>no</InUse>
|
||||
<Start>0x22014000</Start>
|
||||
<Size>0x4000</Size>
|
||||
</ROM2>
|
||||
<ROM3>
|
||||
<InUse>no</InUse>
|
||||
<Start>0x42018000</Start>
|
||||
<Size>0x8000</Size>
|
||||
</ROM3>
|
||||
<ROM4>
|
||||
<InUse>no</InUse>
|
||||
<Start/>
|
||||
<Size/>
|
||||
</ROM4>
|
||||
<ROM5>
|
||||
<InUse>no</InUse>
|
||||
<Start/>
|
||||
<Size/>
|
||||
</ROM5>
|
||||
</ROMBank>
|
||||
<RAMBank>
|
||||
<RAM1>
|
||||
<InUse>yes</InUse>
|
||||
<Start>0x42020000</Start>
|
||||
<Size>0xc000</Size>
|
||||
<Init>yes</Init>
|
||||
</RAM1>
|
||||
<RAM2>
|
||||
<InUse>no</InUse>
|
||||
<Start/>
|
||||
<Size/>
|
||||
<Init>yes</Init>
|
||||
</RAM2>
|
||||
<RAM3>
|
||||
<InUse>no</InUse>
|
||||
<Start/>
|
||||
<Size/>
|
||||
<Init>yes</Init>
|
||||
</RAM3>
|
||||
<RAM4>
|
||||
<InUse>no</InUse>
|
||||
<Start/>
|
||||
<Size/>
|
||||
<Init>yes</Init>
|
||||
</RAM4>
|
||||
<RAM5>
|
||||
<InUse>no</InUse>
|
||||
<Start/>
|
||||
<Size/>
|
||||
<Init>yes</Init>
|
||||
</RAM5>
|
||||
</RAMBank>
|
||||
<CPU>rv32imafc</CPU>
|
||||
<UseMiniLib>no</UseMiniLib>
|
||||
<Endian>little</Endian>
|
||||
<UseHardFloat>no</UseHardFloat>
|
||||
<UseEnhancedLRW>no</UseEnhancedLRW>
|
||||
<UseContinueBuild>no</UseContinueBuild>
|
||||
<UseSemiHost>no</UseSemiHost>
|
||||
</Target>
|
||||
<Output>
|
||||
<OutputName>$(ProjectName)</OutputName>
|
||||
<Type>Executable</Type>
|
||||
<CreateHexFile>no</CreateHexFile>
|
||||
<CreateBinFile>yes</CreateBinFile>
|
||||
<Preprocessor>no</Preprocessor>
|
||||
<Disassmeble>yes</Disassmeble>
|
||||
<CallGraph>no</CallGraph>
|
||||
<Map>yes</Map>
|
||||
</Output>
|
||||
<User>
|
||||
<BeforeCompile>
|
||||
<RunUserProg>no</RunUserProg>
|
||||
<UserProgName/>
|
||||
</BeforeCompile>
|
||||
<BeforeMake>
|
||||
<RunUserProg>no</RunUserProg>
|
||||
<UserProgName/>
|
||||
</BeforeMake>
|
||||
<AfterMake>
|
||||
<RunUserProg>no</RunUserProg>
|
||||
<UserProgName>$(ProjectPath)../../../../tools/bflb_flash_tool/bflb_mcu_tool.exe --chipname=bl702 --firmware="D:/BouffaloLabWS/cdk_ws/bl_mcu_sdk/examples/hellowd/Obj/helloworld.bin" </UserProgName>
|
||||
</AfterMake>
|
||||
</User>
|
||||
<Compiler>
|
||||
<Define>BL702;ARCH_RISCV;</Define>
|
||||
<Undefine/>
|
||||
<Optim>Optimize more (-O2)</Optim>
|
||||
<DebugLevel>Default (-g)</DebugLevel>
|
||||
<IncludePath>$(ProjectPath);$(ProjectPath)../;$(ProjectPath)../../../../components/fatfs;$(ProjectPath)../../../../components/freertos/Source/include;$(ProjectPath)../../../../components/shell;$(ProjectPath)../../../../components/usb_stack/class/audio;$(ProjectPath)../../../../components/usb_stack/class/cdc;$(ProjectPath)../../../../components/usb_stack/class/hid;$(ProjectPath)../../../../components/usb_stack/class/msc;$(ProjectPath)../../../../components/usb_stack/class/video;$(ProjectPath)../../../../components/usb_stack/class/webusb;$(ProjectPath)../../../../components/usb_stack/class/winusb;$(ProjectPath)../../../../components/usb_stack/common;$(ProjectPath)../../../../components/usb_stack/core;$(ProjectPath)../../../../bsp/board/bl706_iot;$(ProjectPath)../../../../bsp/bsp_common/platform;$(ProjectPath)../../../../bsp/bsp_common/image_sensor;$(ProjectPath)../../../../common/libc/inc;$(ProjectPath)../../../../common/libc/inc/arm_gcc;$(ProjectPath)../../../../common/libc/inc/bits;$(ProjectPath)../../../../common/libc/inc/sys;$(ProjectPath)../../../../common/libc/src;$(ProjectPath)../../../../common/device;$(ProjectPath)../../../../common/list;$(ProjectPath)../../../../common/memheap;$(ProjectPath)../../../../common/misc;$(ProjectPath)../../../../common/ring_buffer;$(ProjectPath)../../../../common/soft_crc;$(ProjectPath)../../../../components/shell;$(ProjectPath)../../../../drivers/bl702_driver/hal_drv/default_config;$(ProjectPath)../../../../drivers/bl702_driver/risc-v/Core/Include;$(ProjectPath)../../../../drivers/bl702_driver/hal_drv/inc;$(ProjectPath)../../../../drivers/bl702_driver/regs;$(ProjectPath)../../../../drivers/bl702_driver/startup;$(ProjectPath)../../../../drivers/bl702_driver/std_drv/inc</IncludePath>
|
||||
<OtherFlags>-fshort-enums -fno-common -fms-extensions -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -Wall -Wshift-negative-value -Wchar-subscripts -Wformat -Wuninitialized -Winit-self -fno-jump-tables -Wignored-qualifiers -Wswitch-default -Wunused -Wundef -msmall-data-limit=4</OtherFlags>
|
||||
<Verbose>no</Verbose>
|
||||
<Ansi>no</Ansi>
|
||||
<Syntax>no</Syntax>
|
||||
<Pedantic>no</Pedantic>
|
||||
<PedanticErr>no</PedanticErr>
|
||||
<InhibitWarn>no</InhibitWarn>
|
||||
<AllWarn>yes</AllWarn>
|
||||
<WarnErr>no</WarnErr>
|
||||
<OneElfS>yes</OneElfS>
|
||||
<Fstrict>no</Fstrict>
|
||||
</Compiler>
|
||||
<Asm>
|
||||
<Define/>
|
||||
<Undefine/>
|
||||
<IncludePath>$(ProjectPath);$(ProjectPath)../;$(ProjectPath)../../../../components/fatfs;$(ProjectPath)../../../../components/freertos/Source/include;$(ProjectPath)../../../../components/shell;$(ProjectPath)../../../../components/usb_stack/class/audio;$(ProjectPath)../../../../components/usb_stack/class/cdc;$(ProjectPath)../../../../components/usb_stack/class/hid;$(ProjectPath)../../../../components/usb_stack/class/msc;$(ProjectPath)../../../../components/usb_stack/class/video;$(ProjectPath)../../../../components/usb_stack/class/webusb;$(ProjectPath)../../../../components/usb_stack/class/winusb;$(ProjectPath)../../../../components/usb_stack/common;$(ProjectPath)../../../../components/usb_stack/core;$(ProjectPath)../../../../bsp/board/bl706_iot;$(ProjectPath)../../../../bsp/bsp_common/platform;$(ProjectPath)../../../../common/device;$(ProjectPath)../../../../common/list;$(ProjectPath)../../../../common/memheap;$(ProjectPath)../../../../common/misc;$(ProjectPath)../../../../common/ring_buffer;$(ProjectPath)../../../../common/soft_crc;$(ProjectPath)../../../../components/shell;$(ProjectPath)../../../../drivers/bl702_driver/hal_drv/default_config;$(ProjectPath)../../../../drivers/bl702_driver/hal_drv/inc;$(ProjectPath)../../../../drivers/bl702_driver/risc-v/Core/Include;$(ProjectPath)../../../../drivers/bl702_driver/regs;$(ProjectPath)../../../../drivers/bl702_driver/startup;$(ProjectPath)../../../../drivers/bl702_driver/std_drv/inc;$(ProjectPath)../../../../drivers/bl602_driver/risc-v/Core/Include;$(ProjectPath)../../../../drivers/bl602_driver/startup;$(ProjectPath)../../../../drivers/bl602_driver/hal_drv/inc;$(ProjectPath)../../../../drivers/bl602_driver/hal_drv/default_config;$(ProjectPath)../../../../drivers/bl602_driver/regs;$(ProjectPath)../../../../drivers/bl602_driver/std_drv/inc</IncludePath>
|
||||
<OtherFlags/>
|
||||
<DebugLevel>gdwarf2</DebugLevel>
|
||||
</Asm>
|
||||
<Linker>
|
||||
<Garbage>yes</Garbage>
|
||||
<Garbage2>yes</Garbage2>
|
||||
<LDFile>$(ProjectPath)/../bl706_camera.ld</LDFile>
|
||||
<LibName>c;gcc</LibName>
|
||||
<LibPath/>
|
||||
<OtherFlags/>
|
||||
<AutoLDFile>no</AutoLDFile>
|
||||
<LinkType/>
|
||||
</Linker>
|
||||
<Debug>
|
||||
<LoadApplicationAtStartup>yes</LoadApplicationAtStartup>
|
||||
<Connector>ICE</Connector>
|
||||
<StopAt>yes</StopAt>
|
||||
<StopAtText>main</StopAtText>
|
||||
<InitFile/>
|
||||
<AfterLoadFile>$(ProjectPath)/../../../../tools/openocd/bl70x_gdb.init</AfterLoadFile>
|
||||
<AutoRun>yes</AutoRun>
|
||||
<ResetType>Hard Reset</ResetType>
|
||||
<SoftResetVal>23000000</SoftResetVal>
|
||||
<ResetAfterLoad>no</ResetAfterLoad>
|
||||
<Dumpcore>no</Dumpcore>
|
||||
<DumpcoreText>$(ProjectPath)/$(ProjectName).cdkcore</DumpcoreText>
|
||||
<ConfigICE>
|
||||
<IP>localhost</IP>
|
||||
<PORT>1025</PORT>
|
||||
<CPUNumber>0</CPUNumber>
|
||||
<Clock>2000</Clock>
|
||||
<Delay>10</Delay>
|
||||
<WaitReset>50</WaitReset>
|
||||
<DDC>yes</DDC>
|
||||
<TRST>no</TRST>
|
||||
<DebugPrint>no</DebugPrint>
|
||||
<Connect>Normal</Connect>
|
||||
<ResetType>Hard Reset</ResetType>
|
||||
<SoftResetVal>21000000</SoftResetVal>
|
||||
<RTOSType>Bare Metal</RTOSType>
|
||||
<DownloadToFlash>yes</DownloadToFlash>
|
||||
<ResetAfterConnect>yes</ResetAfterConnect>
|
||||
<GDBName/>
|
||||
<GDBServerType>Local</GDBServerType>
|
||||
<OtherFlags>-arch riscv</OtherFlags>
|
||||
</ConfigICE>
|
||||
<ConfigSIM>
|
||||
<SIMTarget/>
|
||||
<OtherFlags/>
|
||||
<NoGraphic>yes</NoGraphic>
|
||||
<Log>no</Log>
|
||||
<SimTrace>no</SimTrace>
|
||||
</ConfigSIM>
|
||||
<ConfigOpenOCD>
|
||||
<OpenOCDExecutablePath>openocd-bl702</OpenOCDExecutablePath>
|
||||
<OpenOCDTelnetPortEnable>no</OpenOCDTelnetPortEnable>
|
||||
<OpenOCDTelnetPort>4444</OpenOCDTelnetPort>
|
||||
<OpenOCDTclPortEnable>no</OpenOCDTclPortEnable>
|
||||
<OpenOCDTclPort>6666</OpenOCDTclPort>
|
||||
<OpenOCDConfigOptions>-f openocd_bl702_evb.cfg</OpenOCDConfigOptions>
|
||||
</ConfigOpenOCD>
|
||||
</Debug>
|
||||
<Flash>
|
||||
<InitFile/>
|
||||
<Erase>Erase Sectors</Erase>
|
||||
<Algorithms Path="">bl702_flasher.elf</Algorithms>
|
||||
<Program>yes</Program>
|
||||
<Verify>yes</Verify>
|
||||
<ResetAndRun>no</ResetAndRun>
|
||||
<ResetType>Hard Reset</ResetType>
|
||||
<SoftResetVal/>
|
||||
<External>no</External>
|
||||
<Command/>
|
||||
<Arguments/>
|
||||
</Flash>
|
||||
</BuildConfig>
|
||||
</BuildConfigs>
|
||||
</Project>
|
90
examples/camera/camera_interleave/main.c
Normal file
90
examples/camera/camera_interleave/main.c
Normal file
@ -0,0 +1,90 @@
|
||||
/**
|
||||
* @file main.c
|
||||
* @brief
|
||||
*
|
||||
* Copyright (c) 2021 Bouffalolab team
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "bflb_platform.h"
|
||||
#include "bsp_image_sensor.h"
|
||||
#include "bl702_uart.h"
|
||||
|
||||
|
||||
#define CAMERA_RESOLUTION_X (120)
|
||||
#define CAMERA_RESOLUTION_Y (100)
|
||||
#define CAMERA_FRAME_SIZE (CAMERA_RESOLUTION_X * CAMERA_RESOLUTION_Y * 2)
|
||||
#define CAMERA_WRITE_ADDR (0x4201E000)
|
||||
#define CAMERA_BUFFER_SIZE (0x12000)
|
||||
|
||||
#define YUV422_FRAME_SIZE (CAMERA_RESOLUTION_X * CAMERA_RESOLUTION_Y * 2)
|
||||
#define YUV420_FRAME_SIZE (CAMERA_RESOLUTION_X * CAMERA_RESOLUTION_Y * 2 * 3 / 4)
|
||||
#define YUV400_FRAME_SIZE (CAMERA_RESOLUTION_X * CAMERA_RESOLUTION_Y)
|
||||
#define YUV_USE (1)
|
||||
|
||||
static cam_device_t camera_cfg =
|
||||
{
|
||||
.software_mode = CAM_MANUAL_MODE,
|
||||
.frame_mode = CAM_FRAME_INTERLEAVE_MODE,
|
||||
.yuv_format = CAM_YUV_FORMAT_YUV422,
|
||||
.cam_write_ram_addr = CAMERA_WRITE_ADDR,
|
||||
.cam_write_ram_size = CAMERA_BUFFER_SIZE,
|
||||
.cam_frame_size = CAMERA_FRAME_SIZE,
|
||||
|
||||
.cam_write_ram_addr1 = 0,
|
||||
.cam_write_ram_size1 = 0,
|
||||
.cam_frame_size1 = 0,
|
||||
};
|
||||
|
||||
static mjpeg_device_t mjpeg_cfg;
|
||||
|
||||
int main(void)
|
||||
{
|
||||
uint32_t i;
|
||||
uint8_t* picture;
|
||||
uint32_t length;
|
||||
|
||||
bflb_platform_init(0);
|
||||
|
||||
MSG("camera case in interleave mode in ocram \n");
|
||||
|
||||
cam_clk_out();
|
||||
|
||||
cam_hsync_crop(0, 2 * CAMERA_RESOLUTION_X);
|
||||
cam_vsync_crop(0, CAMERA_RESOLUTION_Y);
|
||||
|
||||
if(SUCCESS != image_sensor_init(DISABLE,&camera_cfg,&mjpeg_cfg)){
|
||||
MSG("Init error!\n");
|
||||
BL_CASE_FAIL;
|
||||
}
|
||||
cam_start();
|
||||
|
||||
for(i=0;i<3;i++){
|
||||
while(SUCCESS != cam_get_one_frame_interleave(&picture,&length)){
|
||||
}
|
||||
MSG("picturestartuyvy");
|
||||
UART_SendData(0,picture,length);
|
||||
MSG("pictureend");
|
||||
|
||||
cam_drop_one_frame_interleave();
|
||||
}
|
||||
|
||||
cam_stop();
|
||||
|
||||
BL_CASE_SUCCESS;
|
||||
}
|
6
examples/camera/camera_interleave_psram/CMakeLists.txt
Normal file
6
examples/camera/camera_interleave_psram/CMakeLists.txt
Normal file
@ -0,0 +1,6 @@
|
||||
set(BSP_COMMON_DIR ${CMAKE_SOURCE_DIR}/bsp/bsp_common)
|
||||
set(LINKER_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/bl706_camera_psram.ld)
|
||||
set(TARGET_REQUIRED_PRIVATE_INCLUDE ${BSP_COMMON_DIR}/psram ${BSP_COMMON_DIR}/image_sensor)
|
||||
set(TARGET_REQUIRED_SRCS ${BSP_COMMON_DIR}/psram/bsp_sf_psram.c ${BSP_COMMON_DIR}/image_sensor/bsp_image_sensor.c)
|
||||
set(mains main.c)
|
||||
generate_bin()
|
227
examples/camera/camera_interleave_psram/bl706_camera_psram.ld
Normal file
227
examples/camera/camera_interleave_psram/bl706_camera_psram.ld
Normal file
@ -0,0 +1,227 @@
|
||||
/****************************************************************************************
|
||||
* @file map.txt
|
||||
*
|
||||
* @brief This file is the map file (gnuarm or armgcc).
|
||||
*
|
||||
* Copyright (C) BouffaloLab 2018
|
||||
*
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/* configure the CPU type */
|
||||
OUTPUT_ARCH( "riscv" )
|
||||
/* link with the standard c library */
|
||||
INPUT(-lc)
|
||||
/* link with the standard GCC library */
|
||||
INPUT(-lgcc)
|
||||
/* configure the entry point */
|
||||
ENTRY(_enter)
|
||||
|
||||
StackSize = 0x1000; /* 4KB */
|
||||
HeapSize = 0x1000; /* 4KB */
|
||||
|
||||
MEMORY
|
||||
{
|
||||
xip_memory (rx) : ORIGIN = 0x23000000, LENGTH = 1024K
|
||||
itcm_memory (rx) : ORIGIN = 0x22014000, LENGTH = 10K
|
||||
dtcm_memory (rx) : ORIGIN = 0x42016800, LENGTH = 10K
|
||||
ram_memory (!rx) : ORIGIN = 0x42019000, LENGTH = 20K
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
PROVIDE(__metal_chicken_bit = 0);
|
||||
|
||||
.text :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__text_code_start__ = .;
|
||||
|
||||
KEEP (*(.text.metal.init.enter))
|
||||
KEEP (*(SORT_NONE(.init)))
|
||||
/* section information for finsh shell */
|
||||
. = ALIGN(4);
|
||||
_shell_command_start = .;
|
||||
KEEP(*(shellCommand))
|
||||
_shell_command_end = .;
|
||||
|
||||
/* section information for usb desc */
|
||||
. = ALIGN(4);
|
||||
_usb_desc_start = .;
|
||||
KEEP(*(usb_desc))
|
||||
. = ALIGN(4);
|
||||
_usb_desc_end = .;
|
||||
|
||||
*(.text)
|
||||
*(.text.*)
|
||||
|
||||
/*put .rodata**/
|
||||
*(EXCLUDE_FILE( *bl702_glb.o \
|
||||
*bl702_pds.o \
|
||||
*bl702_common.o \
|
||||
*bl702_sf_cfg.o \
|
||||
*bl702_sf_ctrl.o \
|
||||
*bl702_sflash.o \
|
||||
*bl702_xip_sflash.o \
|
||||
*bl702_ef_ctrl.o) .rodata*)
|
||||
*(.rodata)
|
||||
*(.rodata.*)
|
||||
|
||||
*(.srodata)
|
||||
*(.srodata.*)
|
||||
|
||||
. = ALIGN(4);
|
||||
__text_code_end__ = .;
|
||||
} > xip_memory
|
||||
|
||||
. = ALIGN(4);
|
||||
__itcm_load_addr = .;
|
||||
|
||||
.itcm_region : AT (__itcm_load_addr)
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__tcm_code_start__ = .;
|
||||
|
||||
*(.tcm_code)
|
||||
*(.tcm_const)
|
||||
*(.sclock_rlt_code)
|
||||
*(.sclock_rlt_const)
|
||||
|
||||
*bl702_glb.o*(.rodata*)
|
||||
*bl702_pds.o*(.rodata*)
|
||||
*bl702_common.o*(.rodata*)
|
||||
*bl702_sf_cfg.o*(.rodata*)
|
||||
*bl702_sf_ctrl.o*(.rodata*)
|
||||
*bl702_sflash.o*(.rodata*)
|
||||
*bl702_xip_sflash.o*(.rodata*)
|
||||
*bl702_ef_ctrl.o*(.rodata*)
|
||||
|
||||
. = ALIGN(4);
|
||||
__tcm_code_end__ = .;
|
||||
} > itcm_memory
|
||||
|
||||
__dtcm_load_addr = __itcm_load_addr + SIZEOF(.itcm_region);
|
||||
|
||||
.dtcm_region : AT (__dtcm_load_addr)
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__tcm_data_start__ = .;
|
||||
|
||||
*(.tcm_data)
|
||||
/* *finger_print.o(.data*) */
|
||||
|
||||
. = ALIGN(4);
|
||||
__tcm_data_end__ = .;
|
||||
} > dtcm_memory
|
||||
|
||||
/* .heap_dummy section doesn't contains any symbols. It is only
|
||||
* used for linker to calculate size of heap sections, and assign
|
||||
* values to heap symbols later */
|
||||
.heap_dummy (NOLOAD):
|
||||
{
|
||||
. = ALIGN(0x4);
|
||||
. = . + HeapSize;
|
||||
. = ALIGN(0x4);
|
||||
} > dtcm_memory
|
||||
|
||||
_HeapBase = ORIGIN(dtcm_memory) + LENGTH(dtcm_memory) - StackSize - HeapSize;
|
||||
_HeapSize = HeapSize;
|
||||
|
||||
/* Check if data + heap + stack exceeds RAM limit */
|
||||
ASSERT(_HeapBase >= __tcm_data_end__, "region RAM overflowed with stack")
|
||||
|
||||
/*************************************************************************/
|
||||
/* .stack_dummy section doesn't contains any symbols. It is only
|
||||
* used for linker to calculate size of stack sections, and assign
|
||||
* values to stack symbols later */
|
||||
.stack_dummy (NOLOAD):
|
||||
{
|
||||
. = ALIGN(0x4);
|
||||
. = . + StackSize;
|
||||
. = ALIGN(0x4);
|
||||
} > dtcm_memory
|
||||
|
||||
/* Set stack top to end of RAM, and stack limit move down by
|
||||
* size of stack_dummy section */
|
||||
__StackTop = ORIGIN(dtcm_memory) + LENGTH(dtcm_memory);
|
||||
PROVIDE( __freertos_irq_stack_top = __StackTop);
|
||||
__StackLimit = __StackTop - SIZEOF(.stack_dummy);
|
||||
|
||||
/* Check if data + heap + stack exceeds RAM limit */
|
||||
ASSERT(__StackLimit >= __tcm_data_end__, "region RAM overflowed with stack")
|
||||
/*************************************************************************/
|
||||
|
||||
__system_ram_load_addr = __dtcm_load_addr + SIZEOF(.dtcm_region);
|
||||
|
||||
.system_ram_data_region : AT (__system_ram_load_addr)
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__system_ram_data_start__ = .;
|
||||
|
||||
*(.system_ram)
|
||||
|
||||
. = ALIGN(4);
|
||||
__system_ram_data_end__ = .;
|
||||
} > ram_memory
|
||||
|
||||
__ram_load_addr = __system_ram_load_addr + SIZEOF(.system_ram_data_region);
|
||||
|
||||
/* Data section */
|
||||
RAM_DATA : AT (__ram_load_addr)
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__ram_data_start__ = .;
|
||||
|
||||
PROVIDE( __global_pointer$ = . + 0x800 );
|
||||
|
||||
*(.data)
|
||||
*(.data.*)
|
||||
*(.sdata)
|
||||
*(.sdata.*)
|
||||
*(.sdata2)
|
||||
*(.sdata2.*)
|
||||
|
||||
. = ALIGN(4);
|
||||
__ram_data_end__ = .;
|
||||
} > ram_memory
|
||||
|
||||
.bss (NOLOAD) :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__bss_start__ = .;
|
||||
|
||||
*(.bss*)
|
||||
*(.sbss*)
|
||||
*(COMMON)
|
||||
|
||||
. = ALIGN(4);
|
||||
__bss_end__ = .;
|
||||
} > ram_memory
|
||||
|
||||
.noinit_data (NOLOAD) :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__noinit_data_start__ = .;
|
||||
|
||||
*(.noinit_data*)
|
||||
|
||||
. = ALIGN(4);
|
||||
__noinit_data_end__ = .;
|
||||
} > ram_memory
|
||||
|
||||
.heap (NOLOAD):
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__HeapBase = .;
|
||||
|
||||
/*__end__ = .;*/
|
||||
/*end = __end__;*/
|
||||
KEEP(*(.heap*))
|
||||
|
||||
. = ALIGN(4);
|
||||
__HeapLimit = .;
|
||||
} > ram_memory
|
||||
__HeapLimit = ORIGIN(ram_memory) + LENGTH(ram_memory);
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,735 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Project Name="camera_interleave_psram" Version="1" Language="C">
|
||||
<Description>CPU: RV32IMAFC
|
||||
Chip: bl70x
|
||||
Board: bl70x_iot
|
||||
</Description>
|
||||
<Dependencies Name="Debug"/>
|
||||
<VirtualDirectory Name="app">
|
||||
<File Name="../main.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
</VirtualDirectory>
|
||||
<VirtualDirectory Name="chip">
|
||||
<VirtualDirectory Name="riscv">
|
||||
<File Name="../../../../drivers/bl702_driver/startup/interrupt.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/startup/system_bl702.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
</VirtualDirectory>
|
||||
<VirtualDirectory Name="startup">
|
||||
<File Name="../../../../drivers/bl702_driver/startup/GCC/entry.S">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/startup/GCC/start_load.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
</VirtualDirectory>
|
||||
</VirtualDirectory>
|
||||
<VirtualDirectory Name="hal">
|
||||
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_adc.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_dac.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_dma.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_gpio.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_i2c.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_i2s.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_mtimer.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_pwm.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_spi.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_timer.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_uart.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_usb.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_clock.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_cam.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_mjpeg.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
</VirtualDirectory>
|
||||
<VirtualDirectory Name="std">
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_acomp.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_adc.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_aon.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_cam.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_clock.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_dac.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_dma.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_ef_ctrl.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_emac.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_glb.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_hbn.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_i2c.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_i2c_gpio_sim.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_i2s.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_ir.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_common.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_kys.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_l1c.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_mjpeg.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_pds.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_psram.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_pwm.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_qdec.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_romapi.c" ExcludeProjConfig="BuildSet">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_romdriver.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_sec_dbg.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_sec_eng.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_sf_cfg.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_sf_cfg_ext.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_sf_ctrl.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_sflash.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_sflash_ext.c" ExcludeProjConfig="">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_spi.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_timer.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_uart.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_usb.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_xip_sflash.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_xip_sflash_ext.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
</VirtualDirectory>
|
||||
<VirtualDirectory Name="board">
|
||||
<File Name="../../../../bsp/board/bl706_iot/board.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../bsp/bsp_common/platform/bflb_platform.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../bsp/bsp_common/image_sensor/bsp_image_sensor.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../bsp/bsp_common/psram/bsp_sf_psram.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
</VirtualDirectory>
|
||||
<VirtualDirectory Name="common">
|
||||
<File Name="../../../../common/device/drv_device.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/memheap/drv_mmheap.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/ring_buffer/ring_buffer.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/soft_crc/softcrc.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<VirtualDirectory Name="libc" ExcludeProjConfig="">
|
||||
<File Name="../../../../common/libc/src/atof.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/atoi.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/atol.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/atoll.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/atox.c" ExcludeProjConfig="BuildSet">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/bsearch.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/common.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/ctype_isalnum.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/ctype_isalpha.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/ctype_isascii.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/ctype_isblank.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/ctype_iscntrl.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/ctype_isdigit.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/ctype_isgraph.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/ctype_islower.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/ctype_isprint.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/ctype_ispunct.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/ctype_isspace.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/ctype_isupper.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/ctype_isxdigit.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/ctype_tolower.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/ctype_toupper.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/ctypes.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/fnmatch.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/jrand48.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/lrand48.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/memccpy.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/memchr.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/memcmp.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/memcpy.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/memmem.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/memrchr.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/memset.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/memswap.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/mrand48.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/nrand48.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/qsort.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/seed48.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/snprintf.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/sprintf.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/srand48.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/sscanf.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/stdlib.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strcasecmp.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strcat.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strchr.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strcmp.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strcpy.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strcspn.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strlcat.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strlcpy.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strlen.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strncasecmp.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strncat.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strncmp.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strncpy.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strnlen.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strntoimax.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strntoumax.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strpbrk.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strrchr.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strsep.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strspn.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strstr.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strtoimax.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strtok.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strtok_r.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strtol.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strtoll.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strtoul.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strtoull.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strtoumax.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strtox.c" ExcludeProjConfig="BuildSet">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strxspn.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/vsnprintf.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/vsprintf.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/vsscanf.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
</VirtualDirectory>
|
||||
<File Name="../../../../common/misc/misc.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
</VirtualDirectory>
|
||||
<VirtualDirectory Name="script">
|
||||
<File Name="../../../../tools/openocd/bl70x_gdb.init">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/regs/bl70x_reg.svc">
|
||||
<FileOption/>
|
||||
</File>
|
||||
</VirtualDirectory>
|
||||
<MonitorProgress>
|
||||
<DebugLaunch>154</DebugLaunch>
|
||||
<FlashOperate>104</FlashOperate>
|
||||
</MonitorProgress>
|
||||
<VirtualDirectory Name="components">
|
||||
<VirtualDirectory Name="fatfs">
|
||||
<File Name="../../../../components/fatfs/diskio.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../components/fatfs/ff.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../components/fatfs/ffsystem.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../components/fatfs/ffunicode.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
</VirtualDirectory>
|
||||
<VirtualDirectory Name="shell">
|
||||
<File Name="../../../../components/shell/drv_shell.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
</VirtualDirectory>
|
||||
<VirtualDirectory Name="usb_stack">
|
||||
<VirtualDirectory Name="class">
|
||||
<VirtualDirectory Name="cdc">
|
||||
<File Name="../../../../components/usb_stack/class/cdc/usbd_cdc.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
</VirtualDirectory>
|
||||
<VirtualDirectory Name="hid">
|
||||
<File Name="../../../../components/usb_stack/class/hid/usbd_hid.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
</VirtualDirectory>
|
||||
<VirtualDirectory Name="msc">
|
||||
<File Name="../../../../components/usb_stack/class/msc/usbd_msc.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
</VirtualDirectory>
|
||||
</VirtualDirectory>
|
||||
<VirtualDirectory Name="core">
|
||||
<File Name="../../../../components/usb_stack/core/usbd_core.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
</VirtualDirectory>
|
||||
</VirtualDirectory>
|
||||
</VirtualDirectory>
|
||||
<Dependencies Name="BuildSet"/>
|
||||
<DebugSessions>
|
||||
<watchExpressions/>
|
||||
<memoryExpressions>;;;</memoryExpressions>
|
||||
<statistics>;;MHZ;</statistics>
|
||||
<peripheralTabs>
|
||||
<Tab disFormat="Hex">glb</Tab>
|
||||
<Tab disFormat="Hex">uart</Tab>
|
||||
</peripheralTabs>
|
||||
<WatchDisplayFormat>1</WatchDisplayFormat>
|
||||
<LocalDisplayFormat>1</LocalDisplayFormat>
|
||||
<debugLayout/>
|
||||
<memoryTabColSizeExpressions>100:8;100:8;100:8;100:8;</memoryTabColSizeExpressions>
|
||||
</DebugSessions>
|
||||
<DebugSessions>
|
||||
<watchExpressions/>
|
||||
<memoryExpressions>;;;</memoryExpressions>
|
||||
<statistics>;;MHZ;</statistics>
|
||||
<peripheralTabs>
|
||||
<Tab disFormat="Hex">glb</Tab>
|
||||
<Tab disFormat="Hex">uart</Tab>
|
||||
</peripheralTabs>
|
||||
<WatchDisplayFormat>1</WatchDisplayFormat>
|
||||
<LocalDisplayFormat>1</LocalDisplayFormat>
|
||||
<debugLayout/>
|
||||
<memoryTabColSizeExpressions>100:8;100:8;100:8;100:8;</memoryTabColSizeExpressions>
|
||||
</DebugSessions>
|
||||
<BuildConfigs>
|
||||
<BuildConfig Name="BuildSet">
|
||||
<Target>
|
||||
<ROMBank Selected="1">
|
||||
<ROM1>
|
||||
<InUse>no</InUse>
|
||||
<Start>0x23000000</Start>
|
||||
<Size>0x100000</Size>
|
||||
</ROM1>
|
||||
<ROM2>
|
||||
<InUse>no</InUse>
|
||||
<Start>0x22014000</Start>
|
||||
<Size>0x4000</Size>
|
||||
</ROM2>
|
||||
<ROM3>
|
||||
<InUse>no</InUse>
|
||||
<Start>0x42018000</Start>
|
||||
<Size>0x8000</Size>
|
||||
</ROM3>
|
||||
<ROM4>
|
||||
<InUse>no</InUse>
|
||||
<Start/>
|
||||
<Size/>
|
||||
</ROM4>
|
||||
<ROM5>
|
||||
<InUse>no</InUse>
|
||||
<Start/>
|
||||
<Size/>
|
||||
</ROM5>
|
||||
</ROMBank>
|
||||
<RAMBank>
|
||||
<RAM1>
|
||||
<InUse>yes</InUse>
|
||||
<Start>0x42020000</Start>
|
||||
<Size>0xc000</Size>
|
||||
<Init>yes</Init>
|
||||
</RAM1>
|
||||
<RAM2>
|
||||
<InUse>no</InUse>
|
||||
<Start/>
|
||||
<Size/>
|
||||
<Init>yes</Init>
|
||||
</RAM2>
|
||||
<RAM3>
|
||||
<InUse>no</InUse>
|
||||
<Start/>
|
||||
<Size/>
|
||||
<Init>yes</Init>
|
||||
</RAM3>
|
||||
<RAM4>
|
||||
<InUse>no</InUse>
|
||||
<Start/>
|
||||
<Size/>
|
||||
<Init>yes</Init>
|
||||
</RAM4>
|
||||
<RAM5>
|
||||
<InUse>no</InUse>
|
||||
<Start/>
|
||||
<Size/>
|
||||
<Init>yes</Init>
|
||||
</RAM5>
|
||||
</RAMBank>
|
||||
<CPU>rv32imafc</CPU>
|
||||
<UseMiniLib>no</UseMiniLib>
|
||||
<Endian>little</Endian>
|
||||
<UseHardFloat>no</UseHardFloat>
|
||||
<UseEnhancedLRW>no</UseEnhancedLRW>
|
||||
<UseContinueBuild>no</UseContinueBuild>
|
||||
<UseSemiHost>no</UseSemiHost>
|
||||
</Target>
|
||||
<Output>
|
||||
<OutputName>$(ProjectName)</OutputName>
|
||||
<Type>Executable</Type>
|
||||
<CreateHexFile>no</CreateHexFile>
|
||||
<CreateBinFile>yes</CreateBinFile>
|
||||
<Preprocessor>no</Preprocessor>
|
||||
<Disassmeble>yes</Disassmeble>
|
||||
<CallGraph>no</CallGraph>
|
||||
<Map>yes</Map>
|
||||
</Output>
|
||||
<User>
|
||||
<BeforeCompile>
|
||||
<RunUserProg>no</RunUserProg>
|
||||
<UserProgName/>
|
||||
</BeforeCompile>
|
||||
<BeforeMake>
|
||||
<RunUserProg>no</RunUserProg>
|
||||
<UserProgName/>
|
||||
</BeforeMake>
|
||||
<AfterMake>
|
||||
<RunUserProg>no</RunUserProg>
|
||||
<UserProgName>$(ProjectPath)../../../../tools/bflb_flash_tool/bflb_mcu_tool.exe --chipname=bl702 --firmware="D:/BouffaloLabWS/cdk_ws/bl_mcu_sdk/examples/hellowd/Obj/helloworld.bin" </UserProgName>
|
||||
</AfterMake>
|
||||
</User>
|
||||
<Compiler>
|
||||
<Define>BL702;ARCH_RISCV;</Define>
|
||||
<Undefine/>
|
||||
<Optim>Optimize size (-Os)</Optim>
|
||||
<DebugLevel>Default (-g)</DebugLevel>
|
||||
<IncludePath>$(ProjectPath);$(ProjectPath)../;$(ProjectPath)../../../../components/fatfs;$(ProjectPath)../../../../components/freertos/Source/include;$(ProjectPath)../../../../components/shell;$(ProjectPath)../../../../components/usb_stack/class/audio;$(ProjectPath)../../../../components/usb_stack/class/cdc;$(ProjectPath)../../../../components/usb_stack/class/hid;$(ProjectPath)../../../../components/usb_stack/class/msc;$(ProjectPath)../../../../components/usb_stack/class/video;$(ProjectPath)../../../../components/usb_stack/class/webusb;$(ProjectPath)../../../../components/usb_stack/class/winusb;$(ProjectPath)../../../../components/usb_stack/common;$(ProjectPath)../../../../components/usb_stack/core;$(ProjectPath)../../../../bsp/board/bl706_iot;$(ProjectPath)../../../../bsp/bsp_common/platform;$(ProjectPath)../../../../bsp/bsp_common/image_sensor;$(ProjectPath)../../../../bsp/bsp_common/psram;$(ProjectPath)../../../../common/libc/inc;$(ProjectPath)../../../../common/libc/inc/arm_gcc;$(ProjectPath)../../../../common/libc/inc/bits;$(ProjectPath)../../../../common/libc/inc/sys;$(ProjectPath)../../../../common/libc/src;$(ProjectPath)../../../../common/device;$(ProjectPath)../../../../common/list;$(ProjectPath)../../../../common/memheap;$(ProjectPath)../../../../common/misc;$(ProjectPath)../../../../common/ring_buffer;$(ProjectPath)../../../../common/soft_crc;$(ProjectPath)../../../../components/shell;$(ProjectPath)../../../../drivers/bl702_driver/hal_drv/default_config;$(ProjectPath)../../../../drivers/bl702_driver/risc-v/Core/Include;$(ProjectPath)../../../../drivers/bl702_driver/hal_drv/inc;$(ProjectPath)../../../../drivers/bl702_driver/regs;$(ProjectPath)../../../../drivers/bl702_driver/startup;$(ProjectPath)../../../../drivers/bl702_driver/std_drv/inc</IncludePath>
|
||||
<OtherFlags>-fshort-enums -fno-common -fms-extensions -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -Wall -Wshift-negative-value -Wchar-subscripts -Wformat -Wuninitialized -Winit-self -fno-jump-tables -Wignored-qualifiers -Wswitch-default -Wunused -Wundef -msmall-data-limit=4</OtherFlags>
|
||||
<Verbose>no</Verbose>
|
||||
<Ansi>no</Ansi>
|
||||
<Syntax>no</Syntax>
|
||||
<Pedantic>no</Pedantic>
|
||||
<PedanticErr>no</PedanticErr>
|
||||
<InhibitWarn>no</InhibitWarn>
|
||||
<AllWarn>yes</AllWarn>
|
||||
<WarnErr>no</WarnErr>
|
||||
<OneElfS>yes</OneElfS>
|
||||
<Fstrict>no</Fstrict>
|
||||
</Compiler>
|
||||
<Asm>
|
||||
<Define/>
|
||||
<Undefine/>
|
||||
<IncludePath>$(ProjectPath);$(ProjectPath)../;$(ProjectPath)../../../../components/fatfs;$(ProjectPath)../../../../components/freertos/Source/include;$(ProjectPath)../../../../components/shell;$(ProjectPath)../../../../components/usb_stack/class/audio;$(ProjectPath)../../../../components/usb_stack/class/cdc;$(ProjectPath)../../../../components/usb_stack/class/hid;$(ProjectPath)../../../../components/usb_stack/class/msc;$(ProjectPath)../../../../components/usb_stack/class/video;$(ProjectPath)../../../../components/usb_stack/class/webusb;$(ProjectPath)../../../../components/usb_stack/class/winusb;$(ProjectPath)../../../../components/usb_stack/common;$(ProjectPath)../../../../components/usb_stack/core;$(ProjectPath)../../../../bsp/board/bl706_iot;$(ProjectPath)../../../../bsp/bsp_common/platform;$(ProjectPath)../../../../common/device;$(ProjectPath)../../../../common/list;$(ProjectPath)../../../../common/memheap;$(ProjectPath)../../../../common/misc;$(ProjectPath)../../../../common/ring_buffer;$(ProjectPath)../../../../common/soft_crc;$(ProjectPath)../../../../components/shell;$(ProjectPath)../../../../drivers/bl702_driver/hal_drv/default_config;$(ProjectPath)../../../../drivers/bl702_driver/hal_drv/inc;$(ProjectPath)../../../../drivers/bl702_driver/risc-v/Core/Include;$(ProjectPath)../../../../drivers/bl702_driver/regs;$(ProjectPath)../../../../drivers/bl702_driver/startup;$(ProjectPath)../../../../drivers/bl702_driver/std_drv/inc;$(ProjectPath)../../../../drivers/bl602_driver/risc-v/Core/Include;$(ProjectPath)../../../../drivers/bl602_driver/startup;$(ProjectPath)../../../../drivers/bl602_driver/hal_drv/inc;$(ProjectPath)../../../../drivers/bl602_driver/hal_drv/default_config;$(ProjectPath)../../../../drivers/bl602_driver/regs;$(ProjectPath)../../../../drivers/bl602_driver/std_drv/inc</IncludePath>
|
||||
<OtherFlags/>
|
||||
<DebugLevel>gdwarf2</DebugLevel>
|
||||
</Asm>
|
||||
<Linker>
|
||||
<Garbage>yes</Garbage>
|
||||
<Garbage2>yes</Garbage2>
|
||||
<LDFile>$(ProjectPath)/../bl706_camera_psram.ld</LDFile>
|
||||
<LibName/>
|
||||
<LibPath/>
|
||||
<OtherFlags>--specs=nano.specs</OtherFlags>
|
||||
<AutoLDFile>no</AutoLDFile>
|
||||
<LinkType/>
|
||||
</Linker>
|
||||
<Debug>
|
||||
<LoadApplicationAtStartup>yes</LoadApplicationAtStartup>
|
||||
<Connector>ICE</Connector>
|
||||
<StopAt>yes</StopAt>
|
||||
<StopAtText>main</StopAtText>
|
||||
<InitFile/>
|
||||
<AfterLoadFile>$(ProjectPath)/../../../../tools/openocd/bl70x_gdb.init</AfterLoadFile>
|
||||
<AutoRun>yes</AutoRun>
|
||||
<ResetType>Hard Reset</ResetType>
|
||||
<SoftResetVal>23000000</SoftResetVal>
|
||||
<ResetAfterLoad>no</ResetAfterLoad>
|
||||
<Dumpcore>no</Dumpcore>
|
||||
<DumpcoreText>$(ProjectPath)/$(ProjectName).cdkcore</DumpcoreText>
|
||||
<ConfigICE>
|
||||
<IP>localhost</IP>
|
||||
<PORT>1025</PORT>
|
||||
<CPUNumber>0</CPUNumber>
|
||||
<Clock>2000</Clock>
|
||||
<Delay>10</Delay>
|
||||
<WaitReset>50</WaitReset>
|
||||
<DDC>yes</DDC>
|
||||
<TRST>no</TRST>
|
||||
<DebugPrint>no</DebugPrint>
|
||||
<Connect>Normal</Connect>
|
||||
<ResetType>Hard Reset</ResetType>
|
||||
<SoftResetVal>21000000</SoftResetVal>
|
||||
<RTOSType>Bare Metal</RTOSType>
|
||||
<DownloadToFlash>yes</DownloadToFlash>
|
||||
<ResetAfterConnect>yes</ResetAfterConnect>
|
||||
<GDBName/>
|
||||
<GDBServerType>Local</GDBServerType>
|
||||
<OtherFlags>-arch riscv</OtherFlags>
|
||||
</ConfigICE>
|
||||
<ConfigSIM>
|
||||
<SIMTarget/>
|
||||
<OtherFlags/>
|
||||
<NoGraphic>yes</NoGraphic>
|
||||
<Log>no</Log>
|
||||
<SimTrace>no</SimTrace>
|
||||
</ConfigSIM>
|
||||
<ConfigOpenOCD>
|
||||
<OpenOCDExecutablePath>openocd-bl702</OpenOCDExecutablePath>
|
||||
<OpenOCDTelnetPortEnable>no</OpenOCDTelnetPortEnable>
|
||||
<OpenOCDTelnetPort>4444</OpenOCDTelnetPort>
|
||||
<OpenOCDTclPortEnable>no</OpenOCDTclPortEnable>
|
||||
<OpenOCDTclPort>6666</OpenOCDTclPort>
|
||||
<OpenOCDConfigOptions>-f openocd_bl702_evb.cfg</OpenOCDConfigOptions>
|
||||
</ConfigOpenOCD>
|
||||
</Debug>
|
||||
<Flash>
|
||||
<InitFile/>
|
||||
<Erase>Erase Sectors</Erase>
|
||||
<Algorithms Path="">bl702_flasher.elf</Algorithms>
|
||||
<Program>yes</Program>
|
||||
<Verify>yes</Verify>
|
||||
<ResetAndRun>no</ResetAndRun>
|
||||
<ResetType>Hard Reset</ResetType>
|
||||
<SoftResetVal/>
|
||||
<External>no</External>
|
||||
<Command/>
|
||||
<Arguments/>
|
||||
</Flash>
|
||||
</BuildConfig>
|
||||
</BuildConfigs>
|
||||
</Project>
|
97
examples/camera/camera_interleave_psram/main.c
Normal file
97
examples/camera/camera_interleave_psram/main.c
Normal file
@ -0,0 +1,97 @@
|
||||
/**
|
||||
* @file main.c
|
||||
* @brief
|
||||
*
|
||||
* Copyright (c) 2021 Bouffalolab team
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "bflb_platform.h"
|
||||
#include "bsp_sf_psram.h"
|
||||
#include "bsp_image_sensor.h"
|
||||
#include "bl702_uart.h"
|
||||
|
||||
|
||||
#define CAMERA_RESOLUTION_X (640)
|
||||
#define CAMERA_RESOLUTION_Y (480)
|
||||
#define CAMERA_FRAME_SIZE (CAMERA_RESOLUTION_X * CAMERA_RESOLUTION_Y * 2)
|
||||
#define CAMERA_WRITE_ADDR (0x26000000)
|
||||
#define CAMERA_BUFFER_SIZE (0x500000)
|
||||
|
||||
#define YUV422_FRAME_SIZE (CAMERA_RESOLUTION_X * CAMERA_RESOLUTION_Y * 2)
|
||||
#define YUV420_FRAME_SIZE (640 * 480 * 2 * 3 / 4)
|
||||
#define YUV400_FRAME_SIZE (640 * 480)
|
||||
#define YUV_USE (1)
|
||||
|
||||
static cam_device_t camera_cfg =
|
||||
{
|
||||
.software_mode = CAM_MANUAL_MODE,
|
||||
.frame_mode = CAM_FRAME_INTERLEAVE_MODE,
|
||||
.yuv_format = CAM_YUV_FORMAT_YUV422,
|
||||
.cam_write_ram_addr = CAMERA_WRITE_ADDR,
|
||||
.cam_write_ram_size = CAMERA_BUFFER_SIZE,
|
||||
.cam_frame_size = CAMERA_FRAME_SIZE,
|
||||
|
||||
.cam_write_ram_addr1 = 0,
|
||||
.cam_write_ram_size1 = 0,
|
||||
.cam_frame_size1 = 0,
|
||||
};
|
||||
|
||||
static mjpeg_device_t mjpeg_cfg;
|
||||
|
||||
int main(void)
|
||||
{
|
||||
uint8_t psramId[8]= {0};
|
||||
uint32_t i;
|
||||
uint8_t* picture;
|
||||
uint32_t length;
|
||||
|
||||
bflb_platform_init(0);
|
||||
|
||||
MSG("camera case in interleave mode in psram\n");
|
||||
|
||||
bsp_sf_psram_init(1);
|
||||
bsp_sf_psram_read_id(psramId);
|
||||
MSG("PSRAM ID: %02X %02X %02X %02X %02X %02X %02X %02X.\r\n",
|
||||
psramId[0], psramId[1], psramId[2], psramId[3], psramId[4], psramId[5], psramId[6], psramId[7]);
|
||||
|
||||
cam_clk_out();
|
||||
|
||||
cam_hsync_crop(0, 2 * CAMERA_RESOLUTION_X);
|
||||
cam_vsync_crop(0, CAMERA_RESOLUTION_Y);
|
||||
|
||||
if(SUCCESS != image_sensor_init(DISABLE,&camera_cfg,&mjpeg_cfg)){
|
||||
MSG("Init error!\n");
|
||||
BL_CASE_FAIL;
|
||||
}
|
||||
cam_start();
|
||||
|
||||
for(i=0;i<5;i++){
|
||||
while(SUCCESS != cam_get_one_frame_interleave(&picture,&length)){
|
||||
}
|
||||
MSG("picturestartuyvy");
|
||||
UART_SendData(0,picture,length);
|
||||
MSG("pictureend");
|
||||
|
||||
cam_drop_one_frame_interleave();
|
||||
}
|
||||
|
||||
cam_stop();
|
||||
|
||||
BL_CASE_SUCCESS;
|
||||
}
|
9
examples/camera/camera_lcd/CMakeLists.txt
Normal file
9
examples/camera/camera_lcd/CMakeLists.txt
Normal file
@ -0,0 +1,9 @@
|
||||
set(BSP_COMMON_DIR ${CMAKE_SOURCE_DIR}/bsp/bsp_common)
|
||||
set(LINKER_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/bl706_camera_psram.ld)
|
||||
set(TARGET_REQUIRED_PRIVATE_INCLUDE ${BSP_COMMON_DIR}/psram ${BSP_COMMON_DIR}/image_sensor
|
||||
${BSP_COMMON_DIR}/il9341)
|
||||
set(TARGET_REQUIRED_SRCS ${BSP_COMMON_DIR}/psram/bsp_sf_psram.c
|
||||
${BSP_COMMON_DIR}/image_sensor/bsp_image_sensor.c
|
||||
${BSP_COMMON_DIR}/il9341/bsp_il9341.c)
|
||||
set(mains main.c)
|
||||
generate_bin()
|
227
examples/camera/camera_lcd/bl706_camera_psram.ld
Normal file
227
examples/camera/camera_lcd/bl706_camera_psram.ld
Normal file
@ -0,0 +1,227 @@
|
||||
/****************************************************************************************
|
||||
* @file map.txt
|
||||
*
|
||||
* @brief This file is the map file (gnuarm or armgcc).
|
||||
*
|
||||
* Copyright (C) BouffaloLab 2018
|
||||
*
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/* configure the CPU type */
|
||||
OUTPUT_ARCH( "riscv" )
|
||||
/* link with the standard c library */
|
||||
INPUT(-lc)
|
||||
/* link with the standard GCC library */
|
||||
INPUT(-lgcc)
|
||||
/* configure the entry point */
|
||||
ENTRY(_enter)
|
||||
|
||||
StackSize = 0x1000; /* 4KB */
|
||||
HeapSize = 0x1000; /* 4KB */
|
||||
|
||||
MEMORY
|
||||
{
|
||||
xip_memory (rx) : ORIGIN = 0x23000000, LENGTH = 1024K
|
||||
itcm_memory (rx) : ORIGIN = 0x22014000, LENGTH = 10K
|
||||
dtcm_memory (rx) : ORIGIN = 0x42016800, LENGTH = 10K
|
||||
ram_memory (!rx) : ORIGIN = 0x42019000, LENGTH = 20K
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
PROVIDE(__metal_chicken_bit = 0);
|
||||
|
||||
.text :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__text_code_start__ = .;
|
||||
|
||||
KEEP (*(.text.metal.init.enter))
|
||||
KEEP (*(SORT_NONE(.init)))
|
||||
/* section information for finsh shell */
|
||||
. = ALIGN(4);
|
||||
_shell_command_start = .;
|
||||
KEEP(*(shellCommand))
|
||||
_shell_command_end = .;
|
||||
|
||||
/* section information for usb desc */
|
||||
. = ALIGN(4);
|
||||
_usb_desc_start = .;
|
||||
KEEP(*(usb_desc))
|
||||
. = ALIGN(4);
|
||||
_usb_desc_end = .;
|
||||
|
||||
*(.text)
|
||||
*(.text.*)
|
||||
|
||||
/*put .rodata**/
|
||||
*(EXCLUDE_FILE( *bl702_glb.o \
|
||||
*bl702_pds.o \
|
||||
*bl702_common.o \
|
||||
*bl702_sf_cfg.o \
|
||||
*bl702_sf_ctrl.o \
|
||||
*bl702_sflash.o \
|
||||
*bl702_xip_sflash.o \
|
||||
*bl702_ef_ctrl.o) .rodata*)
|
||||
*(.rodata)
|
||||
*(.rodata.*)
|
||||
|
||||
*(.srodata)
|
||||
*(.srodata.*)
|
||||
|
||||
. = ALIGN(4);
|
||||
__text_code_end__ = .;
|
||||
} > xip_memory
|
||||
|
||||
. = ALIGN(4);
|
||||
__itcm_load_addr = .;
|
||||
|
||||
.itcm_region : AT (__itcm_load_addr)
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__tcm_code_start__ = .;
|
||||
|
||||
*(.tcm_code)
|
||||
*(.tcm_const)
|
||||
*(.sclock_rlt_code)
|
||||
*(.sclock_rlt_const)
|
||||
|
||||
*bl702_glb.o*(.rodata*)
|
||||
*bl702_pds.o*(.rodata*)
|
||||
*bl702_common.o*(.rodata*)
|
||||
*bl702_sf_cfg.o*(.rodata*)
|
||||
*bl702_sf_ctrl.o*(.rodata*)
|
||||
*bl702_sflash.o*(.rodata*)
|
||||
*bl702_xip_sflash.o*(.rodata*)
|
||||
*bl702_ef_ctrl.o*(.rodata*)
|
||||
|
||||
. = ALIGN(4);
|
||||
__tcm_code_end__ = .;
|
||||
} > itcm_memory
|
||||
|
||||
__dtcm_load_addr = __itcm_load_addr + SIZEOF(.itcm_region);
|
||||
|
||||
.dtcm_region : AT (__dtcm_load_addr)
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__tcm_data_start__ = .;
|
||||
|
||||
*(.tcm_data)
|
||||
/* *finger_print.o(.data*) */
|
||||
|
||||
. = ALIGN(4);
|
||||
__tcm_data_end__ = .;
|
||||
} > dtcm_memory
|
||||
|
||||
/* .heap_dummy section doesn't contains any symbols. It is only
|
||||
* used for linker to calculate size of heap sections, and assign
|
||||
* values to heap symbols later */
|
||||
.heap_dummy (NOLOAD):
|
||||
{
|
||||
. = ALIGN(0x4);
|
||||
. = . + HeapSize;
|
||||
. = ALIGN(0x4);
|
||||
} > dtcm_memory
|
||||
|
||||
_HeapBase = ORIGIN(dtcm_memory) + LENGTH(dtcm_memory) - StackSize - HeapSize;
|
||||
_HeapSize = HeapSize;
|
||||
|
||||
/* Check if data + heap + stack exceeds RAM limit */
|
||||
ASSERT(_HeapBase >= __tcm_data_end__, "region RAM overflowed with stack")
|
||||
|
||||
/*************************************************************************/
|
||||
/* .stack_dummy section doesn't contains any symbols. It is only
|
||||
* used for linker to calculate size of stack sections, and assign
|
||||
* values to stack symbols later */
|
||||
.stack_dummy (NOLOAD):
|
||||
{
|
||||
. = ALIGN(0x4);
|
||||
. = . + StackSize;
|
||||
. = ALIGN(0x4);
|
||||
} > dtcm_memory
|
||||
|
||||
/* Set stack top to end of RAM, and stack limit move down by
|
||||
* size of stack_dummy section */
|
||||
__StackTop = ORIGIN(dtcm_memory) + LENGTH(dtcm_memory);
|
||||
PROVIDE( __freertos_irq_stack_top = __StackTop);
|
||||
__StackLimit = __StackTop - SIZEOF(.stack_dummy);
|
||||
|
||||
/* Check if data + heap + stack exceeds RAM limit */
|
||||
ASSERT(__StackLimit >= __tcm_data_end__, "region RAM overflowed with stack")
|
||||
/*************************************************************************/
|
||||
|
||||
__system_ram_load_addr = __dtcm_load_addr + SIZEOF(.dtcm_region);
|
||||
|
||||
.system_ram_data_region : AT (__system_ram_load_addr)
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__system_ram_data_start__ = .;
|
||||
|
||||
*(.system_ram)
|
||||
|
||||
. = ALIGN(4);
|
||||
__system_ram_data_end__ = .;
|
||||
} > ram_memory
|
||||
|
||||
__ram_load_addr = __system_ram_load_addr + SIZEOF(.system_ram_data_region);
|
||||
|
||||
/* Data section */
|
||||
RAM_DATA : AT (__ram_load_addr)
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__ram_data_start__ = .;
|
||||
|
||||
PROVIDE( __global_pointer$ = . + 0x800 );
|
||||
|
||||
*(.data)
|
||||
*(.data.*)
|
||||
*(.sdata)
|
||||
*(.sdata.*)
|
||||
*(.sdata2)
|
||||
*(.sdata2.*)
|
||||
|
||||
. = ALIGN(4);
|
||||
__ram_data_end__ = .;
|
||||
} > ram_memory
|
||||
|
||||
.bss (NOLOAD) :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__bss_start__ = .;
|
||||
|
||||
*(.bss*)
|
||||
*(.sbss*)
|
||||
*(COMMON)
|
||||
|
||||
. = ALIGN(4);
|
||||
__bss_end__ = .;
|
||||
} > ram_memory
|
||||
|
||||
.noinit_data (NOLOAD) :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__noinit_data_start__ = .;
|
||||
|
||||
*(.noinit_data*)
|
||||
|
||||
. = ALIGN(4);
|
||||
__noinit_data_end__ = .;
|
||||
} > ram_memory
|
||||
|
||||
.heap (NOLOAD):
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__HeapBase = .;
|
||||
|
||||
/*__end__ = .;*/
|
||||
/*end = __end__;*/
|
||||
KEEP(*(.heap*))
|
||||
|
||||
. = ALIGN(4);
|
||||
__HeapLimit = .;
|
||||
} > ram_memory
|
||||
__HeapLimit = ORIGIN(ram_memory) + LENGTH(ram_memory);
|
||||
|
||||
}
|
||||
|
738
examples/camera/camera_lcd/cdk/camera_lcd.cdkproj
Normal file
738
examples/camera/camera_lcd/cdk/camera_lcd.cdkproj
Normal file
@ -0,0 +1,738 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Project Name="camera_lcd" Version="1" Language="C">
|
||||
<Description>CPU: RV32IMAFC
|
||||
Chip: bl70x
|
||||
Board: bl70x_iot
|
||||
</Description>
|
||||
<Dependencies Name="Debug"/>
|
||||
<VirtualDirectory Name="app">
|
||||
<File Name="../main.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
</VirtualDirectory>
|
||||
<VirtualDirectory Name="chip">
|
||||
<VirtualDirectory Name="riscv">
|
||||
<File Name="../../../../drivers/bl702_driver/startup/interrupt.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/startup/system_bl702.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
</VirtualDirectory>
|
||||
<VirtualDirectory Name="startup">
|
||||
<File Name="../../../../drivers/bl702_driver/startup/GCC/entry.S">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/startup/GCC/start_load.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
</VirtualDirectory>
|
||||
</VirtualDirectory>
|
||||
<VirtualDirectory Name="hal">
|
||||
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_adc.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_dac.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_dma.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_gpio.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_i2c.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_i2s.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_mtimer.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_pwm.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_spi.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_timer.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_uart.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_usb.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_clock.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_cam.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_mjpeg.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
</VirtualDirectory>
|
||||
<VirtualDirectory Name="std">
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_acomp.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_adc.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_aon.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_cam.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_clock.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_dac.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_dma.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_ef_ctrl.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_emac.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_glb.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_hbn.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_i2c.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_i2c_gpio_sim.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_i2s.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_ir.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_common.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_kys.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_l1c.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_mjpeg.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_pds.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_psram.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_pwm.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_qdec.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_romapi.c" ExcludeProjConfig="BuildSet">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_romdriver.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_sec_dbg.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_sec_eng.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_sf_cfg.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_sf_cfg_ext.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_sf_ctrl.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_sflash.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_sflash_ext.c" ExcludeProjConfig="">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_spi.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_timer.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_uart.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_usb.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_xip_sflash.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_xip_sflash_ext.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
</VirtualDirectory>
|
||||
<VirtualDirectory Name="board">
|
||||
<File Name="../../../../bsp/board/bl706_iot/board.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../bsp/bsp_common/platform/bflb_platform.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../bsp/bsp_common/il9341/bsp_il9341.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../bsp/bsp_common/image_sensor/bsp_image_sensor.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../bsp/bsp_common/psram/bsp_sf_psram.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
</VirtualDirectory>
|
||||
<VirtualDirectory Name="common">
|
||||
<File Name="../../../../common/device/drv_device.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/memheap/drv_mmheap.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/ring_buffer/ring_buffer.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/soft_crc/softcrc.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<VirtualDirectory Name="libc">
|
||||
<File Name="../../../../common/libc/src/atof.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/atoi.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/atol.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/atoll.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/atox.c" ExcludeProjConfig="BuildSet">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/bsearch.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/common.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/ctype_isalnum.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/ctype_isalpha.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/ctype_isascii.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/ctype_isblank.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/ctype_iscntrl.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/ctype_isdigit.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/ctype_isgraph.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/ctype_islower.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/ctype_isprint.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/ctype_ispunct.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/ctype_isspace.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/ctype_isupper.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/ctype_isxdigit.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/ctype_tolower.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/ctype_toupper.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/ctypes.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/fnmatch.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/jrand48.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/lrand48.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/memccpy.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/memchr.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/memcmp.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/memcpy.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/memmem.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/memrchr.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/memset.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/memswap.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/mrand48.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/nrand48.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/qsort.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/seed48.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/snprintf.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/sprintf.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/srand48.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/sscanf.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/stdlib.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strcasecmp.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strcat.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strchr.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strcmp.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strcpy.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strcspn.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strlcat.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strlcpy.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strlen.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strncasecmp.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strncat.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strncmp.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strncpy.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strnlen.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strntoimax.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strntoumax.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strpbrk.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strrchr.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strsep.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strspn.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strstr.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strtoimax.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strtok.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strtok_r.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strtol.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strtoll.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strtoul.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strtoull.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strtoumax.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strtox.c" ExcludeProjConfig="BuildSet">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strxspn.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/vsnprintf.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/vsprintf.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/vsscanf.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
</VirtualDirectory>
|
||||
<File Name="../../../../common/misc/misc.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
</VirtualDirectory>
|
||||
<VirtualDirectory Name="script">
|
||||
<File Name="../../../../tools/openocd/bl70x_gdb.init">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/regs/bl70x_reg.svc">
|
||||
<FileOption/>
|
||||
</File>
|
||||
</VirtualDirectory>
|
||||
<MonitorProgress>
|
||||
<DebugLaunch>154</DebugLaunch>
|
||||
<FlashOperate>104</FlashOperate>
|
||||
</MonitorProgress>
|
||||
<VirtualDirectory Name="components">
|
||||
<VirtualDirectory Name="fatfs">
|
||||
<File Name="../../../../components/fatfs/diskio.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../components/fatfs/ff.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../components/fatfs/ffsystem.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../components/fatfs/ffunicode.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
</VirtualDirectory>
|
||||
<VirtualDirectory Name="shell">
|
||||
<File Name="../../../../components/shell/drv_shell.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
</VirtualDirectory>
|
||||
<VirtualDirectory Name="usb_stack">
|
||||
<VirtualDirectory Name="class">
|
||||
<VirtualDirectory Name="cdc">
|
||||
<File Name="../../../../components/usb_stack/class/cdc/usbd_cdc.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
</VirtualDirectory>
|
||||
<VirtualDirectory Name="hid">
|
||||
<File Name="../../../../components/usb_stack/class/hid/usbd_hid.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
</VirtualDirectory>
|
||||
<VirtualDirectory Name="msc">
|
||||
<File Name="../../../../components/usb_stack/class/msc/usbd_msc.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
</VirtualDirectory>
|
||||
</VirtualDirectory>
|
||||
<VirtualDirectory Name="core">
|
||||
<File Name="../../../../components/usb_stack/core/usbd_core.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
</VirtualDirectory>
|
||||
</VirtualDirectory>
|
||||
</VirtualDirectory>
|
||||
<Dependencies Name="BuildSet"/>
|
||||
<DebugSessions>
|
||||
<watchExpressions/>
|
||||
<memoryExpressions>;;;</memoryExpressions>
|
||||
<statistics>;;MHZ;</statistics>
|
||||
<peripheralTabs>
|
||||
<Tab disFormat="Hex">glb</Tab>
|
||||
<Tab disFormat="Hex">uart</Tab>
|
||||
</peripheralTabs>
|
||||
<WatchDisplayFormat>1</WatchDisplayFormat>
|
||||
<LocalDisplayFormat>1</LocalDisplayFormat>
|
||||
<debugLayout/>
|
||||
<memoryTabColSizeExpressions>100:8;100:8;100:8;100:8;</memoryTabColSizeExpressions>
|
||||
</DebugSessions>
|
||||
<DebugSessions>
|
||||
<watchExpressions/>
|
||||
<memoryExpressions>;;;</memoryExpressions>
|
||||
<statistics>;;MHZ;</statistics>
|
||||
<peripheralTabs>
|
||||
<Tab disFormat="Hex">glb</Tab>
|
||||
<Tab disFormat="Hex">uart</Tab>
|
||||
</peripheralTabs>
|
||||
<WatchDisplayFormat>1</WatchDisplayFormat>
|
||||
<LocalDisplayFormat>1</LocalDisplayFormat>
|
||||
<debugLayout/>
|
||||
<memoryTabColSizeExpressions>100:8;100:8;100:8;100:8;</memoryTabColSizeExpressions>
|
||||
</DebugSessions>
|
||||
<BuildConfigs>
|
||||
<BuildConfig Name="BuildSet">
|
||||
<Target>
|
||||
<ROMBank Selected="1">
|
||||
<ROM1>
|
||||
<InUse>no</InUse>
|
||||
<Start>0x23000000</Start>
|
||||
<Size>0x100000</Size>
|
||||
</ROM1>
|
||||
<ROM2>
|
||||
<InUse>no</InUse>
|
||||
<Start>0x22014000</Start>
|
||||
<Size>0x4000</Size>
|
||||
</ROM2>
|
||||
<ROM3>
|
||||
<InUse>no</InUse>
|
||||
<Start>0x42018000</Start>
|
||||
<Size>0x8000</Size>
|
||||
</ROM3>
|
||||
<ROM4>
|
||||
<InUse>no</InUse>
|
||||
<Start/>
|
||||
<Size/>
|
||||
</ROM4>
|
||||
<ROM5>
|
||||
<InUse>no</InUse>
|
||||
<Start/>
|
||||
<Size/>
|
||||
</ROM5>
|
||||
</ROMBank>
|
||||
<RAMBank>
|
||||
<RAM1>
|
||||
<InUse>yes</InUse>
|
||||
<Start>0x42020000</Start>
|
||||
<Size>0xc000</Size>
|
||||
<Init>yes</Init>
|
||||
</RAM1>
|
||||
<RAM2>
|
||||
<InUse>no</InUse>
|
||||
<Start/>
|
||||
<Size/>
|
||||
<Init>yes</Init>
|
||||
</RAM2>
|
||||
<RAM3>
|
||||
<InUse>no</InUse>
|
||||
<Start/>
|
||||
<Size/>
|
||||
<Init>yes</Init>
|
||||
</RAM3>
|
||||
<RAM4>
|
||||
<InUse>no</InUse>
|
||||
<Start/>
|
||||
<Size/>
|
||||
<Init>yes</Init>
|
||||
</RAM4>
|
||||
<RAM5>
|
||||
<InUse>no</InUse>
|
||||
<Start/>
|
||||
<Size/>
|
||||
<Init>yes</Init>
|
||||
</RAM5>
|
||||
</RAMBank>
|
||||
<CPU>rv32imafc</CPU>
|
||||
<UseMiniLib>no</UseMiniLib>
|
||||
<Endian>little</Endian>
|
||||
<UseHardFloat>no</UseHardFloat>
|
||||
<UseEnhancedLRW>no</UseEnhancedLRW>
|
||||
<UseContinueBuild>no</UseContinueBuild>
|
||||
<UseSemiHost>no</UseSemiHost>
|
||||
</Target>
|
||||
<Output>
|
||||
<OutputName>$(ProjectName)</OutputName>
|
||||
<Type>Executable</Type>
|
||||
<CreateHexFile>no</CreateHexFile>
|
||||
<CreateBinFile>yes</CreateBinFile>
|
||||
<Preprocessor>no</Preprocessor>
|
||||
<Disassmeble>yes</Disassmeble>
|
||||
<CallGraph>no</CallGraph>
|
||||
<Map>yes</Map>
|
||||
</Output>
|
||||
<User>
|
||||
<BeforeCompile>
|
||||
<RunUserProg>no</RunUserProg>
|
||||
<UserProgName/>
|
||||
</BeforeCompile>
|
||||
<BeforeMake>
|
||||
<RunUserProg>no</RunUserProg>
|
||||
<UserProgName/>
|
||||
</BeforeMake>
|
||||
<AfterMake>
|
||||
<RunUserProg>no</RunUserProg>
|
||||
<UserProgName>$(ProjectPath)../../../../tools/bflb_flash_tool/bflb_mcu_tool.exe --chipname=bl702 --firmware="D:/BouffaloLabWS/cdk_ws/bl_mcu_sdk/examples/hellowd/Obj/helloworld.bin" </UserProgName>
|
||||
</AfterMake>
|
||||
</User>
|
||||
<Compiler>
|
||||
<Define>BL702;ARCH_RISCV;</Define>
|
||||
<Undefine/>
|
||||
<Optim>Optimize size (-Os)</Optim>
|
||||
<DebugLevel>Default (-g)</DebugLevel>
|
||||
<IncludePath>$(ProjectPath);$(ProjectPath)../;$(ProjectPath)../../../../components/fatfs;$(ProjectPath)../../../../components/freertos/Source/include;$(ProjectPath)../../../../components/shell;$(ProjectPath)../../../../components/usb_stack/class/audio;$(ProjectPath)../../../../components/usb_stack/class/cdc;$(ProjectPath)../../../../components/usb_stack/class/hid;$(ProjectPath)../../../../components/usb_stack/class/msc;$(ProjectPath)../../../../components/usb_stack/class/video;$(ProjectPath)../../../../components/usb_stack/class/webusb;$(ProjectPath)../../../../components/usb_stack/class/winusb;$(ProjectPath)../../../../components/usb_stack/common;$(ProjectPath)../../../../components/usb_stack/core;$(ProjectPath)../../../../bsp/board/bl706_iot;$(ProjectPath)../../../../bsp/bsp_common/platform;$(ProjectPath)../../../../bsp/bsp_common/il9341;$(ProjectPath)../../../../bsp/bsp_common/image_sensor;$(ProjectPath)../../../../bsp/bsp_common/psram;$(ProjectPath)../../../../common/libc/inc;$(ProjectPath)../../../../common/libc/inc/arm_gcc;$(ProjectPath)../../../../common/libc/inc/bits;$(ProjectPath)../../../../common/libc/inc/sys;$(ProjectPath)../../../../common/libc/src;$(ProjectPath)../../../../common/device;$(ProjectPath)../../../../common/list;$(ProjectPath)../../../../common/memheap;$(ProjectPath)../../../../common/misc;$(ProjectPath)../../../../common/ring_buffer;$(ProjectPath)../../../../common/soft_crc;$(ProjectPath)../../../../components/shell;$(ProjectPath)../../../../drivers/bl702_driver/hal_drv/default_config;$(ProjectPath)../../../../drivers/bl702_driver/risc-v/Core/Include;$(ProjectPath)../../../../drivers/bl702_driver/hal_drv/inc;$(ProjectPath)../../../../drivers/bl702_driver/regs;$(ProjectPath)../../../../drivers/bl702_driver/startup;$(ProjectPath)../../../../drivers/bl702_driver/std_drv/inc</IncludePath>
|
||||
<OtherFlags>-fshort-enums -fno-common -fms-extensions -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -Wall -Wshift-negative-value -Wchar-subscripts -Wformat -Wuninitialized -Winit-self -fno-jump-tables -Wignored-qualifiers -Wswitch-default -Wunused -Wundef -msmall-data-limit=4</OtherFlags>
|
||||
<Verbose>no</Verbose>
|
||||
<Ansi>no</Ansi>
|
||||
<Syntax>no</Syntax>
|
||||
<Pedantic>no</Pedantic>
|
||||
<PedanticErr>no</PedanticErr>
|
||||
<InhibitWarn>no</InhibitWarn>
|
||||
<AllWarn>yes</AllWarn>
|
||||
<WarnErr>no</WarnErr>
|
||||
<OneElfS>yes</OneElfS>
|
||||
<Fstrict>no</Fstrict>
|
||||
</Compiler>
|
||||
<Asm>
|
||||
<Define/>
|
||||
<Undefine/>
|
||||
<IncludePath>$(ProjectPath);$(ProjectPath)../;$(ProjectPath)../../../../components/fatfs;$(ProjectPath)../../../../components/freertos/Source/include;$(ProjectPath)../../../../components/shell;$(ProjectPath)../../../../components/usb_stack/class/audio;$(ProjectPath)../../../../components/usb_stack/class/cdc;$(ProjectPath)../../../../components/usb_stack/class/hid;$(ProjectPath)../../../../components/usb_stack/class/msc;$(ProjectPath)../../../../components/usb_stack/class/video;$(ProjectPath)../../../../components/usb_stack/class/webusb;$(ProjectPath)../../../../components/usb_stack/class/winusb;$(ProjectPath)../../../../components/usb_stack/common;$(ProjectPath)../../../../components/usb_stack/core;$(ProjectPath)../../../../bsp/board/bl706_iot;$(ProjectPath)../../../../bsp/bsp_common/platform;$(ProjectPath)../../../../common/device;$(ProjectPath)../../../../common/list;$(ProjectPath)../../../../common/memheap;$(ProjectPath)../../../../common/misc;$(ProjectPath)../../../../common/ring_buffer;$(ProjectPath)../../../../common/soft_crc;$(ProjectPath)../../../../components/shell;$(ProjectPath)../../../../drivers/bl702_driver/hal_drv/default_config;$(ProjectPath)../../../../drivers/bl702_driver/hal_drv/inc;$(ProjectPath)../../../../drivers/bl702_driver/risc-v/Core/Include;$(ProjectPath)../../../../drivers/bl702_driver/regs;$(ProjectPath)../../../../drivers/bl702_driver/startup;$(ProjectPath)../../../../drivers/bl702_driver/std_drv/inc;$(ProjectPath)../../../../drivers/bl602_driver/risc-v/Core/Include;$(ProjectPath)../../../../drivers/bl602_driver/startup;$(ProjectPath)../../../../drivers/bl602_driver/hal_drv/inc;$(ProjectPath)../../../../drivers/bl602_driver/hal_drv/default_config;$(ProjectPath)../../../../drivers/bl602_driver/regs;$(ProjectPath)../../../../drivers/bl602_driver/std_drv/inc</IncludePath>
|
||||
<OtherFlags/>
|
||||
<DebugLevel>gdwarf2</DebugLevel>
|
||||
</Asm>
|
||||
<Linker>
|
||||
<Garbage>yes</Garbage>
|
||||
<Garbage2>yes</Garbage2>
|
||||
<LDFile>$(ProjectPath)/../../camera_interleave_psram/bl706_camera_psram.ld</LDFile>
|
||||
<LibName/>
|
||||
<LibPath/>
|
||||
<OtherFlags/>
|
||||
<AutoLDFile>no</AutoLDFile>
|
||||
<LinkType/>
|
||||
</Linker>
|
||||
<Debug>
|
||||
<LoadApplicationAtStartup>yes</LoadApplicationAtStartup>
|
||||
<Connector>ICE</Connector>
|
||||
<StopAt>yes</StopAt>
|
||||
<StopAtText>main</StopAtText>
|
||||
<InitFile/>
|
||||
<AfterLoadFile>$(ProjectPath)/../../../../tools/openocd/bl70x_gdb.init</AfterLoadFile>
|
||||
<AutoRun>yes</AutoRun>
|
||||
<ResetType>Hard Reset</ResetType>
|
||||
<SoftResetVal>23000000</SoftResetVal>
|
||||
<ResetAfterLoad>no</ResetAfterLoad>
|
||||
<Dumpcore>no</Dumpcore>
|
||||
<DumpcoreText>$(ProjectPath)/$(ProjectName).cdkcore</DumpcoreText>
|
||||
<ConfigICE>
|
||||
<IP>localhost</IP>
|
||||
<PORT>1025</PORT>
|
||||
<CPUNumber>0</CPUNumber>
|
||||
<Clock>2000</Clock>
|
||||
<Delay>10</Delay>
|
||||
<WaitReset>50</WaitReset>
|
||||
<DDC>yes</DDC>
|
||||
<TRST>no</TRST>
|
||||
<DebugPrint>no</DebugPrint>
|
||||
<Connect>Normal</Connect>
|
||||
<ResetType>Hard Reset</ResetType>
|
||||
<SoftResetVal>21000000</SoftResetVal>
|
||||
<RTOSType>Bare Metal</RTOSType>
|
||||
<DownloadToFlash>yes</DownloadToFlash>
|
||||
<ResetAfterConnect>yes</ResetAfterConnect>
|
||||
<GDBName/>
|
||||
<GDBServerType>Local</GDBServerType>
|
||||
<OtherFlags>-arch riscv</OtherFlags>
|
||||
</ConfigICE>
|
||||
<ConfigSIM>
|
||||
<SIMTarget/>
|
||||
<OtherFlags/>
|
||||
<NoGraphic>yes</NoGraphic>
|
||||
<Log>no</Log>
|
||||
<SimTrace>no</SimTrace>
|
||||
</ConfigSIM>
|
||||
<ConfigOpenOCD>
|
||||
<OpenOCDExecutablePath>openocd-bl702</OpenOCDExecutablePath>
|
||||
<OpenOCDTelnetPortEnable>no</OpenOCDTelnetPortEnable>
|
||||
<OpenOCDTelnetPort>4444</OpenOCDTelnetPort>
|
||||
<OpenOCDTclPortEnable>no</OpenOCDTclPortEnable>
|
||||
<OpenOCDTclPort>6666</OpenOCDTclPort>
|
||||
<OpenOCDConfigOptions>-f openocd_bl702_evb.cfg</OpenOCDConfigOptions>
|
||||
</ConfigOpenOCD>
|
||||
</Debug>
|
||||
<Flash>
|
||||
<InitFile/>
|
||||
<Erase>Erase Sectors</Erase>
|
||||
<Algorithms Path=""/>
|
||||
<Program>yes</Program>
|
||||
<Verify>yes</Verify>
|
||||
<ResetAndRun>no</ResetAndRun>
|
||||
<ResetType>Hard Reset</ResetType>
|
||||
<SoftResetVal/>
|
||||
<External>no</External>
|
||||
<Command/>
|
||||
<Arguments/>
|
||||
</Flash>
|
||||
</BuildConfig>
|
||||
</BuildConfigs>
|
||||
</Project>
|
276
examples/camera/camera_lcd/main.c
Normal file
276
examples/camera/camera_lcd/main.c
Normal file
@ -0,0 +1,276 @@
|
||||
/**
|
||||
* @file main.c
|
||||
* @brief
|
||||
*
|
||||
* Copyright (c) 2021 Bouffalolab team
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "bflb_platform.h"
|
||||
#include "bsp_sf_psram.h"
|
||||
#include "bsp_image_sensor.h"
|
||||
#include "hal_spi.h"
|
||||
#include "hal_gpio.h"
|
||||
#include "hal_dma.h"
|
||||
#include "bsp_il9341.h"
|
||||
|
||||
#include "picture.c"
|
||||
|
||||
#define CAMERA_RESOLUTION_X (240)
|
||||
#define CAMERA_RESOLUTION_Y (320)
|
||||
#define CAMERA_FRAME_SIZE (CAMERA_RESOLUTION_X * CAMERA_RESOLUTION_Y*2)
|
||||
#define CAMERA_WRITE_ADDR (0x26000000)
|
||||
#define CAMERA_BUFFER_SIZE (CAMERA_FRAME_SIZE)
|
||||
#define CAMERA_WRITE_ADDR1 (0x26000000 + CAMERA_BUFFER_SIZE)
|
||||
#define CAMERA_BUFFER_SIZE1 (0x200000)
|
||||
|
||||
#define YUV422_FRAME_SIZE (CAMERA_RESOLUTION_X * CAMERA_RESOLUTION_Y)
|
||||
#define YUV420_FRAME_SIZE (CAMERA_RESOLUTION_X * CAMERA_RESOLUTION_Y/2)
|
||||
#define YUV400_FRAME_SIZE (0)
|
||||
|
||||
#define RGB_FRAME_SIZE (CAMERA_RESOLUTION_X * CAMERA_RESOLUTION_Y * 3)
|
||||
|
||||
#define YUV_USE (1)
|
||||
|
||||
// #define TEST_TIM
|
||||
|
||||
/* Turn 24-bit RGB color to 16-bit */
|
||||
#define RGB(r,g,b) (((r>>3)<<3|(g>>5)|(g>>2)<<13|(b>>3)<<8)&0xffff)
|
||||
|
||||
static cam_device_t camera_cfg =
|
||||
{
|
||||
.software_mode = CAM_MANUAL_MODE,
|
||||
.frame_mode = CAM_FRAME_INTERLEAVE_MODE,
|
||||
.yuv_format = CAM_YUV_FORMAT_YUV422,
|
||||
.cam_write_ram_addr = CAMERA_WRITE_ADDR,
|
||||
.cam_write_ram_size = CAMERA_BUFFER_SIZE,
|
||||
.cam_frame_size = YUV422_FRAME_SIZE *2,
|
||||
|
||||
.cam_write_ram_addr1 = CAMERA_WRITE_ADDR1,
|
||||
.cam_write_ram_size1 = CAMERA_BUFFER_SIZE1,
|
||||
.cam_frame_size1 = YUV422_FRAME_SIZE,
|
||||
};
|
||||
|
||||
static mjpeg_device_t mjpeg_cfg;
|
||||
|
||||
|
||||
#define RANGE_INT(iVal, iMin, iMax) ( ( ( iVal ) > ( iMin ) ) ? ( ( ( iVal ) <= ( iMax ) ) ? ( iVal ) : ( iMax ) ) : ( iMin ) )
|
||||
#define ROUND_SHR_POSITIVE(Dividend, iShiftRightCount) ( ( ( Dividend ) & ( 1 << ( ( iShiftRightCount ) - 1 ) ) ) ? ( ( Dividend ) >> ( iShiftRightCount ) ) + 1 : ( ( Dividend ) >> ( iShiftRightCount ) ) )
|
||||
#define ROUND_SHR_NEGATIVE(Dividend, iShiftRightCount) ( -( ( ( -( Dividend ) ) & ( 1 << ( ( iShiftRightCount ) - 1 ) ) ) ? ( ( -( Dividend ) ) >> ( iShiftRightCount ) ) + 1 : ( ( -( Dividend ) ) >> ( iShiftRightCount ) ) ) )
|
||||
#define ROUND_SHR(Dividend, iShiftRightCount) ( ( ( Dividend ) >= 0 ) ? ROUND_SHR_POSITIVE( Dividend, iShiftRightCount ) : ROUND_SHR_NEGATIVE( Dividend, iShiftRightCount ) )
|
||||
|
||||
void YCbCrConvertToRGB(int Y, int Cb, int Cr, int* R, int* G, int* B)
|
||||
{
|
||||
int iTmpR = 0;
|
||||
int iTmpG = 0;
|
||||
int iTmpB = 0;
|
||||
|
||||
iTmpR = (((int)Y) << 14) + 22970*(((int)Cr) - 128);
|
||||
iTmpG = (((int)Y) << 14) - 5638*(((int)Cb) - 128) - 11700*(((int)Cr) - 128);
|
||||
iTmpB = (((int)Y) << 14) + 29032*(((int)Cb) - 128);
|
||||
|
||||
iTmpR = ROUND_SHR(iTmpR, 14);
|
||||
iTmpG = ROUND_SHR(iTmpG, 14);
|
||||
iTmpB = ROUND_SHR(iTmpB, 14);
|
||||
|
||||
*R = (int)RANGE_INT(iTmpR, 0, 255);
|
||||
*G = (int)RANGE_INT(iTmpG, 0, 255);
|
||||
*B = (int)RANGE_INT(iTmpB, 0, 255);
|
||||
}
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||
#endif
|
||||
#ifndef MIN
|
||||
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
#endif
|
||||
static long U[256], V[256], Y1[256], Y2[256];
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
void init_yuv422p_table(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
// Initialize table
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
V[i] = 15938 * i - 2221300;
|
||||
U[i] = 20238 * i - 2771300;
|
||||
Y1[i] = 11644 * i;
|
||||
Y2[i] = 19837 * i - 311710;
|
||||
}
|
||||
}
|
||||
/**
|
||||
memory structure
|
||||
w
|
||||
+--------------------+
|
||||
|Y0Y1Y2Y3... |
|
||||
|... | h
|
||||
|... |
|
||||
| |
|
||||
+--------------------+
|
||||
|U0V0U1V1 |
|
||||
|... | h
|
||||
|... |
|
||||
| |
|
||||
+--------------------+
|
||||
w/2
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param yuv422sp
|
||||
* @param rgb
|
||||
* @param width
|
||||
* @param height
|
||||
*/
|
||||
void yuv422sp_to_rgb24(unsigned char* yuv422sp, unsigned char* rgb, int width, int height)
|
||||
{
|
||||
int y, cb, cr;
|
||||
int r, g, b;
|
||||
int i = 0;
|
||||
unsigned char* p_y;
|
||||
unsigned char* p_uv;
|
||||
unsigned char* p_rgb;
|
||||
static int init_yuv422sp = 0; // just do it once
|
||||
|
||||
p_y = yuv422sp;
|
||||
p_uv = p_y + width * height;
|
||||
p_rgb = rgb;
|
||||
|
||||
if (init_yuv422sp == 0)
|
||||
{
|
||||
init_yuv422p_table();
|
||||
init_yuv422sp = 1;
|
||||
}
|
||||
|
||||
for (i = 0; i < width * height / 2; i++)
|
||||
{
|
||||
y = p_y[0];
|
||||
cb = p_uv[0];
|
||||
cr = p_uv[1];
|
||||
|
||||
r = MAX (0, MIN (255, (V[cr] + Y1[y])/10000)); //R value
|
||||
b = MAX (0, MIN (255, (U[cb] + Y1[y])/10000)); //B value
|
||||
g = MAX (0, MIN (255, (Y2[y] - 5094*(r) - 1942*(b))/10000)); //G value
|
||||
|
||||
// default rank:RGB
|
||||
p_rgb[0] = b;
|
||||
p_rgb[1] = g;
|
||||
p_rgb[2] = r;
|
||||
|
||||
y = p_y[1];
|
||||
cb = p_uv[0];
|
||||
cr = p_uv[1];
|
||||
r = MAX (0, MIN (255, (V[cr] + Y1[y])/10000)); //R value
|
||||
b = MAX (0, MIN (255, (U[cb] + Y1[y])/10000)); //B value
|
||||
g = MAX (0, MIN (255, (Y2[y] - 5094*(r) - 1942*(b))/10000)); //G value
|
||||
|
||||
p_rgb[3] = b;
|
||||
p_rgb[4] = g;
|
||||
p_rgb[5] = r;
|
||||
|
||||
p_y += 2;
|
||||
p_uv += 2;
|
||||
p_rgb += 6;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param rgb24
|
||||
* @param rgb16
|
||||
*/
|
||||
void rgb24_to_rgb565(uint8_t *rgb24, uint8_t *rgb16)
|
||||
{
|
||||
int i = 0, j = 0;
|
||||
for (i = 0; i < RGB_FRAME_SIZE; i += 3)
|
||||
{
|
||||
rgb16[j+1] = rgb24[i] >> 3; // B
|
||||
rgb16[j+1] |= ((rgb24[i+1] & 0x1C) << 3); // G
|
||||
rgb16[j] = rgb24[i+2] & 0xF8;// R
|
||||
rgb16[j] |= (rgb24[i+1] >>5); // G
|
||||
j += 2;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
int main(void)
|
||||
{
|
||||
uint8_t* picture;
|
||||
#ifdef USE_YUV422
|
||||
uint8_t *rgb_pic = (uint32_t *)(0x26500000);
|
||||
uint8_t *rgb16_pic = (uint32_t *)(0x26800000);
|
||||
#endif
|
||||
uint32_t length;
|
||||
#ifdef TEST_TIM
|
||||
uint32_t timer_start = 0;
|
||||
uint32_t timer_end = 0;
|
||||
#endif
|
||||
|
||||
bflb_platform_init(0);
|
||||
LCD_Init();
|
||||
LCD_Clear(0);
|
||||
|
||||
bsp_sf_psram_init(1);
|
||||
|
||||
cam_clk_out();
|
||||
|
||||
cam_hsync_crop(400, (2 * CAMERA_RESOLUTION_X)+400);
|
||||
cam_vsync_crop(80, CAMERA_RESOLUTION_Y+80);
|
||||
|
||||
if(SUCCESS != image_sensor_init(DISABLE,&camera_cfg,&mjpeg_cfg)){
|
||||
MSG("Init error!\n");
|
||||
BL_CASE_FAIL;
|
||||
}
|
||||
cam_start();
|
||||
|
||||
LCD_Set_Addr(0,0,240,320);
|
||||
while(1)
|
||||
{
|
||||
#ifdef TEST_TIM
|
||||
timer_start = bflb_platform_get_time_ms();
|
||||
#endif
|
||||
while(SUCCESS != cam_get_one_frame_interleave(&picture,&length)){
|
||||
}
|
||||
cam_stop();
|
||||
#ifdef USE_YUV422
|
||||
yuv422sp_to_rgb24(picture, rgb_pic, CAMERA_RESOLUTION_X, CAMERA_RESOLUTION_Y);
|
||||
rgb24_to_rgb565(rgb_pic, rgb16_pic);
|
||||
LCD_DrawPicture_cam(0, 0, CAMERA_RESOLUTION_X, CAMERA_RESOLUTION_Y, picture);
|
||||
#else
|
||||
LCD_WR_SPI_DMA(picture, (YUV422_FRAME_SIZE*2));
|
||||
#endif
|
||||
cam_drop_one_frame_interleave();
|
||||
cam_start();
|
||||
|
||||
#ifdef TEST_TIM
|
||||
timer_end = bflb_platform_get_time_ms();
|
||||
MSG("time:%d\r\n",(timer_end-timer_start));
|
||||
#endif
|
||||
}
|
||||
}
|
19495
examples/camera/camera_lcd/picture.c
Normal file
19495
examples/camera/camera_lcd/picture.c
Normal file
File diff suppressed because it is too large
Load Diff
6
examples/dac/dac_mono_play_form_flash/CMakeLists.txt
Normal file
6
examples/dac/dac_mono_play_form_flash/CMakeLists.txt
Normal file
@ -0,0 +1,6 @@
|
||||
set(mains main.c)
|
||||
#SET(LINKER_SCRIPT ${CMAKE_SOURCE_DIR}/examples/dac/dac_mono_play_form_flash/bl702_dac_flash.ld)
|
||||
generate_bin()
|
||||
|
||||
|
||||
|
227
examples/dac/dac_mono_play_form_flash/bl702_dac_flash.ld
Normal file
227
examples/dac/dac_mono_play_form_flash/bl702_dac_flash.ld
Normal file
@ -0,0 +1,227 @@
|
||||
/****************************************************************************************
|
||||
* @file map.txt
|
||||
*
|
||||
* @brief This file is the map file (gnuarm or armgcc).
|
||||
*
|
||||
* Copyright (C) BouffaloLab 2018
|
||||
*
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/* configure the CPU type */
|
||||
OUTPUT_ARCH( "riscv" )
|
||||
/* link with the standard c library */
|
||||
INPUT(-lc)
|
||||
/* link with the standard GCC library */
|
||||
INPUT(-lgcc)
|
||||
/* configure the entry point */
|
||||
ENTRY(_enter)
|
||||
|
||||
StackSize = 0x1000; /* 4KB */
|
||||
HeapSize = 0x6000; /* 4KB */
|
||||
|
||||
MEMORY
|
||||
{
|
||||
xip_memory (rx) : ORIGIN = 0x23000000, LENGTH = 4096K
|
||||
itcm_memory (rx) : ORIGIN = 0x22014000, LENGTH = 16K
|
||||
dtcm_memory (rx) : ORIGIN = 0x42018000, LENGTH = 32K
|
||||
ram_memory (!rx) : ORIGIN = 0x42020000, LENGTH = 48K
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
PROVIDE(__metal_chicken_bit = 0);
|
||||
|
||||
.text :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__text_code_start__ = .;
|
||||
|
||||
KEEP (*(.text.metal.init.enter))
|
||||
KEEP (*(SORT_NONE(.init)))
|
||||
/* section information for finsh shell */
|
||||
. = ALIGN(4);
|
||||
_shell_command_start = .;
|
||||
KEEP(*(shellCommand))
|
||||
_shell_command_end = .;
|
||||
|
||||
/* section information for usb desc */
|
||||
. = ALIGN(4);
|
||||
_usb_desc_start = .;
|
||||
KEEP(*(usb_desc))
|
||||
. = ALIGN(4);
|
||||
_usb_desc_end = .;
|
||||
|
||||
*(.text)
|
||||
*(.text.*)
|
||||
|
||||
/*put .rodata**/
|
||||
*(EXCLUDE_FILE( *bl702_glb.o \
|
||||
*bl702_pds.o \
|
||||
*bl702_common.o \
|
||||
*bl702_sf_cfg.o \
|
||||
*bl702_sf_ctrl.o \
|
||||
*bl702_sflash.o \
|
||||
*bl702_xip_sflash.o \
|
||||
*bl702_ef_ctrl.o) .rodata*)
|
||||
*(.rodata)
|
||||
*(.rodata.*)
|
||||
|
||||
*(.srodata)
|
||||
*(.srodata.*)
|
||||
|
||||
. = ALIGN(4);
|
||||
__text_code_end__ = .;
|
||||
} > xip_memory
|
||||
|
||||
. = ALIGN(4);
|
||||
__itcm_load_addr = .;
|
||||
|
||||
.itcm_region : AT (__itcm_load_addr)
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__tcm_code_start__ = .;
|
||||
|
||||
*(.tcm_code)
|
||||
*(.tcm_const)
|
||||
*(.sclock_rlt_code)
|
||||
*(.sclock_rlt_const)
|
||||
|
||||
*bl702_glb.o*(.rodata*)
|
||||
*bl702_pds.o*(.rodata*)
|
||||
*bl702_common.o*(.rodata*)
|
||||
*bl702_sf_cfg.o*(.rodata*)
|
||||
*bl702_sf_ctrl.o*(.rodata*)
|
||||
*bl702_sflash.o*(.rodata*)
|
||||
*bl702_xip_sflash.o*(.rodata*)
|
||||
*bl702_ef_ctrl.o*(.rodata*)
|
||||
|
||||
. = ALIGN(4);
|
||||
__tcm_code_end__ = .;
|
||||
} > itcm_memory
|
||||
|
||||
__dtcm_load_addr = __itcm_load_addr + SIZEOF(.itcm_region);
|
||||
|
||||
.dtcm_region : AT (__dtcm_load_addr)
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__tcm_data_start__ = .;
|
||||
|
||||
*(.tcm_data)
|
||||
/* *finger_print.o(.data*) */
|
||||
|
||||
. = ALIGN(4);
|
||||
__tcm_data_end__ = .;
|
||||
} > dtcm_memory
|
||||
|
||||
/* .heap_dummy section doesn't contains any symbols. It is only
|
||||
* used for linker to calculate size of heap sections, and assign
|
||||
* values to heap symbols later */
|
||||
.heap_dummy (NOLOAD):
|
||||
{
|
||||
. = ALIGN(0x4);
|
||||
. = . + HeapSize;
|
||||
. = ALIGN(0x4);
|
||||
} > dtcm_memory
|
||||
|
||||
_HeapBase = ORIGIN(dtcm_memory) + LENGTH(dtcm_memory) - StackSize - HeapSize;
|
||||
_HeapSize = HeapSize;
|
||||
|
||||
/* Check if data + heap + stack exceeds RAM limit */
|
||||
ASSERT(_HeapBase >= __tcm_data_end__, "region RAM overflowed with stack")
|
||||
|
||||
/*************************************************************************/
|
||||
/* .stack_dummy section doesn't contains any symbols. It is only
|
||||
* used for linker to calculate size of stack sections, and assign
|
||||
* values to stack symbols later */
|
||||
.stack_dummy (NOLOAD):
|
||||
{
|
||||
. = ALIGN(0x4);
|
||||
. = . + StackSize;
|
||||
. = ALIGN(0x4);
|
||||
} > dtcm_memory
|
||||
|
||||
/* Set stack top to end of RAM, and stack limit move down by
|
||||
* size of stack_dummy section */
|
||||
__StackTop = ORIGIN(dtcm_memory) + LENGTH(dtcm_memory);
|
||||
PROVIDE( __freertos_irq_stack_top = __StackTop);
|
||||
__StackLimit = __StackTop - SIZEOF(.stack_dummy);
|
||||
|
||||
/* Check if data + heap + stack exceeds RAM limit */
|
||||
ASSERT(__StackLimit >= __tcm_data_end__, "region RAM overflowed with stack")
|
||||
/*************************************************************************/
|
||||
|
||||
__system_ram_load_addr = __dtcm_load_addr + SIZEOF(.dtcm_region);
|
||||
|
||||
.system_ram_data_region : AT (__system_ram_load_addr)
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__system_ram_data_start__ = .;
|
||||
|
||||
*(.system_ram)
|
||||
|
||||
. = ALIGN(4);
|
||||
__system_ram_data_end__ = .;
|
||||
} > ram_memory
|
||||
|
||||
__ram_load_addr = __system_ram_load_addr + SIZEOF(.system_ram_data_region);
|
||||
|
||||
/* Data section */
|
||||
RAM_DATA : AT (__ram_load_addr)
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__ram_data_start__ = .;
|
||||
|
||||
PROVIDE( __global_pointer$ = . + 0x800 );
|
||||
|
||||
*(.data)
|
||||
*(.data.*)
|
||||
*(.sdata)
|
||||
*(.sdata.*)
|
||||
*(.sdata2)
|
||||
*(.sdata2.*)
|
||||
|
||||
. = ALIGN(4);
|
||||
__ram_data_end__ = .;
|
||||
} > ram_memory
|
||||
|
||||
.bss (NOLOAD) :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__bss_start__ = .;
|
||||
|
||||
*(.bss*)
|
||||
*(.sbss*)
|
||||
*(COMMON)
|
||||
|
||||
. = ALIGN(4);
|
||||
__bss_end__ = .;
|
||||
} > ram_memory
|
||||
|
||||
.noinit_data (NOLOAD) :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__noinit_data_start__ = .;
|
||||
|
||||
*(.noinit_data*)
|
||||
|
||||
. = ALIGN(4);
|
||||
__noinit_data_end__ = .;
|
||||
} > ram_memory
|
||||
|
||||
.heap (NOLOAD):
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__HeapBase = .;
|
||||
|
||||
/*__end__ = .;*/
|
||||
/*end = __end__;*/
|
||||
KEEP(*(.heap*))
|
||||
|
||||
. = ALIGN(4);
|
||||
__HeapLimit = .;
|
||||
} > ram_memory
|
||||
__HeapLimit = ORIGIN(ram_memory) + LENGTH(ram_memory);
|
||||
|
||||
}
|
||||
|
66
examples/dac/dac_mono_play_form_flash/main.c
Normal file
66
examples/dac/dac_mono_play_form_flash/main.c
Normal file
@ -0,0 +1,66 @@
|
||||
/**
|
||||
* @file main.c
|
||||
* @brief
|
||||
*
|
||||
* Copyright (c) 2021 Bouffalolab team
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
#include "hal_dac.h"
|
||||
#include "hal_dma.h"
|
||||
#include "zfb_16.h"
|
||||
int main(void)
|
||||
{
|
||||
bflb_platform_init(0);
|
||||
|
||||
/* register & open dac device */
|
||||
dac_register(DAC0_INDEX, "dac", DEVICE_OFLAG_RDWR);
|
||||
struct device *dac = device_find("dac");
|
||||
|
||||
if (dac)
|
||||
{
|
||||
((dac_device_t *)dac)->clk = DAC_CLK_16KHZ;
|
||||
device_open(dac, DEVICE_OFLAG_DMA_TX);
|
||||
MSG("device open success\r\n");
|
||||
}
|
||||
|
||||
/* register & open dma device */
|
||||
if(dma_allocate_register("dac_dma",DEVICE_OFLAG_RDWR) == SUCCESS){
|
||||
MSG("dma allocate success\r\n");
|
||||
}
|
||||
|
||||
struct device *dac_dma = device_find("dac_dma");
|
||||
|
||||
if(dac_dma){
|
||||
|
||||
((dma_device_t *) dac_dma)->direction = DMA_MEMORY_TO_PERIPH;
|
||||
((dma_device_t *) dac_dma)->transfer_mode = DMA_LLI_ONCE_MODE;
|
||||
((dma_device_t *) dac_dma)->src_req = DMA_REQUEST_NONE;
|
||||
((dma_device_t *) dac_dma)->dst_req = DMA_REQUEST_DAC0;
|
||||
((dma_device_t *) dac_dma)->src_width = DMA_TRANSFER_WIDTH_16BIT;
|
||||
((dma_device_t *) dac_dma)->dst_width = DMA_TRANSFER_WIDTH_16BIT;
|
||||
|
||||
device_open(dac_dma,0);
|
||||
}
|
||||
|
||||
/* connect dac device and dma device */
|
||||
device_control(dac,DEVICE_CTRL_ATTACH_TX_DMA,dac_dma);
|
||||
|
||||
device_write(dac,DAC_CHANNEL_0,zfb_source,sizeof(zfb_source));
|
||||
|
||||
BL_CASE_SUCCESS;
|
||||
}
|
7037
examples/dac/dac_mono_play_form_flash/zfb_16.h
Normal file
7037
examples/dac/dac_mono_play_form_flash/zfb_16.h
Normal file
File diff suppressed because it is too large
Load Diff
6
examples/emac/emac_uip/CMakeLists.txt
Normal file
6
examples/emac/emac_uip/CMakeLists.txt
Normal file
@ -0,0 +1,6 @@
|
||||
set(mains emac_basic.c )
|
||||
set(TARGET_REQUIRED_SRCS emac_bd.c clock-arch.c tapdev.c timer.c uip.c uip_arp.c psock.c httpd.c httpd-cgi.c httpd-fs.c http-strings.c uip_main.c)
|
||||
generate_bin()
|
||||
|
||||
|
||||
|
49
examples/emac/emac_uip/clock-arch.c
Normal file
49
examples/emac/emac_uip/clock-arch.c
Normal file
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) 2006, Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the uIP TCP/IP stack
|
||||
*
|
||||
* $Id: clock-arch.c,v 1.2 2006/06/12 08:00:31 adam Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* Implementation of architecture-specific clock functionality
|
||||
* \author
|
||||
* Adam Dunkels <adam@sics.se>
|
||||
*/
|
||||
|
||||
#include "clock-arch.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
clock_time_t
|
||||
clock_time(void)
|
||||
{
|
||||
return bflb_platform_get_time_us() / 1000;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
40
examples/emac/emac_uip/clock-arch.h
Normal file
40
examples/emac/emac_uip/clock-arch.h
Normal file
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) 2006, Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the uIP TCP/IP stack
|
||||
*
|
||||
* $Id: clock-arch.h,v 1.2 2006/06/12 08:00:31 adam Exp $
|
||||
*/
|
||||
|
||||
#ifndef __CLOCK_ARCH_H__
|
||||
#define __CLOCK_ARCH_H__
|
||||
|
||||
typedef int clock_time_t;
|
||||
#define CLOCK_CONF_SECOND 1000
|
||||
|
||||
#endif /* __CLOCK_ARCH_H__ */
|
88
examples/emac/emac_uip/clock.h
Normal file
88
examples/emac/emac_uip/clock.h
Normal file
@ -0,0 +1,88 @@
|
||||
/**
|
||||
* \defgroup clock Clock interface
|
||||
*
|
||||
* The clock interface is the interface between the \ref timer "timer library"
|
||||
* and the platform specific clock functionality. The clock
|
||||
* interface must be implemented for each platform that uses the \ref
|
||||
* timer "timer library".
|
||||
*
|
||||
* The clock interface does only one this: it measures time. The clock
|
||||
* interface provides a macro, CLOCK_SECOND, which corresponds to one
|
||||
* second of system time.
|
||||
*
|
||||
* \sa \ref timer "Timer library"
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2004, Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the uIP TCP/IP stack
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: clock.h,v 1.3 2006/06/11 21:46:39 adam Exp $
|
||||
*/
|
||||
#ifndef __CLOCK_H__
|
||||
#define __CLOCK_H__
|
||||
|
||||
#include "clock-arch.h"
|
||||
|
||||
/**
|
||||
* Initialize the clock library.
|
||||
*
|
||||
* This function initializes the clock library and should be called
|
||||
* from the main() function of the system.
|
||||
*
|
||||
*/
|
||||
void clock_init(void);
|
||||
|
||||
/**
|
||||
* Get the current clock time.
|
||||
*
|
||||
* This function returns the current system clock time.
|
||||
*
|
||||
* \return The current clock time, measured in system ticks.
|
||||
*/
|
||||
clock_time_t clock_time(void);
|
||||
|
||||
/**
|
||||
* A second, measured in system clock time.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#ifdef CLOCK_CONF_SECOND
|
||||
#define CLOCK_SECOND CLOCK_CONF_SECOND
|
||||
#else
|
||||
#define CLOCK_SECOND (clock_time_t)32
|
||||
#endif
|
||||
|
||||
#endif /* __CLOCK_H__ */
|
||||
|
||||
/** @} */
|
376
examples/emac/emac_uip/emac_basic.c
Normal file
376
examples/emac/emac_uip/emac_basic.c
Normal file
@ -0,0 +1,376 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file emac_basic.c
|
||||
* @version V1.2
|
||||
* @date
|
||||
* @brief This file is the peripheral case c file
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT(c) 2018 Bouffalo Lab</center></h2>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of Bouffalo Lab nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include "bl702_common.h"
|
||||
#include "bl702_glb.h"
|
||||
#include "bl702_emac.h"
|
||||
#include "bflb_platform.h"
|
||||
#include "emac_bd.h"
|
||||
|
||||
/** @addtogroup BL702_Peripheral_Case
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup EMAC_BASIC
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup EMAC_BASIC_Private_Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define TEST_ROLE_UIP (0)
|
||||
#define TEST_ROLE_TX (1)
|
||||
#define TEST_ROLE_RX (2)
|
||||
#define TEST_ROLE_TX_RX (3)
|
||||
|
||||
#define EMAC_USE_INSIDE_CLOCK (0)
|
||||
#define EMAC_TEST_ROLE (TEST_ROLE_TX_RX)
|
||||
#define EMAC_TEST_INTERVAL (9)
|
||||
#define EMAC_TEST_TX_INTERVAL_US (3000)
|
||||
|
||||
/*@} end of group EMAC_BASIC_Private_Macros */
|
||||
|
||||
/** @defgroup EMAC_BASIC_Private_Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*@} end of group EMAC_BASIC_Private_Types */
|
||||
|
||||
/** @defgroup EMAC_BASIC_Private_Variables
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*@} end of group EMAC_BASIC_Private_Variables */
|
||||
|
||||
|
||||
/** @defgroup EMAC_BASIC_Global_Variables
|
||||
* @{
|
||||
*/
|
||||
EMAC_CFG_Type emacCfg={
|
||||
.recvSmallFrame=ENABLE, /*!< Receive small frmae or not */
|
||||
.recvHugeFrame=DISABLE, /*!< Receive huge frmae(>64K bytes) or not */
|
||||
.padEnable=ENABLE, /*!< Enable padding for frame which is less than MINFL or not */
|
||||
.crcEnable=ENABLE, /*!< Enable hardware CRC or not */
|
||||
.noPreamble=DISABLE, /*!< Enable preamble or not */
|
||||
.recvBroadCast=ENABLE, /*!< Receive broadcast frame or not */
|
||||
.interFrameGapCheck=ENABLE, /*!< Check inter frame gap or not */
|
||||
.miiNoPreamble=ENABLE, /*!< Enable MII interface preamble or not */
|
||||
.miiClkDiv=49, /*!< MII interface clock divider from bus clock */
|
||||
.maxTxRetry=16, /*!< Maximum tx retry count */
|
||||
.interFrameGapValue=24, /*!< Inter frame gap vaule in clock cycles(default 24)*/
|
||||
.minFrameLen=64, /*!< Minimum frame length */
|
||||
.maxFrameLen=1500, /*!< Maximum frame length */
|
||||
.collisionValid=16, /*!< Collision valid value */
|
||||
.macAddr[0]=0x18, /*!< MAC Address */
|
||||
.macAddr[1]=0xB0,
|
||||
.macAddr[2]=0x09,
|
||||
.macAddr[3]=0x00,
|
||||
.macAddr[4]=0x12,
|
||||
.macAddr[5]=0x34,
|
||||
};
|
||||
ETHPHY_CFG_Type phyCfg={
|
||||
.autoNegotiation=ENABLE, /*!< Speed and mode auto negotiation */
|
||||
.duplex=EMAC_MODE_FULLDUPLEX, /*!< Duplex mode */
|
||||
.speed=EMAC_SPEED_100M, /*!< Speed mode */
|
||||
.phyAddress=0x1, /*!< PHY address */
|
||||
};
|
||||
|
||||
#if (EMAC_TEST_ROLE & TEST_ROLE_TX)
|
||||
//00-E0-4C-68-00-B2
|
||||
//static const uint8_t test_framex[60] = {
|
||||
// 0x00,0xe0,0x4c,0x68,0x00,0xb2,0x18,0xb0,0x09,0x00,0x12,0x34,0x08,0x00,0x45,0x00,
|
||||
// 0x00,0x24,0x85,0x7b,0x00,0x00,0x80,0x11,0x00,0x00,0xa9,0xfe,0x19,0x6f,0xa9,0xfe,
|
||||
// 0xff,0xff,0xd5,0x04,0x05,0xfe,0x00,0x10,0x18,0xea,0x54,0x43,0x46,0x32,0x04,0x00,
|
||||
// 0x00,0x00
|
||||
//};
|
||||
static const uint8_t test_frame[42]={
|
||||
0x8c,0xec,0x4b,0x45,0x16,0xbc,0x18,0xB0,0x09,0x00,0x12,0x34,0x08,0x06,
|
||||
0x00,0x01,0x08,0x00,0x06,0x04,0x00,0x01,0x18,0xB0,0x09,0x00,0x12,0x34,
|
||||
0xC0,0xA8,0x0D,0x91,0x8c,0xec,0x4b,0x45,0x16,0xbc,0xa9,0xfe,0x0f,0xb3
|
||||
};
|
||||
#define TEST_PATTERN_LEN (ETH_MAX_PACKET_SIZE - 32)
|
||||
static uint8_t test_pattern[TEST_PATTERN_LEN] = {0};
|
||||
|
||||
static volatile uint32_t tx_pkg_cnt = 0;
|
||||
static volatile uint32_t tx_err_cnt = 0;
|
||||
#endif
|
||||
|
||||
#if (EMAC_TEST_ROLE & TEST_ROLE_RX)
|
||||
static volatile uint32_t rx_pkg_cnt = 0;
|
||||
static volatile uint32_t rx_err_cnt = 0;
|
||||
static volatile uint32_t rx_bytes = 0;
|
||||
#endif
|
||||
|
||||
#if (EMAC_TEST_ROLE & TEST_ROLE_RX) || (EMAC_TEST_ROLE & TEST_ROLE_TX)
|
||||
static uint32_t time = 0;
|
||||
static uint32_t last_time = 0;
|
||||
#endif
|
||||
|
||||
/*@} end of group EMAC_BASIC_Global_Variables */
|
||||
|
||||
/** @defgroup EMAC_BASIC_Private_Fun_Declaration
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*@} end of group EMAC_BASIC_Private_Fun_Declaration */
|
||||
|
||||
/** @defgroup EMAC_BASIC_Private_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
static void EMAC_GPIO_Init(void)
|
||||
{
|
||||
uint8_t emacPins[]={GLB_GPIO_PIN_0,GLB_GPIO_PIN_1,GLB_GPIO_PIN_2,
|
||||
GLB_GPIO_PIN_7,GLB_GPIO_PIN_8,
|
||||
GLB_GPIO_PIN_18,GLB_GPIO_PIN_19,GLB_GPIO_PIN_20,GLB_GPIO_PIN_21,GLB_GPIO_PIN_22};
|
||||
|
||||
GLB_SWAP_EMAC_CAM_Pin(GLB_EMAC_CAM_PIN_EMAC);
|
||||
|
||||
GLB_GPIO_Func_Init(GPIO_FUN_ETHER_MAC,(GLB_GPIO_Type *)emacPins,sizeof(emacPins));
|
||||
}
|
||||
|
||||
static void EMAC_TX_Done_Callback(void)
|
||||
{
|
||||
uint32_t index = 0;
|
||||
|
||||
index = EMAC_BD_Get_CurActive(EMAC_BD_TYPE_TX);
|
||||
|
||||
#if (EMAC_TEST_ROLE & TEST_ROLE_TX)
|
||||
tx_pkg_cnt ++;
|
||||
#endif
|
||||
|
||||
EMAC_BD_TX_dequeue(index);
|
||||
}
|
||||
|
||||
static void EMAC_TX_Error_Callback(void)
|
||||
{
|
||||
uint32_t index = 0;
|
||||
|
||||
#if (EMAC_TEST_ROLE & TEST_ROLE_TX)
|
||||
tx_err_cnt ++;
|
||||
#endif
|
||||
|
||||
index = EMAC_BD_Get_CurActive(EMAC_BD_TYPE_TX);
|
||||
|
||||
EMAC_BD_TX_onErr(index);
|
||||
}
|
||||
|
||||
static void EMAC_RX_Done_Callback(void)
|
||||
{
|
||||
uint32_t index = 0;
|
||||
|
||||
index = EMAC_BD_Get_CurActive(EMAC_BD_TYPE_RX);
|
||||
|
||||
EMAC_BD_RX_enqueue(index);
|
||||
}
|
||||
|
||||
static void EMAC_RX_Error_Callback(void)
|
||||
{
|
||||
uint32_t index;
|
||||
|
||||
index = EMAC_BD_Get_CurActive(EMAC_BD_TYPE_RX);
|
||||
|
||||
#if (EMAC_TEST_ROLE & TEST_ROLE_RX)
|
||||
rx_err_cnt ++;
|
||||
#endif
|
||||
|
||||
EMAC_BD_RX_onErr(index);
|
||||
}
|
||||
|
||||
static void EMAC_RX_Busy_Callback(void)
|
||||
{
|
||||
MSG("%s:%d\r\n", __func__, __LINE__);
|
||||
}
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief EMAC basic case funtion
|
||||
*
|
||||
* @param EMACId: EMAC ID type
|
||||
* @param EMACCfg: EMAC configuration struct pointer
|
||||
*
|
||||
* @return SUCCESS or ERROR
|
||||
*
|
||||
*******************************************************************************/
|
||||
static BL_Err_Type EMAC_Basic_Case()
|
||||
{
|
||||
BL_Err_Type err = SUCCESS;
|
||||
#if (EMAC_TEST_ROLE & TEST_ROLE_RX)
|
||||
uint32_t rx_len = 0;
|
||||
#endif
|
||||
|
||||
#if EMAC_USE_INSIDE_CLOCK
|
||||
//enable audio clock */
|
||||
PDS_Enable_PLL_Clk(PDS_PLL_CLK_48M);
|
||||
PDS_Set_Audio_PLL_Freq(AUDIO_PLL_50000000_HZ);
|
||||
|
||||
GLB_Set_ETH_REF_O_CLK_Sel(GLB_ETH_REF_CLK_OUT_INSIDE_50M);
|
||||
#else
|
||||
GLB_Set_ETH_REF_O_CLK_Sel(GLB_ETH_REF_CLK_OUT_OUTSIDE_50M);
|
||||
#endif
|
||||
GLB_AHB_Slave1_Clock_Gate(DISABLE,BL_AHB_SLAVE1_EMAC);
|
||||
//GLB_Invert_ETH_RX_CLK(0);
|
||||
//GLB_Invert_ETH_TX_CLK(0);
|
||||
EMAC_Init(&emacCfg);
|
||||
err=EMAC_PhyInit(&phyCfg);
|
||||
if(TIMEOUT==err){
|
||||
MSG("PHY Init timeout\r\n");
|
||||
while(1);
|
||||
}
|
||||
if(ERROR==err){
|
||||
MSG("PHY Init error\r\n");
|
||||
while(1);
|
||||
}
|
||||
if(phyCfg.duplex==EMAC_MODE_FULLDUPLEX){
|
||||
MSG("EMAC_MODE_FULLDUPLEX\r\n");
|
||||
}else{
|
||||
MSG("EMAC_MODE_HALFDUPLEX\r\n");
|
||||
}
|
||||
if(phyCfg.speed==EMAC_SPEED_100M){
|
||||
MSG("EMAC_SPEED_100M\r\n");
|
||||
}else{
|
||||
MSG("EMAC_SPEED_50M\r\n");
|
||||
}
|
||||
MSG("PHY Init done\r\n");
|
||||
|
||||
EMAC_BD_Init();
|
||||
|
||||
EMAC_Int_Callback_Install(EMAC_INT_TX_DONE_IDX, EMAC_TX_Done_Callback);
|
||||
EMAC_Int_Callback_Install(EMAC_INT_TX_ERROR_IDX, EMAC_TX_Error_Callback);
|
||||
|
||||
EMAC_Int_Callback_Install(EMAC_INT_RX_DONE_IDX, EMAC_RX_Done_Callback);
|
||||
EMAC_Int_Callback_Install(EMAC_INT_RX_ERROR_IDX, EMAC_RX_Error_Callback);
|
||||
|
||||
EMAC_Int_Callback_Install(EMAC_INT_RX_BUSY_IDX, EMAC_RX_Busy_Callback);
|
||||
|
||||
NVIC_EnableIRQ(EMAC_IRQn);
|
||||
|
||||
EMAC_ClrIntStatus(EMAC_INT_ALL);
|
||||
EMAC_IntMask(EMAC_INT_ALL, UNMASK);
|
||||
#if (EMAC_TEST_ROLE == TEST_ROLE_TX)
|
||||
EMAC_IntMask(EMAC_INT_RX_BUSY, MASK);
|
||||
#endif
|
||||
__enable_irq();
|
||||
EMAC_Enable();
|
||||
|
||||
#if EMAC_TEST_ROLE == TEST_ROLE_UIP
|
||||
uip_main();
|
||||
#endif
|
||||
|
||||
#if (EMAC_TEST_ROLE & TEST_ROLE_RX) || (EMAC_TEST_ROLE & TEST_ROLE_TX)
|
||||
bflb_platform_init_time();
|
||||
bflb_platform_start_time();
|
||||
#endif
|
||||
|
||||
#if (EMAC_TEST_ROLE & TEST_ROLE_TX)
|
||||
memset(test_pattern, 0x5a, TEST_PATTERN_LEN);
|
||||
memcpy(test_pattern, test_frame, sizeof(test_frame));
|
||||
#endif
|
||||
|
||||
while(1) {
|
||||
#if (EMAC_TEST_ROLE & TEST_ROLE_TX)
|
||||
EMAC_BD_TX_enqueue(-1, sizeof(test_frame), test_pattern);
|
||||
//BL702_Delay_US(EMAC_TEST_TX_INTERVAL_US);
|
||||
#endif
|
||||
|
||||
#if (EMAC_TEST_ROLE & TEST_ROLE_RX)
|
||||
EMAC_BD_RX_dequeue(-1, &rx_len, NULL);
|
||||
if (rx_len) {
|
||||
rx_pkg_cnt ++;
|
||||
rx_bytes += rx_len;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (EMAC_TEST_ROLE & TEST_ROLE_RX) || (EMAC_TEST_ROLE & TEST_ROLE_TX)
|
||||
time = bflb_platform_get_time_ms() /1000;
|
||||
if ((time - last_time) > EMAC_TEST_INTERVAL) {
|
||||
last_time = time;
|
||||
#if (EMAC_TEST_ROLE & TEST_ROLE_TX)
|
||||
MSG("tx: %d, err: %d\n\r", tx_pkg_cnt, tx_err_cnt);
|
||||
#endif
|
||||
#if (EMAC_TEST_ROLE & TEST_ROLE_RX)
|
||||
MSG("rx: %d, err: %d, bytes: %d\n\r", rx_pkg_cnt, rx_err_cnt, rx_bytes);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* more time slice for RX */
|
||||
#if (EMAC_TEST_ROLE & TEST_ROLE_RX)
|
||||
EMAC_BD_RX_dequeue(-1, &rx_len, NULL);
|
||||
if (rx_len) {
|
||||
rx_pkg_cnt ++;
|
||||
rx_bytes += rx_len;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/*@} end of group EMAC_BASIC_Private_Functions */
|
||||
|
||||
/** @defgroup EMAC_BASIC_Public_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief EMAC basic case main function
|
||||
*
|
||||
* @param None
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************/
|
||||
int main(void)
|
||||
{
|
||||
GLB_Set_System_CLK(GLB_DLL_XTAL_32M,GLB_SYS_CLK_DLL144M);
|
||||
|
||||
bflb_platform_init(0);
|
||||
MSG("EMAC basic test\n");
|
||||
|
||||
EMAC_GPIO_Init();
|
||||
|
||||
EMAC_Basic_Case();
|
||||
|
||||
BL_CASE_SUCCESS;
|
||||
}
|
||||
|
||||
/*@} end of group EMAC_BASIC_Public_Functions */
|
||||
|
||||
/*@} end of group EMAC_BASIC */
|
||||
|
||||
/*@} end of group BL70X_Peripheral_Case */
|
196
examples/emac/emac_uip/emac_bd.c
Normal file
196
examples/emac/emac_uip/emac_bd.c
Normal file
@ -0,0 +1,196 @@
|
||||
#include "bl702_common.h"
|
||||
#include "bl702_glb.h"
|
||||
#include "bl702_emac.h"
|
||||
#include "bflb_platform.h"
|
||||
#include "emac_reg.h"
|
||||
|
||||
#include "emac_bd.h"
|
||||
|
||||
#define TAG "EMAC_BD: "
|
||||
|
||||
#define ETH_RXBUFNB 5
|
||||
#define ETH_TXBUFNB 3
|
||||
|
||||
EMAC_Handle_Type ethHandle;
|
||||
static EMAC_Handle_Type *thiz = NULL;
|
||||
|
||||
uint8_t ethRxBuff[ETH_RXBUFNB][ETH_MAX_PACKET_SIZE] __attribute__ ((align(4)))={0}; /* Ethernet Receive Buffers */
|
||||
uint8_t ethTxBuff[ETH_TXBUFNB][ETH_MAX_PACKET_SIZE] __attribute__ ((align(4))); /* Ethernet Transmit Buffers */
|
||||
|
||||
BL_Err_Type EMAC_BD_Init(void)
|
||||
{
|
||||
BL_Err_Type err = SUCCESS;
|
||||
thiz = ðHandle;
|
||||
|
||||
/* init the BDs in emac with buffer address */
|
||||
err = EMAC_DMADescListInit(thiz, (uint8_t *)ethTxBuff, ETH_TXBUFNB, (uint8_t *)ethRxBuff, ETH_RXBUFNB);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
BL_Err_Type EMAC_BD_TX_enqueue(uint32_t flags, uint32_t len, const uint8_t *data_in)
|
||||
{
|
||||
BL_Err_Type err = SUCCESS;
|
||||
EMAC_BD_Desc_Type *DMADesc;
|
||||
|
||||
DMADesc = &thiz->bd[thiz->txIndexCPU];
|
||||
|
||||
if ((uint32_t)(-1) == flags) {
|
||||
flags = EMAC_TX_COMMON_FLAGS;
|
||||
}
|
||||
|
||||
if(DMADesc->C_S_L & EMAC_BD_FIELD_MSK(TX_RD)){
|
||||
/* no free BD, lost sync with DMA TX? */
|
||||
err = NORESC;
|
||||
//MSG_ERR(TAG"%s:%d\n", __func__, __LINE__);
|
||||
}else{
|
||||
//DMADesc->TXBuffer = (uint32_t)data_in;
|
||||
ARCH_MemCpy_Fast((void *)DMADesc->Buffer, data_in, len);
|
||||
|
||||
DMADesc->C_S_L = flags | (len << BD_TX_LEN_POS);
|
||||
/* move to next TX BD */
|
||||
if ((++thiz->txIndexCPU) > thiz->txBuffLimit) {
|
||||
/* the last BD */
|
||||
DMADesc->C_S_L |= EMAC_BD_FIELD_MSK(TX_WR);
|
||||
/* wrap back */
|
||||
thiz->txIndexCPU = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
/* this func will be called in ISR */
|
||||
BL_Err_Type EMAC_BD_TX_dequeue(uint32_t index)
|
||||
{
|
||||
BL_Err_Type err = SUCCESS;
|
||||
EMAC_BD_Desc_Type *DMADesc;
|
||||
|
||||
thiz->txIndexEMAC = index;
|
||||
DMADesc = &thiz->bd[thiz->txIndexEMAC];
|
||||
/* release this tx BD to SW (HW will do this) */
|
||||
DMADesc->C_S_L &= EMAC_BD_FIELD_UMSK(TX_RD);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
void EMAC_BD_TX_onErr(uint32_t index)
|
||||
{
|
||||
/* handle error */
|
||||
if (thiz->bd[index].C_S_L & EMAC_BD_FIELD_MSK(TX_UR)) {
|
||||
MSG("%s:%d\r\n", __func__, __LINE__);
|
||||
}
|
||||
|
||||
if (thiz->bd[index].C_S_L & EMAC_BD_FIELD_MSK(TX_RTRY)) {
|
||||
MSG("%s:%d\r\n", __func__, __LINE__);
|
||||
}
|
||||
|
||||
if (thiz->bd[index].C_S_L & EMAC_BD_FIELD_MSK(TX_RL)) {
|
||||
MSG("%s:%d\r\n", __func__, __LINE__);
|
||||
}
|
||||
|
||||
if (thiz->bd[index].C_S_L & EMAC_BD_FIELD_MSK(TX_LC)) {
|
||||
MSG("%s:%d\r\n", __func__, __LINE__);
|
||||
}
|
||||
|
||||
if (thiz->bd[index].C_S_L & EMAC_BD_FIELD_MSK(TX_DF)) {
|
||||
MSG("%s:%d\r\n", __func__, __LINE__);
|
||||
}
|
||||
|
||||
if (thiz->bd[index].C_S_L & EMAC_BD_FIELD_MSK(TX_CS)) {
|
||||
MSG("%s:%d\r\n", __func__, __LINE__);
|
||||
}
|
||||
|
||||
thiz->bd[index].C_S_L &= ~0xff;
|
||||
}
|
||||
|
||||
BL_Err_Type EMAC_BD_RX_enqueue(uint32_t index)
|
||||
{
|
||||
BL_Err_Type err = SUCCESS;
|
||||
|
||||
thiz->rxIndexEMAC = index;
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
BL_Err_Type EMAC_BD_RX_dequeue(uint32_t flags, uint32_t *len, uint8_t *data_out)
|
||||
{
|
||||
BL_Err_Type err = SUCCESS;
|
||||
EMAC_BD_Desc_Type *DMADesc;
|
||||
|
||||
DMADesc = &thiz->bd[thiz->rxIndexCPU];
|
||||
|
||||
if(DMADesc->C_S_L & EMAC_BD_FIELD_MSK(RX_E)){
|
||||
/* current RX BD is empty */
|
||||
err = NORESC;
|
||||
*len = 0;
|
||||
//MSG_ERR(TAG"%s:%d\n", __func__, __LINE__);
|
||||
}else{
|
||||
*len = (thiz->bd[thiz->rxIndexCPU].C_S_L & EMAC_BD_FIELD_MSK(RX_LEN)) >> BD_RX_LEN_POS;
|
||||
if (data_out) {
|
||||
ARCH_MemCpy_Fast(data_out, (const void *)DMADesc->Buffer, *len);
|
||||
}
|
||||
/* RX BD can be used for another receive */
|
||||
DMADesc->C_S_L |= EMAC_BD_FIELD_MSK(RX_E);
|
||||
/* move to next RX BD */
|
||||
if ((++thiz->rxIndexCPU) > thiz->rxBuffLimit) {
|
||||
/* the last BD */
|
||||
DMADesc->C_S_L |= EMAC_BD_FIELD_MSK(RX_WR);
|
||||
/* wrap back */
|
||||
thiz->rxIndexCPU = thiz->txBuffLimit + 1;
|
||||
}
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
void EMAC_BD_RX_onErr(uint32_t index)
|
||||
{
|
||||
/* handle error */
|
||||
if (thiz->bd[index].C_S_L & EMAC_BD_FIELD_MSK(RX_OR)) {
|
||||
MSG("%s:%d\r\n", __func__, __LINE__);
|
||||
}
|
||||
|
||||
if (thiz->bd[index].C_S_L & EMAC_BD_FIELD_MSK(RX_RE)) {
|
||||
MSG("%s:%d\r\n", __func__, __LINE__);
|
||||
}
|
||||
|
||||
if (thiz->bd[index].C_S_L & EMAC_BD_FIELD_MSK(RX_DN)) {
|
||||
MSG("%s:%d\r\n", __func__, __LINE__);
|
||||
}
|
||||
|
||||
if (thiz->bd[index].C_S_L & EMAC_BD_FIELD_MSK(RX_TL)) {
|
||||
MSG("%s:%d\r\n", __func__, __LINE__);
|
||||
}
|
||||
|
||||
if (thiz->bd[index].C_S_L & EMAC_BD_FIELD_MSK(RX_CRC)) {
|
||||
MSG("%s:%d\r\n", __func__, __LINE__);
|
||||
}
|
||||
|
||||
if (thiz->bd[index].C_S_L & EMAC_BD_FIELD_MSK(RX_LC)) {
|
||||
MSG("%s:%d\r\n", __func__, __LINE__);
|
||||
}
|
||||
|
||||
thiz->bd[index].C_S_L &= ~0xff;
|
||||
/* RX BD is ready for RX */
|
||||
thiz->bd[index].C_S_L |= EMAC_BD_FIELD_MSK(RX_E);
|
||||
}
|
||||
|
||||
uint32_t EMAC_BD_Get_CurActive(EMAC_BD_TYPE_e bdt)
|
||||
{
|
||||
uint32_t bd = 0;
|
||||
|
||||
bd = BL_RD_REG(EMAC_BASE, EMAC_TX_BD_NUM);
|
||||
|
||||
if (bdt == EMAC_BD_TYPE_TX) {
|
||||
bd &= EMAC_TXBDPTR_MSK;
|
||||
bd >>= EMAC_TXBDPTR_POS;
|
||||
}
|
||||
|
||||
if (bdt == EMAC_BD_TYPE_RX) {
|
||||
bd &= EMAC_RXBDPTR_MSK;
|
||||
bd >>= EMAC_RXBDPTR_POS;
|
||||
}
|
||||
|
||||
return bd;
|
||||
}
|
29
examples/emac/emac_uip/emac_bd.h
Normal file
29
examples/emac/emac_uip/emac_bd.h
Normal file
@ -0,0 +1,29 @@
|
||||
#ifndef _EMAC_BD_H_
|
||||
#define _EMAC_BD_H_
|
||||
|
||||
#define EMAC_TX_COMMON_FLAGS (EMAC_BD_FIELD_MSK(TX_RD) | \
|
||||
EMAC_BD_FIELD_MSK(TX_IRQ) | \
|
||||
EMAC_BD_FIELD_MSK(TX_PAD) | \
|
||||
EMAC_BD_FIELD_MSK(TX_CRC) )
|
||||
|
||||
#define EMAC_RX_COMMON_FLAGS (ETH_MAX_PACKET_SIZE << 16) | \
|
||||
EMAC_BD_FIELD_MSK(RX_IRQ) )
|
||||
|
||||
typedef enum _BD_TYPE_ {
|
||||
EMAC_BD_TYPE_INVLAID,
|
||||
EMAC_BD_TYPE_TX,
|
||||
EMAC_BD_TYPE_RX,
|
||||
EMAC_BD_TYPE_NONE,
|
||||
EMAC_BD_TYPE_MAX = 0x7FFFFFFF
|
||||
} EMAC_BD_TYPE_e;
|
||||
|
||||
BL_Err_Type EMAC_BD_Init(void);
|
||||
BL_Err_Type EMAC_BD_TX_enqueue(uint32_t flags, uint32_t len, const uint8_t *data_in);
|
||||
BL_Err_Type EMAC_BD_TX_dequeue(uint32_t index);
|
||||
void EMAC_BD_TX_onErr(uint32_t index);
|
||||
BL_Err_Type EMAC_BD_RX_enqueue(uint32_t index);
|
||||
BL_Err_Type EMAC_BD_RX_dequeue(uint32_t flags, uint32_t *len, uint8_t *data_out);
|
||||
void EMAC_BD_RX_onErr(uint32_t index);
|
||||
uint32_t EMAC_BD_Get_CurActive(EMAC_BD_TYPE_e bdt);
|
||||
|
||||
#endif
|
102
examples/emac/emac_uip/http-strings.c
Normal file
102
examples/emac/emac_uip/http-strings.c
Normal file
@ -0,0 +1,102 @@
|
||||
const char http_http[8] =
|
||||
/* "http://" */
|
||||
{0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, };
|
||||
const char http_200[5] =
|
||||
/* "200 " */
|
||||
{0x32, 0x30, 0x30, 0x20, };
|
||||
const char http_301[5] =
|
||||
/* "301 " */
|
||||
{0x33, 0x30, 0x31, 0x20, };
|
||||
const char http_302[5] =
|
||||
/* "302 " */
|
||||
{0x33, 0x30, 0x32, 0x20, };
|
||||
const char http_get[5] =
|
||||
/* "GET " */
|
||||
{0x47, 0x45, 0x54, 0x20, };
|
||||
const char http_10[9] =
|
||||
/* "HTTP/1.0" */
|
||||
{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, };
|
||||
const char http_11[9] =
|
||||
/* "HTTP/1.1" */
|
||||
{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x31, };
|
||||
const char http_content_type[15] =
|
||||
/* "content-type: " */
|
||||
{0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, };
|
||||
const char http_texthtml[10] =
|
||||
/* "text/html" */
|
||||
{0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, };
|
||||
const char http_location[11] =
|
||||
/* "location: " */
|
||||
{0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, };
|
||||
const char http_host[7] =
|
||||
/* "host: " */
|
||||
{0x68, 0x6f, 0x73, 0x74, 0x3a, 0x20, };
|
||||
const char http_crnl[3] =
|
||||
/* "\r\n" */
|
||||
{0xd, 0xa, };
|
||||
const char http_index_html[12] =
|
||||
/* "/index.html" */
|
||||
{0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x6c, };
|
||||
const char http_404_html[10] =
|
||||
/* "/404.html" */
|
||||
{0x2f, 0x34, 0x30, 0x34, 0x2e, 0x68, 0x74, 0x6d, 0x6c, };
|
||||
const char http_referer[9] =
|
||||
/* "Referer:" */
|
||||
{0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x72, 0x3a, };
|
||||
const char http_header_200[84] =
|
||||
/* "HTTP/1.0 200 OK\r\nServer: uIP/1.0 http://www.sics.se/~adam/uip/\r\nConnection: close\r\n" */
|
||||
{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32, 0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x3a, 0x20, 0x75, 0x49, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x69, 0x63, 0x73, 0x2e, 0x73, 0x65, 0x2f, 0x7e, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x75, 0x69, 0x70, 0x2f, 0xd, 0xa, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0xd, 0xa, };
|
||||
const char http_header_404[91] =
|
||||
/* "HTTP/1.0 404 Not found\r\nServer: uIP/1.0 http://www.sics.se/~adam/uip/\r\nConnection: close\r\n" */
|
||||
{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x34, 0x30, 0x34, 0x20, 0x4e, 0x6f, 0x74, 0x20, 0x66, 0x6f, 0x75, 0x6e, 0x64, 0xd, 0xa, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x3a, 0x20, 0x75, 0x49, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x69, 0x63, 0x73, 0x2e, 0x73, 0x65, 0x2f, 0x7e, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x75, 0x69, 0x70, 0x2f, 0xd, 0xa, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0xd, 0xa, };
|
||||
const char http_content_type_plain[29] =
|
||||
/* "Content-type: text/plain\r\n\r\n" */
|
||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x70, 0x6c, 0x61, 0x69, 0x6e, 0xd, 0xa, 0xd, 0xa, };
|
||||
const char http_content_type_html[28] =
|
||||
/* "Content-type: text/html\r\n\r\n" */
|
||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0xd, 0xa, 0xd, 0xa, };
|
||||
const char http_content_type_css [27] =
|
||||
/* "Content-type: text/css\r\n\r\n" */
|
||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x63, 0x73, 0x73, 0xd, 0xa, 0xd, 0xa, };
|
||||
const char http_content_type_text[28] =
|
||||
/* "Content-type: text/text\r\n\r\n" */
|
||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x74, 0x65, 0x78, 0x74, 0xd, 0xa, 0xd, 0xa, };
|
||||
const char http_content_type_png [28] =
|
||||
/* "Content-type: image/png\r\n\r\n" */
|
||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x70, 0x6e, 0x67, 0xd, 0xa, 0xd, 0xa, };
|
||||
const char http_content_type_gif [28] =
|
||||
/* "Content-type: image/gif\r\n\r\n" */
|
||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x67, 0x69, 0x66, 0xd, 0xa, 0xd, 0xa, };
|
||||
const char http_content_type_jpg [29] =
|
||||
/* "Content-type: image/jpeg\r\n\r\n" */
|
||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x6a, 0x70, 0x65, 0x67, 0xd, 0xa, 0xd, 0xa, };
|
||||
const char http_content_type_binary[43] =
|
||||
/* "Content-type: application/octet-stream\r\n\r\n" */
|
||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x6f, 0x63, 0x74, 0x65, 0x74, 0x2d, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0xd, 0xa, 0xd, 0xa, };
|
||||
const char http_html[6] =
|
||||
/* ".html" */
|
||||
{0x2e, 0x68, 0x74, 0x6d, 0x6c, };
|
||||
const char http_shtml[7] =
|
||||
/* ".shtml" */
|
||||
{0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, };
|
||||
const char http_htm[5] =
|
||||
/* ".htm" */
|
||||
{0x2e, 0x68, 0x74, 0x6d, };
|
||||
const char http_css[5] =
|
||||
/* ".css" */
|
||||
{0x2e, 0x63, 0x73, 0x73, };
|
||||
const char http_png[5] =
|
||||
/* ".png" */
|
||||
{0x2e, 0x70, 0x6e, 0x67, };
|
||||
const char http_gif[5] =
|
||||
/* ".gif" */
|
||||
{0x2e, 0x67, 0x69, 0x66, };
|
||||
const char http_jpg[5] =
|
||||
/* ".jpg" */
|
||||
{0x2e, 0x6a, 0x70, 0x67, };
|
||||
const char http_text[5] =
|
||||
/* ".txt" */
|
||||
{0x2e, 0x74, 0x78, 0x74, };
|
||||
const char http_txt[5] =
|
||||
/* ".txt" */
|
||||
{0x2e, 0x74, 0x78, 0x74, };
|
34
examples/emac/emac_uip/http-strings.h
Normal file
34
examples/emac/emac_uip/http-strings.h
Normal file
@ -0,0 +1,34 @@
|
||||
extern const char http_http[8];
|
||||
extern const char http_200[5];
|
||||
extern const char http_301[5];
|
||||
extern const char http_302[5];
|
||||
extern const char http_get[5];
|
||||
extern const char http_10[9];
|
||||
extern const char http_11[9];
|
||||
extern const char http_content_type[15];
|
||||
extern const char http_texthtml[10];
|
||||
extern const char http_location[11];
|
||||
extern const char http_host[7];
|
||||
extern const char http_crnl[3];
|
||||
extern const char http_index_html[12];
|
||||
extern const char http_404_html[10];
|
||||
extern const char http_referer[9];
|
||||
extern const char http_header_200[84];
|
||||
extern const char http_header_404[91];
|
||||
extern const char http_content_type_plain[29];
|
||||
extern const char http_content_type_html[28];
|
||||
extern const char http_content_type_css [27];
|
||||
extern const char http_content_type_text[28];
|
||||
extern const char http_content_type_png [28];
|
||||
extern const char http_content_type_gif [28];
|
||||
extern const char http_content_type_jpg [29];
|
||||
extern const char http_content_type_binary[43];
|
||||
extern const char http_html[6];
|
||||
extern const char http_shtml[7];
|
||||
extern const char http_htm[5];
|
||||
extern const char http_css[5];
|
||||
extern const char http_png[5];
|
||||
extern const char http_gif[5];
|
||||
extern const char http_jpg[5];
|
||||
extern const char http_text[5];
|
||||
extern const char http_txt[5];
|
203
examples/emac/emac_uip/httpd-cgi.c
Normal file
203
examples/emac/emac_uip/httpd-cgi.c
Normal file
@ -0,0 +1,203 @@
|
||||
/**
|
||||
* \addtogroup httpd
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* Web server script interface
|
||||
* \author
|
||||
* Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2006, Adam Dunkels.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the uIP TCP/IP stack.
|
||||
*
|
||||
* $Id: httpd-cgi.c,v 1.2 2006/06/11 21:46:37 adam Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
#include "uip.h"
|
||||
#include "psock.h"
|
||||
#include "httpd.h"
|
||||
#include "httpd-cgi.h"
|
||||
#include "httpd-fs.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
HTTPD_CGI_CALL(file, "file-stats", file_stats);
|
||||
HTTPD_CGI_CALL(tcp, "tcp-connections", tcp_stats);
|
||||
HTTPD_CGI_CALL(net, "net-stats", net_stats);
|
||||
|
||||
static const struct httpd_cgi_call *calls[] = { &file, &tcp, &net, NULL };
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static
|
||||
PT_THREAD(nullfunction(struct httpd_state *s, char *ptr))
|
||||
{
|
||||
PSOCK_BEGIN(&s->sout);
|
||||
PSOCK_END(&s->sout);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
httpd_cgifunction
|
||||
httpd_cgi(char *name)
|
||||
{
|
||||
const struct httpd_cgi_call **f;
|
||||
|
||||
/* Find the matching name in the table, return the function. */
|
||||
for(f = calls; *f != NULL; ++f) {
|
||||
if(strncmp((*f)->name, name, strlen((*f)->name)) == 0) {
|
||||
return (*f)->function;
|
||||
}
|
||||
}
|
||||
return nullfunction;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static unsigned short
|
||||
generate_file_stats(void *arg)
|
||||
{
|
||||
char *f = (char *)arg;
|
||||
return snprintf((char *)uip_appdata, UIP_APPDATA_SIZE, "%5u", httpd_fs_count(f));
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static
|
||||
PT_THREAD(file_stats(struct httpd_state *s, char *ptr))
|
||||
{
|
||||
PSOCK_BEGIN(&s->sout);
|
||||
|
||||
PSOCK_GENERATOR_SEND(&s->sout, generate_file_stats, strchr(ptr, ' ') + 1);
|
||||
|
||||
PSOCK_END(&s->sout);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static const char closed[] = /* "CLOSED",*/
|
||||
{0x43, 0x4c, 0x4f, 0x53, 0x45, 0x44, 0};
|
||||
static const char syn_rcvd[] = /* "SYN-RCVD",*/
|
||||
{0x53, 0x59, 0x4e, 0x2d, 0x52, 0x43, 0x56,
|
||||
0x44, 0};
|
||||
static const char syn_sent[] = /* "SYN-SENT",*/
|
||||
{0x53, 0x59, 0x4e, 0x2d, 0x53, 0x45, 0x4e,
|
||||
0x54, 0};
|
||||
static const char established[] = /* "ESTABLISHED",*/
|
||||
{0x45, 0x53, 0x54, 0x41, 0x42, 0x4c, 0x49, 0x53, 0x48,
|
||||
0x45, 0x44, 0};
|
||||
static const char fin_wait_1[] = /* "FIN-WAIT-1",*/
|
||||
{0x46, 0x49, 0x4e, 0x2d, 0x57, 0x41, 0x49,
|
||||
0x54, 0x2d, 0x31, 0};
|
||||
static const char fin_wait_2[] = /* "FIN-WAIT-2",*/
|
||||
{0x46, 0x49, 0x4e, 0x2d, 0x57, 0x41, 0x49,
|
||||
0x54, 0x2d, 0x32, 0};
|
||||
static const char closing[] = /* "CLOSING",*/
|
||||
{0x43, 0x4c, 0x4f, 0x53, 0x49,
|
||||
0x4e, 0x47, 0};
|
||||
static const char time_wait[] = /* "TIME-WAIT,"*/
|
||||
{0x54, 0x49, 0x4d, 0x45, 0x2d, 0x57, 0x41,
|
||||
0x49, 0x54, 0};
|
||||
static const char last_ack[] = /* "LAST-ACK"*/
|
||||
{0x4c, 0x41, 0x53, 0x54, 0x2d, 0x41, 0x43,
|
||||
0x4b, 0};
|
||||
|
||||
static const char *states[] = {
|
||||
closed,
|
||||
syn_rcvd,
|
||||
syn_sent,
|
||||
established,
|
||||
fin_wait_1,
|
||||
fin_wait_2,
|
||||
closing,
|
||||
time_wait,
|
||||
last_ack};
|
||||
|
||||
|
||||
static unsigned short
|
||||
generate_tcp_stats(void *arg)
|
||||
{
|
||||
struct uip_conn *conn;
|
||||
struct httpd_state *s = (struct httpd_state *)arg;
|
||||
|
||||
conn = &uip_conns[s->count];
|
||||
return snprintf((char *)uip_appdata, UIP_APPDATA_SIZE,
|
||||
"<tr><td>%d</td><td>%u.%u.%u.%u:%u</td><td>%s</td><td>%u</td><td>%u</td><td>%c %c</td></tr>\r\n",
|
||||
htons(conn->lport),
|
||||
htons(conn->ripaddr[0]) >> 8,
|
||||
htons(conn->ripaddr[0]) & 0xff,
|
||||
htons(conn->ripaddr[1]) >> 8,
|
||||
htons(conn->ripaddr[1]) & 0xff,
|
||||
htons(conn->rport),
|
||||
states[conn->tcpstateflags & UIP_TS_MASK],
|
||||
conn->nrtx,
|
||||
conn->timer,
|
||||
(uip_outstanding(conn))? '*':' ',
|
||||
(uip_stopped(conn))? '!':' ');
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static
|
||||
PT_THREAD(tcp_stats(struct httpd_state *s, char *ptr))
|
||||
{
|
||||
|
||||
PSOCK_BEGIN(&s->sout);
|
||||
|
||||
for(s->count = 0; s->count < UIP_CONNS; ++s->count) {
|
||||
if((uip_conns[s->count].tcpstateflags & UIP_TS_MASK) != UIP_CLOSED) {
|
||||
PSOCK_GENERATOR_SEND(&s->sout, generate_tcp_stats, s);
|
||||
}
|
||||
}
|
||||
|
||||
PSOCK_END(&s->sout);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static unsigned short
|
||||
generate_net_stats(void *arg)
|
||||
{
|
||||
struct httpd_state *s = (struct httpd_state *)arg;
|
||||
return snprintf((char *)uip_appdata, UIP_APPDATA_SIZE,
|
||||
"%5u\n", ((uip_stats_t *)&uip_stat)[s->count]);
|
||||
}
|
||||
|
||||
static
|
||||
PT_THREAD(net_stats(struct httpd_state *s, char *ptr))
|
||||
{
|
||||
PSOCK_BEGIN(&s->sout);
|
||||
|
||||
#if UIP_STATISTICS
|
||||
|
||||
for(s->count = 0; s->count < sizeof(uip_stat) / sizeof(uip_stats_t);
|
||||
++s->count) {
|
||||
PSOCK_GENERATOR_SEND(&s->sout, generate_net_stats, s);
|
||||
}
|
||||
|
||||
#endif /* UIP_STATISTICS */
|
||||
|
||||
PSOCK_END(&s->sout);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @} */
|
84
examples/emac/emac_uip/httpd-cgi.h
Normal file
84
examples/emac/emac_uip/httpd-cgi.h
Normal file
@ -0,0 +1,84 @@
|
||||
/**
|
||||
* \addtogroup httpd
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* Web server script interface header file
|
||||
* \author
|
||||
* Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001, Adam Dunkels.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the uIP TCP/IP stack.
|
||||
*
|
||||
* $Id: httpd-cgi.h,v 1.2 2006/06/11 21:46:38 adam Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __HTTPD_CGI_H__
|
||||
#define __HTTPD_CGI_H__
|
||||
|
||||
#include "psock.h"
|
||||
#include "httpd.h"
|
||||
|
||||
typedef PT_THREAD((* httpd_cgifunction)(struct httpd_state *, char *));
|
||||
|
||||
httpd_cgifunction httpd_cgi(char *name);
|
||||
|
||||
struct httpd_cgi_call {
|
||||
const char *name;
|
||||
const httpd_cgifunction function;
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief HTTPD CGI function declaration
|
||||
* \param name The C variable name of the function
|
||||
* \param str The string name of the function, used in the script file
|
||||
* \param function A pointer to the function that implements it
|
||||
*
|
||||
* This macro is used for declaring a HTTPD CGI
|
||||
* function. This function is then added to the list of
|
||||
* HTTPD CGI functions with the httpd_cgi_add() function.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define HTTPD_CGI_CALL(name, str, function) \
|
||||
static PT_THREAD(function(struct httpd_state *, char *)); \
|
||||
static const struct httpd_cgi_call name = {str, function}
|
||||
|
||||
void httpd_cgi_init(void);
|
||||
#endif /* __HTTPD_CGI_H__ */
|
||||
|
||||
/** @} */
|
132
examples/emac/emac_uip/httpd-fs.c
Normal file
132
examples/emac/emac_uip/httpd-fs.c
Normal file
@ -0,0 +1,132 @@
|
||||
/*
|
||||
* Copyright (c) 2001, Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: httpd-fs.c,v 1.1 2006/06/07 09:13:08 adam Exp $
|
||||
*/
|
||||
|
||||
#include "httpd.h"
|
||||
#include "httpd-fs.h"
|
||||
#include "httpd-fsdata.h"
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif /* NULL */
|
||||
|
||||
#include "httpd-fsdata.c"
|
||||
|
||||
#if HTTPD_FS_STATISTICS
|
||||
static u16_t count[HTTPD_FS_NUMFILES];
|
||||
#endif /* HTTPD_FS_STATISTICS */
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static u8_t
|
||||
httpd_fs_strcmp(const char *str1, const char *str2)
|
||||
{
|
||||
u8_t i;
|
||||
i = 0;
|
||||
loop:
|
||||
|
||||
if(str2[i] == 0 ||
|
||||
str1[i] == '\r' ||
|
||||
str1[i] == '\n') {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(str1[i] != str2[i]) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
++i;
|
||||
goto loop;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
int
|
||||
httpd_fs_open(const char *name, struct httpd_fs_file *file)
|
||||
{
|
||||
#if HTTPD_FS_STATISTICS
|
||||
u16_t i = 0;
|
||||
#endif /* HTTPD_FS_STATISTICS */
|
||||
struct httpd_fsdata_file_noconst *f;
|
||||
|
||||
for(f = (struct httpd_fsdata_file_noconst *)HTTPD_FS_ROOT;
|
||||
f != NULL;
|
||||
f = (struct httpd_fsdata_file_noconst *)f->next) {
|
||||
|
||||
if(httpd_fs_strcmp(name, f->name) == 0) {
|
||||
file->data = f->data;
|
||||
file->len = f->len;
|
||||
#if HTTPD_FS_STATISTICS
|
||||
++count[i];
|
||||
#endif /* HTTPD_FS_STATISTICS */
|
||||
return 1;
|
||||
}
|
||||
#if HTTPD_FS_STATISTICS
|
||||
++i;
|
||||
#endif /* HTTPD_FS_STATISTICS */
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
httpd_fs_init(void)
|
||||
{
|
||||
#if HTTPD_FS_STATISTICS
|
||||
u16_t i;
|
||||
for(i = 0; i < HTTPD_FS_NUMFILES; i++) {
|
||||
count[i] = 0;
|
||||
}
|
||||
#endif /* HTTPD_FS_STATISTICS */
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
#if HTTPD_FS_STATISTICS
|
||||
u16_t httpd_fs_count
|
||||
(char *name)
|
||||
{
|
||||
struct httpd_fsdata_file_noconst *f;
|
||||
u16_t i;
|
||||
|
||||
i = 0;
|
||||
for(f = (struct httpd_fsdata_file_noconst *)HTTPD_FS_ROOT;
|
||||
f != NULL;
|
||||
f = (struct httpd_fsdata_file_noconst *)f->next) {
|
||||
|
||||
if(httpd_fs_strcmp(name, f->name) == 0) {
|
||||
return count[i];
|
||||
}
|
||||
++i;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif /* HTTPD_FS_STATISTICS */
|
||||
/*-----------------------------------------------------------------------------------*/
|
57
examples/emac/emac_uip/httpd-fs.h
Normal file
57
examples/emac/emac_uip/httpd-fs.h
Normal file
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (c) 2001, Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: httpd-fs.h,v 1.1 2006/06/07 09:13:08 adam Exp $
|
||||
*/
|
||||
#ifndef __HTTPD_FS_H__
|
||||
#define __HTTPD_FS_H__
|
||||
|
||||
#define HTTPD_FS_STATISTICS 1
|
||||
|
||||
struct httpd_fs_file {
|
||||
char *data;
|
||||
int len;
|
||||
};
|
||||
|
||||
/* file must be allocated by caller and will be filled in
|
||||
by the function. */
|
||||
int httpd_fs_open(const char *name, struct httpd_fs_file *file);
|
||||
|
||||
#ifdef HTTPD_FS_STATISTICS
|
||||
#if HTTPD_FS_STATISTICS == 1
|
||||
u16_t httpd_fs_count(char *name);
|
||||
#endif /* HTTPD_FS_STATISTICS */
|
||||
#endif /* HTTPD_FS_STATISTICS */
|
||||
|
||||
void httpd_fs_init(void);
|
||||
|
||||
#endif /* __HTTPD_FS_H__ */
|
607
examples/emac/emac_uip/httpd-fsdata.c
Normal file
607
examples/emac/emac_uip/httpd-fsdata.c
Normal file
@ -0,0 +1,607 @@
|
||||
static const unsigned char data_processes_shtml[] = {
|
||||
/* /processes.shtml */
|
||||
0x2f, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x65, 0x73, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0,
|
||||
0x25, 0x21, 0x3a, 0x20, 0x2f, 0x68, 0x65, 0x61, 0x64, 0x65,
|
||||
0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0xa, 0x3c, 0x68, 0x31,
|
||||
0x3e, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x20, 0x70, 0x72,
|
||||
0x6f, 0x63, 0x65, 0x73, 0x73, 0x65, 0x73, 0x3c, 0x2f, 0x68,
|
||||
0x31, 0x3e, 0x3c, 0x62, 0x72, 0x3e, 0x3c, 0x74, 0x61, 0x62,
|
||||
0x6c, 0x65, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3d, 0x22,
|
||||
0x31, 0x30, 0x30, 0x25, 0x22, 0x3e, 0xa, 0x3c, 0x74, 0x72,
|
||||
0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x49, 0x44, 0x3c, 0x2f, 0x74,
|
||||
0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x4e, 0x61, 0x6d, 0x65,
|
||||
0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x50,
|
||||
0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x3c, 0x2f, 0x74,
|
||||
0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x50, 0x6f, 0x6c, 0x6c,
|
||||
0x20, 0x68, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x3c, 0x2f,
|
||||
0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x45, 0x76, 0x65,
|
||||
0x6e, 0x74, 0x20, 0x68, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72,
|
||||
0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x50,
|
||||
0x72, 0x6f, 0x63, 0x73, 0x74, 0x61, 0x74, 0x65, 0x3c, 0x2f,
|
||||
0x74, 0x68, 0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e, 0xa, 0x25,
|
||||
0x21, 0x20, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x65,
|
||||
0x73, 0xa, 0x25, 0x21, 0x3a, 0x20, 0x2f, 0x66, 0x6f, 0x6f,
|
||||
0x74, 0x65, 0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0};
|
||||
|
||||
static const unsigned char data_404_html[] = {
|
||||
/* /404.html */
|
||||
0x2f, 0x34, 0x30, 0x34, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0,
|
||||
0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0xa, 0x20, 0x20, 0x3c,
|
||||
0x62, 0x6f, 0x64, 0x79, 0x20, 0x62, 0x67, 0x63, 0x6f, 0x6c,
|
||||
0x6f, 0x72, 0x3d, 0x22, 0x77, 0x68, 0x69, 0x74, 0x65, 0x22,
|
||||
0x3e, 0xa, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x63, 0x65, 0x6e,
|
||||
0x74, 0x65, 0x72, 0x3e, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x3c, 0x68, 0x31, 0x3e, 0x34, 0x30, 0x34, 0x20, 0x2d,
|
||||
0x20, 0x66, 0x69, 0x6c, 0x65, 0x20, 0x6e, 0x6f, 0x74, 0x20,
|
||||
0x66, 0x6f, 0x75, 0x6e, 0x64, 0x3c, 0x2f, 0x68, 0x31, 0x3e,
|
||||
0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x68, 0x33,
|
||||
0x3e, 0x47, 0x6f, 0x20, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65,
|
||||
0x66, 0x3d, 0x22, 0x2f, 0x22, 0x3e, 0x68, 0x65, 0x72, 0x65,
|
||||
0x3c, 0x2f, 0x61, 0x3e, 0x20, 0x69, 0x6e, 0x73, 0x74, 0x65,
|
||||
0x61, 0x64, 0x2e, 0x3c, 0x2f, 0x68, 0x33, 0x3e, 0xa, 0x20,
|
||||
0x20, 0x20, 0x20, 0x3c, 0x2f, 0x63, 0x65, 0x6e, 0x74, 0x65,
|
||||
0x72, 0x3e, 0xa, 0x20, 0x20, 0x3c, 0x2f, 0x62, 0x6f, 0x64,
|
||||
0x79, 0x3e, 0xa, 0x3c, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x3e,
|
||||
0};
|
||||
|
||||
static const unsigned char data_files_shtml[] = {
|
||||
/* /files.shtml */
|
||||
0x2f, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0,
|
||||
0x25, 0x21, 0x3a, 0x20, 0x2f, 0x68, 0x65, 0x61, 0x64, 0x65,
|
||||
0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0xa, 0x3c, 0x68, 0x31,
|
||||
0x3e, 0x46, 0x69, 0x6c, 0x65, 0x20, 0x73, 0x74, 0x61, 0x74,
|
||||
0x69, 0x73, 0x74, 0x69, 0x63, 0x73, 0x3c, 0x2f, 0x68, 0x31,
|
||||
0x3e, 0xa, 0x3c, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x3e,
|
||||
0xa, 0x3c, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x77, 0x69,
|
||||
0x64, 0x74, 0x68, 0x3d, 0x22, 0x33, 0x30, 0x30, 0x22, 0x3e,
|
||||
0xa, 0x3c, 0x74, 0x72, 0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c,
|
||||
0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x69,
|
||||
0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0x22,
|
||||
0x3e, 0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74,
|
||||
0x6d, 0x6c, 0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x2f, 0x74, 0x64,
|
||||
0x3e, 0xa, 0x3c, 0x74, 0x64, 0x3e, 0x25, 0x21, 0x20, 0x66,
|
||||
0x69, 0x6c, 0x65, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x73, 0x20,
|
||||
0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d,
|
||||
0x6c, 0xa, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x74, 0x64,
|
||||
0x3e, 0x3c, 0x69, 0x6d, 0x67, 0x20, 0x73, 0x72, 0x63, 0x3d,
|
||||
0x22, 0x2f, 0x66, 0x61, 0x64, 0x65, 0x2e, 0x70, 0x6e, 0x67,
|
||||
0x22, 0x20, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x3d, 0x31,
|
||||
0x30, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3d, 0x25, 0x21,
|
||||
0x20, 0x66, 0x69, 0x6c, 0x65, 0x2d, 0x73, 0x74, 0x61, 0x74,
|
||||
0x73, 0x20, 0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68,
|
||||
0x74, 0x6d, 0x6c, 0xa, 0x3e, 0x20, 0x3c, 0x2f, 0x74, 0x64,
|
||||
0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e, 0xa, 0x3c, 0x74, 0x72,
|
||||
0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c, 0x61, 0x20, 0x68, 0x72,
|
||||
0x65, 0x66, 0x3d, 0x22, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x73,
|
||||
0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x2f, 0x66,
|
||||
0x69, 0x6c, 0x65, 0x73, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c,
|
||||
0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0xa,
|
||||
0x3c, 0x74, 0x64, 0x3e, 0x25, 0x21, 0x20, 0x66, 0x69, 0x6c,
|
||||
0x65, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x73, 0x20, 0x2f, 0x66,
|
||||
0x69, 0x6c, 0x65, 0x73, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c,
|
||||
0xa, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x74, 0x64, 0x3e,
|
||||
0x3c, 0x69, 0x6d, 0x67, 0x20, 0x73, 0x72, 0x63, 0x3d, 0x22,
|
||||
0x2f, 0x66, 0x61, 0x64, 0x65, 0x2e, 0x70, 0x6e, 0x67, 0x22,
|
||||
0x20, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x3d, 0x31, 0x30,
|
||||
0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3d, 0x25, 0x21, 0x20,
|
||||
0x66, 0x69, 0x6c, 0x65, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x73,
|
||||
0x20, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x2e, 0x73, 0x68,
|
||||
0x74, 0x6d, 0x6c, 0xa, 0x3e, 0x20, 0x3c, 0x2f, 0x74, 0x64,
|
||||
0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e, 0xa, 0x3c, 0x74, 0x72,
|
||||
0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c, 0x61, 0x20, 0x68, 0x72,
|
||||
0x65, 0x66, 0x3d, 0x22, 0x2f, 0x74, 0x63, 0x70, 0x2e, 0x73,
|
||||
0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x2f, 0x74, 0x63, 0x70,
|
||||
0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0x3c, 0x2f, 0x61, 0x3e,
|
||||
0x3c, 0x2f, 0x74, 0x64, 0x3e, 0xa, 0x3c, 0x74, 0x64, 0x3e,
|
||||
0x25, 0x21, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x2d, 0x73, 0x74,
|
||||
0x61, 0x74, 0x73, 0x20, 0x2f, 0x74, 0x63, 0x70, 0x2e, 0x73,
|
||||
0x68, 0x74, 0x6d, 0x6c, 0xa, 0x3c, 0x2f, 0x74, 0x64, 0x3e,
|
||||
0x3c, 0x74, 0x64, 0x3e, 0x3c, 0x69, 0x6d, 0x67, 0x20, 0x73,
|
||||
0x72, 0x63, 0x3d, 0x22, 0x2f, 0x66, 0x61, 0x64, 0x65, 0x2e,
|
||||
0x70, 0x6e, 0x67, 0x22, 0x20, 0x68, 0x65, 0x69, 0x67, 0x68,
|
||||
0x74, 0x3d, 0x31, 0x30, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68,
|
||||
0x3d, 0x25, 0x21, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x2d, 0x73,
|
||||
0x74, 0x61, 0x74, 0x73, 0x20, 0x2f, 0x74, 0x63, 0x70, 0x2e,
|
||||
0x73, 0x68, 0x74, 0x6d, 0x6c, 0xa, 0x3e, 0x20, 0x3c, 0x2f,
|
||||
0x74, 0x64, 0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e, 0xa, 0x3c,
|
||||
0x74, 0x72, 0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c, 0x61, 0x20,
|
||||
0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x73, 0x74, 0x61,
|
||||
0x74, 0x73, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e,
|
||||
0x2f, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x73, 0x68, 0x74,
|
||||
0x6d, 0x6c, 0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x2f, 0x74, 0x64,
|
||||
0x3e, 0xa, 0x3c, 0x74, 0x64, 0x3e, 0x25, 0x21, 0x20, 0x66,
|
||||
0x69, 0x6c, 0x65, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x73, 0x20,
|
||||
0x2f, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x73, 0x68, 0x74,
|
||||
0x6d, 0x6c, 0xa, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x74,
|
||||
0x64, 0x3e, 0x3c, 0x69, 0x6d, 0x67, 0x20, 0x73, 0x72, 0x63,
|
||||
0x3d, 0x22, 0x2f, 0x66, 0x61, 0x64, 0x65, 0x2e, 0x70, 0x6e,
|
||||
0x67, 0x22, 0x20, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x3d,
|
||||
0x31, 0x30, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3d, 0x25,
|
||||
0x21, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x2d, 0x73, 0x74, 0x61,
|
||||
0x74, 0x73, 0x20, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e,
|
||||
0x73, 0x68, 0x74, 0x6d, 0x6c, 0xa, 0x3e, 0x20, 0x3c, 0x2f,
|
||||
0x74, 0x64, 0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e, 0xa, 0x3c,
|
||||
0x74, 0x72, 0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c, 0x61, 0x20,
|
||||
0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x73, 0x74, 0x79,
|
||||
0x6c, 0x65, 0x2e, 0x63, 0x73, 0x73, 0x22, 0x3e, 0x2f, 0x73,
|
||||
0x74, 0x79, 0x6c, 0x65, 0x2e, 0x63, 0x73, 0x73, 0x3c, 0x2f,
|
||||
0x61, 0x3e, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0xa, 0x3c, 0x74,
|
||||
0x64, 0x3e, 0x25, 0x21, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x2d,
|
||||
0x73, 0x74, 0x61, 0x74, 0x73, 0x20, 0x2f, 0x73, 0x74, 0x79,
|
||||
0x6c, 0x65, 0x2e, 0x63, 0x73, 0x73, 0xa, 0x3c, 0x2f, 0x74,
|
||||
0x64, 0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c, 0x69, 0x6d, 0x67,
|
||||
0x20, 0x73, 0x72, 0x63, 0x3d, 0x22, 0x2f, 0x66, 0x61, 0x64,
|
||||
0x65, 0x2e, 0x70, 0x6e, 0x67, 0x22, 0x20, 0x68, 0x65, 0x69,
|
||||
0x67, 0x68, 0x74, 0x3d, 0x31, 0x30, 0x20, 0x77, 0x69, 0x64,
|
||||
0x74, 0x68, 0x3d, 0x25, 0x21, 0x20, 0x66, 0x69, 0x6c, 0x65,
|
||||
0x2d, 0x73, 0x74, 0x61, 0x74, 0x73, 0x20, 0x2f, 0x73, 0x74,
|
||||
0x79, 0x6c, 0x65, 0x2e, 0x63, 0x73, 0x73, 0xa, 0x3e, 0x20,
|
||||
0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e,
|
||||
0xa, 0x3c, 0x74, 0x72, 0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c,
|
||||
0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x34,
|
||||
0x30, 0x34, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x2f,
|
||||
0x34, 0x30, 0x34, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0x3c, 0x2f,
|
||||
0x61, 0x3e, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0xa, 0x3c, 0x74,
|
||||
0x64, 0x3e, 0x25, 0x21, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x2d,
|
||||
0x73, 0x74, 0x61, 0x74, 0x73, 0x20, 0x2f, 0x34, 0x30, 0x34,
|
||||
0x2e, 0x68, 0x74, 0x6d, 0x6c, 0xa, 0x3c, 0x2f, 0x74, 0x64,
|
||||
0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c, 0x69, 0x6d, 0x67, 0x20,
|
||||
0x73, 0x72, 0x63, 0x3d, 0x22, 0x2f, 0x66, 0x61, 0x64, 0x65,
|
||||
0x2e, 0x70, 0x6e, 0x67, 0x22, 0x20, 0x68, 0x65, 0x69, 0x67,
|
||||
0x68, 0x74, 0x3d, 0x31, 0x30, 0x20, 0x77, 0x69, 0x64, 0x74,
|
||||
0x68, 0x3d, 0x25, 0x21, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x2d,
|
||||
0x73, 0x74, 0x61, 0x74, 0x73, 0x20, 0x2f, 0x34, 0x30, 0x34,
|
||||
0x2e, 0x68, 0x74, 0x6d, 0x6c, 0xa, 0x3e, 0x20, 0x3c, 0x2f,
|
||||
0x74, 0x64, 0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e, 0xa, 0x3c,
|
||||
0x74, 0x72, 0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c, 0x61, 0x20,
|
||||
0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x66, 0x61, 0x64,
|
||||
0x65, 0x2e, 0x70, 0x6e, 0x67, 0x22, 0x3e, 0x2f, 0x66, 0x61,
|
||||
0x64, 0x65, 0x2e, 0x70, 0x6e, 0x67, 0x3c, 0x2f, 0x61, 0x3e,
|
||||
0x3c, 0x2f, 0x74, 0x64, 0x3e, 0xa, 0x3c, 0x74, 0x64, 0x3e,
|
||||
0x25, 0x21, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x2d, 0x73, 0x74,
|
||||
0x61, 0x74, 0x73, 0x20, 0x2f, 0x66, 0x61, 0x64, 0x65, 0x2e,
|
||||
0x70, 0x6e, 0x67, 0xa, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c,
|
||||
0x74, 0x64, 0x3e, 0x3c, 0x69, 0x6d, 0x67, 0x20, 0x73, 0x72,
|
||||
0x63, 0x3d, 0x22, 0x2f, 0x66, 0x61, 0x64, 0x65, 0x2e, 0x70,
|
||||
0x6e, 0x67, 0x22, 0x20, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74,
|
||||
0x3d, 0x31, 0x30, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3d,
|
||||
0x25, 0x21, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x2d, 0x73, 0x74,
|
||||
0x61, 0x74, 0x73, 0x20, 0x2f, 0x66, 0x61, 0x64, 0x65, 0x2e,
|
||||
0x70, 0x6e, 0x67, 0xa, 0x3e, 0x20, 0x3c, 0x2f, 0x74, 0x64,
|
||||
0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e, 0xa, 0x3c, 0x2f, 0x74,
|
||||
0x61, 0x62, 0x6c, 0x65, 0x3e, 0xa, 0x3c, 0x2f, 0x63, 0x65,
|
||||
0x6e, 0x74, 0x65, 0x72, 0x3e, 0xa, 0x25, 0x21, 0x3a, 0x20,
|
||||
0x2f, 0x66, 0x6f, 0x6f, 0x74, 0x65, 0x72, 0x2e, 0x68, 0x74,
|
||||
0x6d, 0x6c, 0xa, 0};
|
||||
|
||||
static const unsigned char data_footer_html[] = {
|
||||
/* /footer.html */
|
||||
0x2f, 0x66, 0x6f, 0x6f, 0x74, 0x65, 0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0,
|
||||
0x20, 0x20, 0x3c, 0x2f, 0x62, 0x6f, 0x64, 0x79, 0x3e, 0xa,
|
||||
0x3c, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0};
|
||||
|
||||
static const unsigned char data_header_html[] = {
|
||||
/* /header.html */
|
||||
0x2f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0,
|
||||
0x3c, 0x21, 0x44, 0x4f, 0x43, 0x54, 0x59, 0x50, 0x45, 0x20,
|
||||
0x48, 0x54, 0x4d, 0x4c, 0x20, 0x50, 0x55, 0x42, 0x4c, 0x49,
|
||||
0x43, 0x20, 0x22, 0x2d, 0x2f, 0x2f, 0x57, 0x33, 0x43, 0x2f,
|
||||
0x2f, 0x44, 0x54, 0x44, 0x20, 0x48, 0x54, 0x4d, 0x4c, 0x20,
|
||||
0x34, 0x2e, 0x30, 0x31, 0x20, 0x54, 0x72, 0x61, 0x6e, 0x73,
|
||||
0x69, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x2f, 0x2f, 0x45,
|
||||
0x4e, 0x22, 0x20, 0x22, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f,
|
||||
0x2f, 0x77, 0x77, 0x77, 0x2e, 0x77, 0x33, 0x2e, 0x6f, 0x72,
|
||||
0x67, 0x2f, 0x54, 0x52, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x34,
|
||||
0x2f, 0x6c, 0x6f, 0x6f, 0x73, 0x65, 0x2e, 0x64, 0x74, 0x64,
|
||||
0x22, 0x3e, 0xa, 0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0xa,
|
||||
0x20, 0x20, 0x3c, 0x68, 0x65, 0x61, 0x64, 0x3e, 0xa, 0x20,
|
||||
0x20, 0x20, 0x20, 0x3c, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e,
|
||||
0x57, 0x65, 0x6c, 0x63, 0x6f, 0x6d, 0x65, 0x20, 0x74, 0x6f,
|
||||
0x20, 0x74, 0x68, 0x65, 0x20, 0x75, 0x49, 0x50, 0x20, 0x77,
|
||||
0x65, 0x62, 0x20, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x21,
|
||||
0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0xa, 0x20,
|
||||
0x20, 0x20, 0x20, 0x3c, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x72,
|
||||
0x65, 0x6c, 0x3d, 0x22, 0x73, 0x74, 0x79, 0x6c, 0x65, 0x73,
|
||||
0x68, 0x65, 0x65, 0x74, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65,
|
||||
0x3d, 0x22, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x63, 0x73, 0x73,
|
||||
0x22, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x73, 0x74,
|
||||
0x79, 0x6c, 0x65, 0x2e, 0x63, 0x73, 0x73, 0x22, 0x3e, 0x20,
|
||||
0x20, 0xa, 0x20, 0x20, 0x3c, 0x2f, 0x68, 0x65, 0x61, 0x64,
|
||||
0x3e, 0xa, 0x20, 0x20, 0x3c, 0x62, 0x6f, 0x64, 0x79, 0x20,
|
||||
0x62, 0x67, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3d, 0x22, 0x23,
|
||||
0x66, 0x66, 0x66, 0x65, 0x65, 0x63, 0x22, 0x20, 0x74, 0x65,
|
||||
0x78, 0x74, 0x3d, 0x22, 0x62, 0x6c, 0x61, 0x63, 0x6b, 0x22,
|
||||
0x3e, 0xa, 0xa, 0x20, 0x20, 0x3c, 0x64, 0x69, 0x76, 0x20,
|
||||
0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d, 0x22, 0x6d, 0x65, 0x6e,
|
||||
0x75, 0x22, 0x3e, 0xa, 0x20, 0x20, 0x3c, 0x64, 0x69, 0x76,
|
||||
0x20, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d, 0x22, 0x6d, 0x65,
|
||||
0x6e, 0x75, 0x62, 0x6f, 0x78, 0x22, 0x3e, 0x3c, 0x61, 0x20,
|
||||
0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x22, 0x3e, 0x46,
|
||||
0x72, 0x6f, 0x6e, 0x74, 0x20, 0x70, 0x61, 0x67, 0x65, 0x3c,
|
||||
0x2f, 0x61, 0x3e, 0x3c, 0x2f, 0x64, 0x69, 0x76, 0x3e, 0xa,
|
||||
0x20, 0x20, 0x3c, 0x64, 0x69, 0x76, 0x20, 0x63, 0x6c, 0x61,
|
||||
0x73, 0x73, 0x3d, 0x22, 0x6d, 0x65, 0x6e, 0x75, 0x62, 0x6f,
|
||||
0x78, 0x22, 0x3e, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 0x66,
|
||||
0x3d, 0x22, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x2e, 0x73, 0x68,
|
||||
0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x46, 0x69, 0x6c, 0x65, 0x20,
|
||||
0x73, 0x74, 0x61, 0x74, 0x69, 0x73, 0x74, 0x69, 0x63, 0x73,
|
||||
0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x2f, 0x64, 0x69, 0x76, 0x3e,
|
||||
0xa, 0x20, 0x20, 0x3c, 0x64, 0x69, 0x76, 0x20, 0x63, 0x6c,
|
||||
0x61, 0x73, 0x73, 0x3d, 0x22, 0x6d, 0x65, 0x6e, 0x75, 0x62,
|
||||
0x6f, 0x78, 0x22, 0x3e, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65,
|
||||
0x66, 0x3d, 0x22, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x73,
|
||||
0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x4e, 0x65, 0x74, 0x77,
|
||||
0x6f, 0x72, 0x6b, 0x20, 0x73, 0x74, 0x61, 0x74, 0x69, 0x73,
|
||||
0x74, 0x69, 0x63, 0x73, 0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x2f,
|
||||
0x64, 0x69, 0x76, 0x3e, 0xa, 0x20, 0x20, 0x3c, 0x64, 0x69,
|
||||
0x76, 0x20, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d, 0x22, 0x6d,
|
||||
0x65, 0x6e, 0x75, 0x62, 0x6f, 0x78, 0x22, 0x3e, 0x3c, 0x61,
|
||||
0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x74, 0x63, 0x70,
|
||||
0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x4e, 0x65,
|
||||
0x74, 0x77, 0x6f, 0x72, 0x6b, 0xa, 0x20, 0x20, 0x63, 0x6f,
|
||||
0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x3c,
|
||||
0x2f, 0x61, 0x3e, 0x3c, 0x2f, 0x64, 0x69, 0x76, 0x3e, 0xa,
|
||||
0x20, 0x20, 0x3c, 0x62, 0x72, 0x3e, 0xa, 0x20, 0x20, 0x3c,
|
||||
0x2f, 0x64, 0x69, 0x76, 0x3e, 0xa, 0x20, 0x20, 0xa, 0x20,
|
||||
0x20, 0x3c, 0x64, 0x69, 0x76, 0x20, 0x63, 0x6c, 0x61, 0x73,
|
||||
0x73, 0x3d, 0x22, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74,
|
||||
0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x3e, 0xa, 0};
|
||||
|
||||
static const unsigned char data_index_html[] = {
|
||||
/* /index.html */
|
||||
0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0,
|
||||
0x3c, 0x21, 0x44, 0x4f, 0x43, 0x54, 0x59, 0x50, 0x45, 0x20,
|
||||
0x48, 0x54, 0x4d, 0x4c, 0x20, 0x50, 0x55, 0x42, 0x4c, 0x49,
|
||||
0x43, 0x20, 0x22, 0x2d, 0x2f, 0x2f, 0x57, 0x33, 0x43, 0x2f,
|
||||
0x2f, 0x44, 0x54, 0x44, 0x20, 0x48, 0x54, 0x4d, 0x4c, 0x20,
|
||||
0x34, 0x2e, 0x30, 0x31, 0x20, 0x54, 0x72, 0x61, 0x6e, 0x73,
|
||||
0x69, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x2f, 0x2f, 0x45,
|
||||
0x4e, 0x22, 0x20, 0x22, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f,
|
||||
0x2f, 0x77, 0x77, 0x77, 0x2e, 0x77, 0x33, 0x2e, 0x6f, 0x72,
|
||||
0x67, 0x2f, 0x54, 0x52, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x34,
|
||||
0x2f, 0x6c, 0x6f, 0x6f, 0x73, 0x65, 0x2e, 0x64, 0x74, 0x64,
|
||||
0x22, 0x3e, 0xa, 0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0xa,
|
||||
0x20, 0x20, 0x3c, 0x68, 0x65, 0x61, 0x64, 0x3e, 0xa, 0x20,
|
||||
0x20, 0x20, 0x20, 0x3c, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e,
|
||||
0x57, 0x65, 0x6c, 0x63, 0x6f, 0x6d, 0x65, 0x20, 0x74, 0x6f,
|
||||
0x20, 0x74, 0x68, 0x65, 0x20, 0x75, 0x49, 0x50, 0x20, 0x77,
|
||||
0x65, 0x62, 0x20, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x21,
|
||||
0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0xa, 0x20,
|
||||
0x20, 0x20, 0x20, 0x3c, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x72,
|
||||
0x65, 0x6c, 0x3d, 0x22, 0x73, 0x74, 0x79, 0x6c, 0x65, 0x73,
|
||||
0x68, 0x65, 0x65, 0x74, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65,
|
||||
0x3d, 0x22, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x63, 0x73, 0x73,
|
||||
0x22, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x73, 0x74,
|
||||
0x79, 0x6c, 0x65, 0x2e, 0x63, 0x73, 0x73, 0x22, 0x3e, 0x20,
|
||||
0x20, 0xa, 0x20, 0x20, 0x3c, 0x2f, 0x68, 0x65, 0x61, 0x64,
|
||||
0x3e, 0xa, 0x20, 0x20, 0x3c, 0x62, 0x6f, 0x64, 0x79, 0x20,
|
||||
0x62, 0x67, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3d, 0x22, 0x23,
|
||||
0x66, 0x66, 0x66, 0x65, 0x65, 0x63, 0x22, 0x20, 0x74, 0x65,
|
||||
0x78, 0x74, 0x3d, 0x22, 0x62, 0x6c, 0x61, 0x63, 0x6b, 0x22,
|
||||
0x3e, 0xa, 0xa, 0x20, 0x20, 0x3c, 0x64, 0x69, 0x76, 0x20,
|
||||
0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d, 0x22, 0x6d, 0x65, 0x6e,
|
||||
0x75, 0x22, 0x3e, 0xa, 0x20, 0x20, 0x3c, 0x64, 0x69, 0x76,
|
||||
0x20, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d, 0x22, 0x6d, 0x65,
|
||||
0x6e, 0x75, 0x62, 0x6f, 0x78, 0x22, 0x3e, 0x3c, 0x61, 0x20,
|
||||
0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x22, 0x3e, 0x46,
|
||||
0x72, 0x6f, 0x6e, 0x74, 0x20, 0x70, 0x61, 0x67, 0x65, 0x3c,
|
||||
0x2f, 0x61, 0x3e, 0x3c, 0x2f, 0x64, 0x69, 0x76, 0x3e, 0xa,
|
||||
0x20, 0x20, 0x3c, 0x64, 0x69, 0x76, 0x20, 0x63, 0x6c, 0x61,
|
||||
0x73, 0x73, 0x3d, 0x22, 0x6d, 0x65, 0x6e, 0x75, 0x62, 0x6f,
|
||||
0x78, 0x22, 0x3e, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 0x66,
|
||||
0x3d, 0x22, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x2e, 0x73, 0x68,
|
||||
0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x46, 0x69, 0x6c, 0x65, 0x20,
|
||||
0x73, 0x74, 0x61, 0x74, 0x69, 0x73, 0x74, 0x69, 0x63, 0x73,
|
||||
0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x2f, 0x64, 0x69, 0x76, 0x3e,
|
||||
0xa, 0x20, 0x20, 0x3c, 0x64, 0x69, 0x76, 0x20, 0x63, 0x6c,
|
||||
0x61, 0x73, 0x73, 0x3d, 0x22, 0x6d, 0x65, 0x6e, 0x75, 0x62,
|
||||
0x6f, 0x78, 0x22, 0x3e, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65,
|
||||
0x66, 0x3d, 0x22, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x73,
|
||||
0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x4e, 0x65, 0x74, 0x77,
|
||||
0x6f, 0x72, 0x6b, 0x20, 0x73, 0x74, 0x61, 0x74, 0x69, 0x73,
|
||||
0x74, 0x69, 0x63, 0x73, 0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x2f,
|
||||
0x64, 0x69, 0x76, 0x3e, 0xa, 0x20, 0x20, 0x3c, 0x64, 0x69,
|
||||
0x76, 0x20, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d, 0x22, 0x6d,
|
||||
0x65, 0x6e, 0x75, 0x62, 0x6f, 0x78, 0x22, 0x3e, 0x3c, 0x61,
|
||||
0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x74, 0x63, 0x70,
|
||||
0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x4e, 0x65,
|
||||
0x74, 0x77, 0x6f, 0x72, 0x6b, 0xa, 0x20, 0x20, 0x63, 0x6f,
|
||||
0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x3c,
|
||||
0x2f, 0x61, 0x3e, 0x3c, 0x2f, 0x64, 0x69, 0x76, 0x3e, 0xa,
|
||||
0x20, 0x20, 0x3c, 0x62, 0x72, 0x3e, 0xa, 0x20, 0x20, 0x3c,
|
||||
0x2f, 0x64, 0x69, 0x76, 0x3e, 0xa, 0xa, 0x20, 0x20, 0x3c,
|
||||
0x64, 0x69, 0x76, 0x20, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d,
|
||||
0x22, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x62, 0x6c,
|
||||
0x6f, 0x63, 0x6b, 0x22, 0x3e, 0xa, 0x20, 0x20, 0x3c, 0x70,
|
||||
0x3e, 0xa, 0x20, 0x20, 0x54, 0x68, 0x65, 0x73, 0x65, 0x20,
|
||||
0x77, 0x65, 0x62, 0x20, 0x70, 0x61, 0x67, 0x65, 0x73, 0x20,
|
||||
0x61, 0x72, 0x65, 0x20, 0x73, 0x65, 0x72, 0x76, 0x65, 0x64,
|
||||
0x20, 0x62, 0x79, 0x20, 0x61, 0x20, 0x73, 0x6d, 0x61, 0x6c,
|
||||
0x6c, 0x20, 0x77, 0x65, 0x62, 0x20, 0x73, 0x65, 0x72, 0x76,
|
||||
0x65, 0x72, 0x20, 0x72, 0x75, 0x6e, 0x6e, 0x69, 0x6e, 0x67,
|
||||
0x20, 0x6f, 0x6e, 0x20, 0x74, 0x6f, 0x70, 0x20, 0x6f, 0x66,
|
||||
0xa, 0x20, 0x20, 0x74, 0x68, 0x65, 0x20, 0x3c, 0x61, 0x20,
|
||||
0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70,
|
||||
0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x69, 0x63,
|
||||
0x73, 0x2e, 0x73, 0x65, 0x2f, 0x7e, 0x61, 0x64, 0x61, 0x6d,
|
||||
0x2f, 0x75, 0x69, 0x70, 0x2f, 0x22, 0x3e, 0x75, 0x49, 0x50,
|
||||
0x20, 0x65, 0x6d, 0x62, 0x65, 0x64, 0x64, 0x65, 0x64, 0x20,
|
||||
0x54, 0x43, 0x50, 0x2f, 0x49, 0x50, 0xa, 0x20, 0x20, 0x73,
|
||||
0x74, 0x61, 0x63, 0x6b, 0x3c, 0x2f, 0x61, 0x3e, 0x2e, 0xa,
|
||||
0x20, 0x20, 0x3c, 0x2f, 0x70, 0x3e, 0xa, 0x20, 0x20, 0x3c,
|
||||
0x70, 0x3e, 0xa, 0x20, 0x20, 0x43, 0x6c, 0x69, 0x63, 0x6b,
|
||||
0x20, 0x6f, 0x6e, 0x20, 0x74, 0x68, 0x65, 0x20, 0x6c, 0x69,
|
||||
0x6e, 0x6b, 0x73, 0x20, 0x61, 0x62, 0x6f, 0x76, 0x65, 0x20,
|
||||
0x66, 0x6f, 0x72, 0x20, 0x77, 0x65, 0x62, 0x20, 0x73, 0x65,
|
||||
0x72, 0x76, 0x65, 0x72, 0x20, 0x73, 0x74, 0x61, 0x74, 0x69,
|
||||
0x73, 0x74, 0x69, 0x63, 0x73, 0x2e, 0xa, 0x20, 0x20, 0x3c,
|
||||
0x2f, 0x70, 0x3e, 0xa, 0xa, 0x20, 0x20, 0x3c, 0x2f, 0x62,
|
||||
0x6f, 0x64, 0x79, 0x3e, 0xa, 0x3c, 0x2f, 0x68, 0x74, 0x6d,
|
||||
0x6c, 0x3e, 0xa, 0};
|
||||
|
||||
static const unsigned char data_style_css[] = {
|
||||
/* /style.css */
|
||||
0x2f, 0x73, 0x74, 0x79, 0x6c, 0x65, 0x2e, 0x63, 0x73, 0x73, 0,
|
||||
0x68, 0x31, 0x20, 0xa, 0x7b, 0xa, 0x20, 0x20, 0x74, 0x65,
|
||||
0x78, 0x74, 0x2d, 0x61, 0x6c, 0x69, 0x67, 0x6e, 0x3a, 0x20,
|
||||
0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x3b, 0xa, 0x20, 0x20,
|
||||
0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a,
|
||||
0x31, 0x34, 0x70, 0x74, 0x3b, 0xa, 0x20, 0x20, 0x66, 0x6f,
|
||||
0x6e, 0x74, 0x2d, 0x66, 0x61, 0x6d, 0x69, 0x6c, 0x79, 0x3a,
|
||||
0x61, 0x72, 0x69, 0x61, 0x6c, 0x2c, 0x68, 0x65, 0x6c, 0x76,
|
||||
0x65, 0x74, 0x69, 0x63, 0x61, 0x3b, 0xa, 0x20, 0x20, 0x66,
|
||||
0x6f, 0x6e, 0x74, 0x2d, 0x77, 0x65, 0x69, 0x67, 0x68, 0x74,
|
||||
0x3a, 0x62, 0x6f, 0x6c, 0x64, 0x3b, 0xa, 0x20, 0x20, 0x70,
|
||||
0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x3a, 0x31, 0x30, 0x70,
|
||||
0x78, 0x3b, 0x20, 0xa, 0x7d, 0xa, 0xa, 0x62, 0x6f, 0x64,
|
||||
0x79, 0xa, 0x7b, 0xa, 0xa, 0x20, 0x20, 0x62, 0x61, 0x63,
|
||||
0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x2d, 0x63, 0x6f,
|
||||
0x6c, 0x6f, 0x72, 0x3a, 0x20, 0x23, 0x66, 0x66, 0x66, 0x65,
|
||||
0x65, 0x63, 0x3b, 0xa, 0x20, 0x20, 0x63, 0x6f, 0x6c, 0x6f,
|
||||
0x72, 0x3a, 0x62, 0x6c, 0x61, 0x63, 0x6b, 0x3b, 0xa, 0xa,
|
||||
0x20, 0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a,
|
||||
0x65, 0x3a, 0x38, 0x70, 0x74, 0x3b, 0xa, 0x20, 0x20, 0x66,
|
||||
0x6f, 0x6e, 0x74, 0x2d, 0x66, 0x61, 0x6d, 0x69, 0x6c, 0x79,
|
||||
0x3a, 0x61, 0x72, 0x69, 0x61, 0x6c, 0x2c, 0x68, 0x65, 0x6c,
|
||||
0x76, 0x65, 0x74, 0x69, 0x63, 0x61, 0x3b, 0xa, 0x7d, 0xa,
|
||||
0xa, 0x2e, 0x6d, 0x65, 0x6e, 0x75, 0xa, 0x7b, 0xa, 0x20,
|
||||
0x20, 0x6d, 0x61, 0x72, 0x67, 0x69, 0x6e, 0x3a, 0x20, 0x34,
|
||||
0x70, 0x78, 0x3b, 0xa, 0x20, 0x20, 0x77, 0x69, 0x64, 0x74,
|
||||
0x68, 0x3a, 0x36, 0x30, 0x25, 0x3b, 0xa, 0xa, 0x20, 0x20,
|
||||
0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x3a, 0x32, 0x70,
|
||||
0x78, 0x3b, 0xa, 0x9, 0xa, 0x20, 0x20, 0x62, 0x6f, 0x72,
|
||||
0x64, 0x65, 0x72, 0x3a, 0x20, 0x73, 0x6f, 0x6c, 0x69, 0x64,
|
||||
0x20, 0x31, 0x70, 0x78, 0x3b, 0xa, 0x20, 0x20, 0x62, 0x61,
|
||||
0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x2d, 0x63,
|
||||
0x6f, 0x6c, 0x6f, 0x72, 0x3a, 0x20, 0x23, 0x66, 0x66, 0x66,
|
||||
0x63, 0x64, 0x32, 0x3b, 0xa, 0x20, 0x20, 0x74, 0x65, 0x78,
|
||||
0x74, 0x2d, 0x61, 0x6c, 0x69, 0x67, 0x6e, 0x3a, 0x6c, 0x65,
|
||||
0x66, 0x74, 0x3b, 0xa, 0x20, 0x20, 0xa, 0x20, 0x20, 0x66,
|
||||
0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a, 0x39,
|
||||
0x70, 0x74, 0x3b, 0xa, 0x20, 0x20, 0x66, 0x6f, 0x6e, 0x74,
|
||||
0x2d, 0x66, 0x61, 0x6d, 0x69, 0x6c, 0x79, 0x3a, 0x61, 0x72,
|
||||
0x69, 0x61, 0x6c, 0x2c, 0x68, 0x65, 0x6c, 0x76, 0x65, 0x74,
|
||||
0x69, 0x63, 0x61, 0x3b, 0x20, 0x20, 0xa, 0x7d, 0xa, 0xa,
|
||||
0x64, 0x69, 0x76, 0x2e, 0x6d, 0x65, 0x6e, 0x75, 0x62, 0x6f,
|
||||
0x78, 0xa, 0x7b, 0xa, 0x20, 0x20, 0x77, 0x69, 0x64, 0x74,
|
||||
0x68, 0x3a, 0x20, 0x32, 0x35, 0x25, 0x3b, 0xa, 0x20, 0x20,
|
||||
0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x3a, 0x20, 0x30, 0x3b,
|
||||
0xa, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x3a, 0x20,
|
||||
0x6c, 0x65, 0x66, 0x74, 0x3b, 0xa, 0x74, 0x65, 0x78, 0x74,
|
||||
0x2d, 0x61, 0x6c, 0x69, 0x67, 0x6e, 0x3a, 0x20, 0x63, 0x65,
|
||||
0x6e, 0x74, 0x65, 0x72, 0x3b, 0xa, 0x7d, 0xa, 0xa, 0x2e,
|
||||
0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x62, 0x6c, 0x6f,
|
||||
0x63, 0x6b, 0xa, 0x7b, 0x20, 0x20, 0xa, 0x20, 0x20, 0x6d,
|
||||
0x61, 0x72, 0x67, 0x69, 0x6e, 0x3a, 0x20, 0x34, 0x70, 0x78,
|
||||
0x3b, 0xa, 0x20, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3a,
|
||||
0x36, 0x30, 0x25, 0x3b, 0xa, 0xa, 0x20, 0x20, 0x70, 0x61,
|
||||
0x64, 0x64, 0x69, 0x6e, 0x67, 0x3a, 0x32, 0x70, 0x78, 0x3b,
|
||||
0xa, 0xa, 0x20, 0x20, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72,
|
||||
0x3a, 0x20, 0x31, 0x70, 0x78, 0x20, 0x64, 0x6f, 0x74, 0x74,
|
||||
0x65, 0x64, 0x3b, 0xa, 0x20, 0x20, 0x62, 0x61, 0x63, 0x6b,
|
||||
0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x2d, 0x63, 0x6f, 0x6c,
|
||||
0x6f, 0x72, 0x3a, 0x20, 0x77, 0x68, 0x69, 0x74, 0x65, 0x3b,
|
||||
0xa, 0xa, 0x20, 0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73,
|
||||
0x69, 0x7a, 0x65, 0x3a, 0x38, 0x70, 0x74, 0x3b, 0xa, 0x20,
|
||||
0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x66, 0x61, 0x6d, 0x69,
|
||||
0x6c, 0x79, 0x3a, 0x61, 0x72, 0x69, 0x61, 0x6c, 0x2c, 0x68,
|
||||
0x65, 0x6c, 0x76, 0x65, 0x74, 0x69, 0x63, 0x61, 0x3b, 0x20,
|
||||
0x20, 0xa, 0xa, 0x7d, 0xa, 0xa, 0x70, 0x2e, 0x69, 0x6e,
|
||||
0x74, 0x72, 0x6f, 0xa, 0x7b, 0xa, 0x20, 0x20, 0x6d, 0x61,
|
||||
0x72, 0x67, 0x69, 0x6e, 0x2d, 0x6c, 0x65, 0x66, 0x74, 0x3a,
|
||||
0x32, 0x30, 0x70, 0x78, 0x3b, 0xa, 0x20, 0x20, 0x6d, 0x61,
|
||||
0x72, 0x67, 0x69, 0x6e, 0x2d, 0x72, 0x69, 0x67, 0x68, 0x74,
|
||||
0x3a, 0x32, 0x30, 0x70, 0x78, 0x3b, 0xa, 0xa, 0x20, 0x20,
|
||||
0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a,
|
||||
0x31, 0x30, 0x70, 0x74, 0x3b, 0xa, 0x2f, 0x2a, 0x20, 0x20,
|
||||
0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x77, 0x65, 0x69, 0x67, 0x68,
|
||||
0x74, 0x3a, 0x62, 0x6f, 0x6c, 0x64, 0x3b, 0x20, 0x2a, 0x2f,
|
||||
0xa, 0x20, 0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x66, 0x61,
|
||||
0x6d, 0x69, 0x6c, 0x79, 0x3a, 0x61, 0x72, 0x69, 0x61, 0x6c,
|
||||
0x2c, 0x68, 0x65, 0x6c, 0x76, 0x65, 0x74, 0x69, 0x63, 0x61,
|
||||
0x3b, 0x20, 0x20, 0xa, 0x7d, 0xa, 0xa, 0x70, 0x2e, 0x63,
|
||||
0x6c, 0x69, 0x6e, 0x6b, 0xa, 0x7b, 0xa, 0x20, 0x20, 0x66,
|
||||
0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a, 0x31,
|
||||
0x32, 0x70, 0x74, 0x3b, 0xa, 0x20, 0x20, 0x66, 0x6f, 0x6e,
|
||||
0x74, 0x2d, 0x66, 0x61, 0x6d, 0x69, 0x6c, 0x79, 0x3a, 0x63,
|
||||
0x6f, 0x75, 0x72, 0x69, 0x65, 0x72, 0x2c, 0x6d, 0x6f, 0x6e,
|
||||
0x6f, 0x73, 0x70, 0x61, 0x63, 0x65, 0x3b, 0x20, 0x20, 0xa,
|
||||
0x20, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2d, 0x61, 0x6c, 0x69,
|
||||
0x67, 0x6e, 0x3a, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x3b,
|
||||
0xa, 0x7d, 0xa, 0xa, 0x70, 0x2e, 0x63, 0x6c, 0x69, 0x6e,
|
||||
0x6b, 0x39, 0xa, 0x7b, 0xa, 0x20, 0x20, 0x66, 0x6f, 0x6e,
|
||||
0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a, 0x39, 0x70, 0x74,
|
||||
0x3b, 0xa, 0x20, 0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x66,
|
||||
0x61, 0x6d, 0x69, 0x6c, 0x79, 0x3a, 0x63, 0x6f, 0x75, 0x72,
|
||||
0x69, 0x65, 0x72, 0x2c, 0x6d, 0x6f, 0x6e, 0x6f, 0x73, 0x70,
|
||||
0x61, 0x63, 0x65, 0x3b, 0x20, 0x20, 0xa, 0x20, 0x20, 0x74,
|
||||
0x65, 0x78, 0x74, 0x2d, 0x61, 0x6c, 0x69, 0x67, 0x6e, 0x3a,
|
||||
0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x3b, 0xa, 0x7d, 0xa,
|
||||
0xa, 0xa, 0x70, 0xa, 0x7b, 0xa, 0x20, 0x20, 0x70, 0x61,
|
||||
0x64, 0x64, 0x69, 0x6e, 0x67, 0x2d, 0x6c, 0x65, 0x66, 0x74,
|
||||
0x3a, 0x31, 0x30, 0x70, 0x78, 0x3b, 0xa, 0x7d, 0xa, 0xa,
|
||||
0x70, 0x2e, 0x72, 0x69, 0x67, 0x68, 0x74, 0xa, 0x7b, 0xa,
|
||||
0x20, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2d, 0x61, 0x6c, 0x69,
|
||||
0x67, 0x6e, 0x3a, 0x72, 0x69, 0x67, 0x68, 0x74, 0x3b, 0x20,
|
||||
0xa, 0x7d, 0xa, 0xa, 0};
|
||||
|
||||
static const unsigned char data_tcp_shtml[] = {
|
||||
/* /tcp.shtml */
|
||||
0x2f, 0x74, 0x63, 0x70, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0,
|
||||
0x25, 0x21, 0x3a, 0x20, 0x2f, 0x68, 0x65, 0x61, 0x64, 0x65,
|
||||
0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0xa, 0x3c, 0x68, 0x31,
|
||||
0x3e, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x20, 0x63,
|
||||
0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73,
|
||||
0x3c, 0x2f, 0x68, 0x31, 0x3e, 0x3c, 0x62, 0x72, 0x3e, 0x3c,
|
||||
0x74, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x77, 0x69, 0x64, 0x74,
|
||||
0x68, 0x3d, 0x22, 0x31, 0x30, 0x30, 0x25, 0x22, 0x3e, 0xa,
|
||||
0x3c, 0x74, 0x72, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x4c, 0x6f,
|
||||
0x63, 0x61, 0x6c, 0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x74,
|
||||
0x68, 0x3e, 0x52, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x3c, 0x2f,
|
||||
0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x53, 0x74, 0x61,
|
||||
0x74, 0x65, 0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68,
|
||||
0x3e, 0x52, 0x65, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x6d, 0x69,
|
||||
0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x3c, 0x2f, 0x74, 0x68,
|
||||
0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x54, 0x69, 0x6d, 0x65, 0x72,
|
||||
0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x46,
|
||||
0x6c, 0x61, 0x67, 0x73, 0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c,
|
||||
0x2f, 0x74, 0x72, 0x3e, 0xa, 0x25, 0x21, 0x20, 0x74, 0x63,
|
||||
0x70, 0x2d, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69,
|
||||
0x6f, 0x6e, 0x73, 0xa, 0x25, 0x21, 0x3a, 0x20, 0x2f, 0x66,
|
||||
0x6f, 0x6f, 0x74, 0x65, 0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c,
|
||||
0};
|
||||
|
||||
static const unsigned char data_fade_png[] = {
|
||||
/* /fade.png */
|
||||
0x2f, 0x66, 0x61, 0x64, 0x65, 0x2e, 0x70, 0x6e, 0x67, 0,
|
||||
0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 00, 00,
|
||||
00, 0xd, 0x49, 0x48, 0x44, 0x52, 00, 00, 00, 0x4,
|
||||
00, 00, 00, 0xa, 0x8, 0x2, 00, 00, 00, 0x1c,
|
||||
0x99, 0x68, 0x59, 00, 00, 00, 0x9, 0x70, 0x48, 0x59,
|
||||
0x73, 00, 00, 0xb, 0x13, 00, 00, 0xb, 0x13, 0x1,
|
||||
00, 0x9a, 0x9c, 0x18, 00, 00, 00, 0x7, 0x74, 0x49,
|
||||
0x4d, 0x45, 0x7, 0xd6, 0x6, 0x8, 0x14, 0x1b, 0x39, 0xaf,
|
||||
0x5b, 0xc0, 0xe3, 00, 00, 00, 0x1d, 0x74, 0x45, 0x58,
|
||||
0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 00, 0x43,
|
||||
0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74,
|
||||
0x68, 0x20, 0x54, 0x68, 0x65, 0x20, 0x47, 0x49, 0x4d, 0x50,
|
||||
0xef, 0x64, 0x25, 0x6e, 00, 00, 00, 0x3a, 0x49, 0x44,
|
||||
0x41, 0x54, 0x8, 0xd7, 0x75, 0x8c, 0x31, 0x12, 00, 0x10,
|
||||
0x10, 0xc4, 0x2e, 0x37, 0x9e, 0x40, 0x65, 0xfd, 0xff, 0x83,
|
||||
0xf4, 0xa, 0x1c, 0x8d, 0x54, 0x9b, 0xc9, 0xcc, 0x9a, 0x3d,
|
||||
0x90, 0x73, 0x71, 0x67, 0x91, 0xd4, 0x74, 0x36, 0xa9, 0x55,
|
||||
0x1, 0xf8, 0x29, 0x58, 0xc8, 0xbf, 0x48, 0xc4, 0x81, 0x74,
|
||||
0xb, 0xa3, 0xf, 0x7c, 0xdb, 0x4, 0xe8, 0x40, 0x5, 0xdf,
|
||||
0xa1, 0xf3, 0xfc, 0x73, 00, 00, 00, 00, 0x49, 0x45,
|
||||
0x4e, 0x44, 0xae, 0x42, 0x60, 0x82, 0};
|
||||
|
||||
static const unsigned char data_stats_shtml[] = {
|
||||
/* /stats.shtml */
|
||||
0x2f, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0,
|
||||
0x25, 0x21, 0x3a, 0x20, 0x2f, 0x68, 0x65, 0x61, 0x64, 0x65,
|
||||
0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0xa, 0x3c, 0x68, 0x31,
|
||||
0x3e, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x20, 0x73,
|
||||
0x74, 0x61, 0x74, 0x69, 0x73, 0x74, 0x69, 0x63, 0x73, 0x3c,
|
||||
0x2f, 0x68, 0x31, 0x3e, 0xa, 0x3c, 0x63, 0x65, 0x6e, 0x74,
|
||||
0x65, 0x72, 0x3e, 0xa, 0x3c, 0x74, 0x61, 0x62, 0x6c, 0x65,
|
||||
0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3d, 0x22, 0x33, 0x30,
|
||||
0x30, 0x22, 0x20, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x3d,
|
||||
0x22, 0x30, 0x22, 0x3e, 0xa, 0x3c, 0x74, 0x72, 0x3e, 0x3c,
|
||||
0x74, 0x64, 0x3e, 0x3c, 0x70, 0x72, 0x65, 0x3e, 0xa, 0x49,
|
||||
0x50, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x73, 0x20,
|
||||
0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0xa, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x73, 0x20,
|
||||
0x73, 0x65, 0x6e, 0x74, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x73, 0x20, 0x64,
|
||||
0x72, 0x6f, 0x70, 0x70, 0x65, 0x64, 0xa, 0x49, 0x50, 0x20,
|
||||
0x65, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x20, 0x20, 0x20, 0x20,
|
||||
0x49, 0x50, 0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e,
|
||||
0x2f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x20, 0x6c, 0x65,
|
||||
0x6e, 0x67, 0x74, 0x68, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x49, 0x50,
|
||||
0x20, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x2c, 0x20, 0x68,
|
||||
0x69, 0x67, 0x68, 0x20, 0x62, 0x79, 0x74, 0x65, 0xa, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x49, 0x50, 0x20, 0x6c, 0x65, 0x6e, 0x67, 0x74,
|
||||
0x68, 0x2c, 0x20, 0x6c, 0x6f, 0x77, 0x20, 0x62, 0x79, 0x74,
|
||||
0x65, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x49, 0x50, 0x20, 0x66, 0x72,
|
||||
0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0xa, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x20, 0x63, 0x68,
|
||||
0x65, 0x63, 0x6b, 0x73, 0x75, 0x6d, 0xa, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x57, 0x72, 0x6f, 0x6e, 0x67, 0x20, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x63, 0x6f, 0x6c, 0xa, 0x49, 0x43, 0x4d, 0x50, 0x9,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x50, 0x61, 0x63, 0x6b, 0x65,
|
||||
0x74, 0x73, 0x20, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65,
|
||||
0x64, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x50, 0x61, 0x63, 0x6b, 0x65,
|
||||
0x74, 0x73, 0x20, 0x73, 0x65, 0x6e, 0x74, 0xa, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x73, 0x20, 0x64,
|
||||
0x72, 0x6f, 0x70, 0x70, 0x65, 0x64, 0xa, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x54, 0x79, 0x70, 0x65, 0x20, 0x65, 0x72, 0x72, 0x6f, 0x72,
|
||||
0x73, 0xa, 0x54, 0x43, 0x50, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x50, 0x61, 0x63, 0x6b, 0x65,
|
||||
0x74, 0x73, 0x20, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65,
|
||||
0x64, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x50, 0x61, 0x63, 0x6b, 0x65,
|
||||
0x74, 0x73, 0x20, 0x73, 0x65, 0x6e, 0x74, 0xa, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x73, 0x20, 0x64,
|
||||
0x72, 0x6f, 0x70, 0x70, 0x65, 0x64, 0xa, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x43, 0x68, 0x65, 0x63, 0x6b, 0x73, 0x75, 0x6d, 0x20, 0x65,
|
||||
0x72, 0x72, 0x6f, 0x72, 0x73, 0xa, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x44,
|
||||
0x61, 0x74, 0x61, 0x20, 0x70, 0x61, 0x63, 0x6b, 0x65, 0x74,
|
||||
0x73, 0x20, 0x77, 0x69, 0x74, 0x68, 0x6f, 0x75, 0x74, 0x20,
|
||||
0x41, 0x43, 0x4b, 0x73, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x52, 0x65,
|
||||
0x73, 0x65, 0x74, 0x73, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x52, 0x65,
|
||||
0x74, 0x72, 0x61, 0x6e, 0x73, 0x6d, 0x69, 0x73, 0x73, 0x69,
|
||||
0x6f, 0x6e, 0x73, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x4e, 0x6f, 0x20, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74,
|
||||
0x69, 0x6f, 0x6e, 0x20, 0x61, 0x76, 0x61, 0x6c, 0x69, 0x61,
|
||||
0x62, 0x6c, 0x65, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e,
|
||||
0x20, 0x61, 0x74, 0x74, 0x65, 0x6d, 0x70, 0x74, 0x73, 0x20,
|
||||
0x74, 0x6f, 0x20, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0x64, 0x20,
|
||||
0x70, 0x6f, 0x72, 0x74, 0x73, 0xa, 0x3c, 0x2f, 0x70, 0x72,
|
||||
0x65, 0x3e, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x74, 0x64,
|
||||
0x3e, 0x3c, 0x70, 0x72, 0x65, 0x3e, 0x25, 0x21, 0x20, 0x6e,
|
||||
0x65, 0x74, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x73, 0xa, 0x3c,
|
||||
0x2f, 0x70, 0x72, 0x65, 0x3e, 0x3c, 0x2f, 0x74, 0x61, 0x62,
|
||||
0x6c, 0x65, 0x3e, 0xa, 0x3c, 0x2f, 0x63, 0x65, 0x6e, 0x74,
|
||||
0x65, 0x72, 0x3e, 0xa, 0x25, 0x21, 0x3a, 0x20, 0x2f, 0x66,
|
||||
0x6f, 0x6f, 0x74, 0x65, 0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c,
|
||||
0xa, 0};
|
||||
|
||||
const struct httpd_fsdata_file file_processes_shtml[] = {{NULL, data_processes_shtml, data_processes_shtml + 17, sizeof(data_processes_shtml) - 17}};
|
||||
|
||||
const struct httpd_fsdata_file file_404_html[] = {{file_processes_shtml, data_404_html, data_404_html + 10, sizeof(data_404_html) - 10}};
|
||||
|
||||
const struct httpd_fsdata_file file_files_shtml[] = {{file_404_html, data_files_shtml, data_files_shtml + 13, sizeof(data_files_shtml) - 13}};
|
||||
|
||||
const struct httpd_fsdata_file file_footer_html[] = {{file_files_shtml, data_footer_html, data_footer_html + 13, sizeof(data_footer_html) - 13}};
|
||||
|
||||
const struct httpd_fsdata_file file_header_html[] = {{file_footer_html, data_header_html, data_header_html + 13, sizeof(data_header_html) - 13}};
|
||||
|
||||
const struct httpd_fsdata_file file_index_html[] = {{file_header_html, data_index_html, data_index_html + 12, sizeof(data_index_html) - 12}};
|
||||
|
||||
const struct httpd_fsdata_file file_style_css[] = {{file_index_html, data_style_css, data_style_css + 11, sizeof(data_style_css) - 11}};
|
||||
|
||||
const struct httpd_fsdata_file file_tcp_shtml[] = {{file_style_css, data_tcp_shtml, data_tcp_shtml + 11, sizeof(data_tcp_shtml) - 11}};
|
||||
|
||||
const struct httpd_fsdata_file file_fade_png[] = {{file_tcp_shtml, data_fade_png, data_fade_png + 10, sizeof(data_fade_png) - 10}};
|
||||
|
||||
const struct httpd_fsdata_file file_stats_shtml[] = {{file_fade_png, data_stats_shtml, data_stats_shtml + 13, sizeof(data_stats_shtml) - 13}};
|
||||
|
||||
#define HTTPD_FS_ROOT file_stats_shtml
|
||||
|
||||
#define HTTPD_FS_NUMFILES 10
|
64
examples/emac/emac_uip/httpd-fsdata.h
Normal file
64
examples/emac/emac_uip/httpd-fsdata.h
Normal file
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (c) 2001, Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: httpd-fsdata.h,v 1.1 2006/06/07 09:13:08 adam Exp $
|
||||
*/
|
||||
#ifndef __HTTPD_FSDATA_H__
|
||||
#define __HTTPD_FSDATA_H__
|
||||
|
||||
#include "uip.h"
|
||||
|
||||
struct httpd_fsdata_file {
|
||||
const struct httpd_fsdata_file *next;
|
||||
const char *name;
|
||||
const char *data;
|
||||
const int len;
|
||||
#ifdef HTTPD_FS_STATISTICS
|
||||
#if HTTPD_FS_STATISTICS == 1
|
||||
u16_t count;
|
||||
#endif /* HTTPD_FS_STATISTICS */
|
||||
#endif /* HTTPD_FS_STATISTICS */
|
||||
};
|
||||
|
||||
struct httpd_fsdata_file_noconst {
|
||||
struct httpd_fsdata_file *next;
|
||||
char *name;
|
||||
char *data;
|
||||
int len;
|
||||
#ifdef HTTPD_FS_STATISTICS
|
||||
#if HTTPD_FS_STATISTICS == 1
|
||||
u16_t count;
|
||||
#endif /* HTTPD_FS_STATISTICS */
|
||||
#endif /* HTTPD_FS_STATISTICS */
|
||||
};
|
||||
|
||||
#endif /* __HTTPD_FSDATA_H__ */
|
338
examples/emac/emac_uip/httpd.c
Normal file
338
examples/emac/emac_uip/httpd.c
Normal file
@ -0,0 +1,338 @@
|
||||
/**
|
||||
* \addtogroup apps
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* \defgroup httpd Web server
|
||||
* @{
|
||||
* The uIP web server is a very simplistic implementation of an HTTP
|
||||
* server. It can serve web pages and files from a read-only ROM
|
||||
* filesystem, and provides a very small scripting language.
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* Web server
|
||||
* \author
|
||||
* Adam Dunkels <adam@sics.se>
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Copyright (c) 2004, Adam Dunkels.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the uIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: httpd.c,v 1.2 2006/06/11 21:46:38 adam Exp $
|
||||
*/
|
||||
|
||||
#include "uip.h"
|
||||
#include "httpd.h"
|
||||
#include "httpd-fs.h"
|
||||
#include "httpd-cgi.h"
|
||||
#include "http-strings.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#define STATE_WAITING 0
|
||||
#define STATE_OUTPUT 1
|
||||
|
||||
#define ISO_nl 0x0a
|
||||
#define ISO_space 0x20
|
||||
#define ISO_bang 0x21
|
||||
#define ISO_percent 0x25
|
||||
#define ISO_period 0x2e
|
||||
#define ISO_slash 0x2f
|
||||
#define ISO_colon 0x3a
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static unsigned short
|
||||
generate_part_of_file(void *state)
|
||||
{
|
||||
struct httpd_state *s = (struct httpd_state *)state;
|
||||
|
||||
if(s->file.len > uip_mss()) {
|
||||
s->len = uip_mss();
|
||||
} else {
|
||||
s->len = s->file.len;
|
||||
}
|
||||
memcpy(uip_appdata, s->file.data, s->len);
|
||||
|
||||
return s->len;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static
|
||||
PT_THREAD(send_file(struct httpd_state *s))
|
||||
{
|
||||
PSOCK_BEGIN(&s->sout);
|
||||
|
||||
do {
|
||||
PSOCK_GENERATOR_SEND(&s->sout, generate_part_of_file, s);
|
||||
s->file.len -= s->len;
|
||||
s->file.data += s->len;
|
||||
} while(s->file.len > 0);
|
||||
|
||||
PSOCK_END(&s->sout);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static
|
||||
PT_THREAD(send_part_of_file(struct httpd_state *s))
|
||||
{
|
||||
PSOCK_BEGIN(&s->sout);
|
||||
|
||||
PSOCK_SEND(&s->sout, s->file.data, s->len);
|
||||
|
||||
PSOCK_END(&s->sout);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
next_scriptstate(struct httpd_state *s)
|
||||
{
|
||||
char *p;
|
||||
p = strchr(s->scriptptr, ISO_nl) + 1;
|
||||
s->scriptlen -= (unsigned short)(p - s->scriptptr);
|
||||
s->scriptptr = p;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static
|
||||
PT_THREAD(handle_script(struct httpd_state *s))
|
||||
{
|
||||
char *ptr;
|
||||
|
||||
PT_BEGIN(&s->scriptpt);
|
||||
|
||||
|
||||
while(s->file.len > 0) {
|
||||
|
||||
/* Check if we should start executing a script. */
|
||||
if(*s->file.data == ISO_percent &&
|
||||
*(s->file.data + 1) == ISO_bang) {
|
||||
s->scriptptr = s->file.data + 3;
|
||||
s->scriptlen = s->file.len - 3;
|
||||
if(*(s->scriptptr - 1) == ISO_colon) {
|
||||
httpd_fs_open(s->scriptptr + 1, &s->file);
|
||||
PT_WAIT_THREAD(&s->scriptpt, send_file(s));
|
||||
} else {
|
||||
PT_WAIT_THREAD(&s->scriptpt,
|
||||
httpd_cgi(s->scriptptr)(s, s->scriptptr));
|
||||
}
|
||||
next_scriptstate(s);
|
||||
|
||||
/* The script is over, so we reset the pointers and continue
|
||||
sending the rest of the file. */
|
||||
s->file.data = s->scriptptr;
|
||||
s->file.len = s->scriptlen;
|
||||
} else {
|
||||
/* See if we find the start of script marker in the block of HTML
|
||||
to be sent. */
|
||||
|
||||
if(s->file.len > uip_mss()) {
|
||||
s->len = uip_mss();
|
||||
} else {
|
||||
s->len = s->file.len;
|
||||
}
|
||||
|
||||
if(*s->file.data == ISO_percent) {
|
||||
ptr = strchr(s->file.data + 1, ISO_percent);
|
||||
} else {
|
||||
ptr = strchr(s->file.data, ISO_percent);
|
||||
}
|
||||
if(ptr != NULL &&
|
||||
ptr != s->file.data) {
|
||||
s->len = (int)(ptr - s->file.data);
|
||||
if(s->len >= uip_mss()) {
|
||||
s->len = uip_mss();
|
||||
}
|
||||
}
|
||||
PT_WAIT_THREAD(&s->scriptpt, send_part_of_file(s));
|
||||
s->file.data += s->len;
|
||||
s->file.len -= s->len;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
PT_END(&s->scriptpt);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static
|
||||
PT_THREAD(send_headers(struct httpd_state *s, const char *statushdr))
|
||||
{
|
||||
char *ptr;
|
||||
|
||||
PSOCK_BEGIN(&s->sout);
|
||||
|
||||
PSOCK_SEND_STR(&s->sout, statushdr);
|
||||
|
||||
ptr = strrchr(s->filename, ISO_period);
|
||||
if(ptr == NULL) {
|
||||
PSOCK_SEND_STR(&s->sout, http_content_type_binary);
|
||||
} else if(strncmp(http_html, ptr, 5) == 0 ||
|
||||
strncmp(http_shtml, ptr, 6) == 0) {
|
||||
PSOCK_SEND_STR(&s->sout, http_content_type_html);
|
||||
} else if(strncmp(http_css, ptr, 4) == 0) {
|
||||
PSOCK_SEND_STR(&s->sout, http_content_type_css);
|
||||
} else if(strncmp(http_png, ptr, 4) == 0) {
|
||||
PSOCK_SEND_STR(&s->sout, http_content_type_png);
|
||||
} else if(strncmp(http_gif, ptr, 4) == 0) {
|
||||
PSOCK_SEND_STR(&s->sout, http_content_type_gif);
|
||||
} else if(strncmp(http_jpg, ptr, 4) == 0) {
|
||||
PSOCK_SEND_STR(&s->sout, http_content_type_jpg);
|
||||
} else {
|
||||
PSOCK_SEND_STR(&s->sout, http_content_type_plain);
|
||||
}
|
||||
PSOCK_END(&s->sout);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static
|
||||
PT_THREAD(handle_output(struct httpd_state *s))
|
||||
{
|
||||
char *ptr;
|
||||
|
||||
PT_BEGIN(&s->outputpt);
|
||||
|
||||
if(!httpd_fs_open(s->filename, &s->file)) {
|
||||
httpd_fs_open(http_404_html, &s->file);
|
||||
strcpy(s->filename, http_404_html);
|
||||
PT_WAIT_THREAD(&s->outputpt,
|
||||
send_headers(s,
|
||||
http_header_404));
|
||||
PT_WAIT_THREAD(&s->outputpt,
|
||||
send_file(s));
|
||||
} else {
|
||||
PT_WAIT_THREAD(&s->outputpt,
|
||||
send_headers(s,
|
||||
http_header_200));
|
||||
ptr = strchr(s->filename, ISO_period);
|
||||
if(ptr != NULL && strncmp(ptr, http_shtml, 6) == 0) {
|
||||
PT_INIT(&s->scriptpt);
|
||||
PT_WAIT_THREAD(&s->outputpt, handle_script(s));
|
||||
} else {
|
||||
PT_WAIT_THREAD(&s->outputpt,
|
||||
send_file(s));
|
||||
}
|
||||
}
|
||||
PSOCK_CLOSE(&s->sout);
|
||||
PT_END(&s->outputpt);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static
|
||||
PT_THREAD(handle_input(struct httpd_state *s))
|
||||
{
|
||||
PSOCK_BEGIN(&s->sin);
|
||||
|
||||
PSOCK_READTO(&s->sin, ISO_space);
|
||||
|
||||
|
||||
if(strncmp(s->inputbuf, http_get, 4) != 0) {
|
||||
PSOCK_CLOSE_EXIT(&s->sin);
|
||||
}
|
||||
PSOCK_READTO(&s->sin, ISO_space);
|
||||
|
||||
if(s->inputbuf[0] != ISO_slash) {
|
||||
PSOCK_CLOSE_EXIT(&s->sin);
|
||||
}
|
||||
|
||||
if(s->inputbuf[1] == ISO_space) {
|
||||
strncpy(s->filename, http_index_html, sizeof(s->filename));
|
||||
} else {
|
||||
s->inputbuf[PSOCK_DATALEN(&s->sin) - 1] = 0;
|
||||
strncpy(s->filename, &s->inputbuf[0], sizeof(s->filename));
|
||||
}
|
||||
|
||||
/* httpd_log_file(uip_conn->ripaddr, s->filename);*/
|
||||
|
||||
s->state = STATE_OUTPUT;
|
||||
|
||||
while(1) {
|
||||
PSOCK_READTO(&s->sin, ISO_nl);
|
||||
|
||||
if(strncmp(s->inputbuf, http_referer, 8) == 0) {
|
||||
s->inputbuf[PSOCK_DATALEN(&s->sin) - 2] = 0;
|
||||
/* httpd_log(&s->inputbuf[9]);*/
|
||||
}
|
||||
}
|
||||
|
||||
PSOCK_END(&s->sin);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
handle_connection(struct httpd_state *s)
|
||||
{
|
||||
handle_input(s);
|
||||
if(s->state == STATE_OUTPUT) {
|
||||
handle_output(s);
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
httpd_appcall(void)
|
||||
{
|
||||
struct httpd_state *s = (struct httpd_state *)&(uip_conn->appstate);
|
||||
|
||||
if(uip_closed() || uip_aborted() || uip_timedout()) {
|
||||
} else if(uip_connected()) {
|
||||
PSOCK_INIT(&s->sin, s->inputbuf, sizeof(s->inputbuf) - 1);
|
||||
PSOCK_INIT(&s->sout, s->inputbuf, sizeof(s->inputbuf) - 1);
|
||||
PT_INIT(&s->outputpt);
|
||||
s->state = STATE_WAITING;
|
||||
/* timer_set(&s->timer, CLOCK_SECOND * 100);*/
|
||||
s->timer = 0;
|
||||
handle_connection(s);
|
||||
} else if(s != NULL) {
|
||||
if(uip_poll()) {
|
||||
++s->timer;
|
||||
if(s->timer >= 20) {
|
||||
uip_abort();
|
||||
}
|
||||
} else {
|
||||
s->timer = 0;
|
||||
}
|
||||
handle_connection(s);
|
||||
} else {
|
||||
uip_abort();
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Initialize the web server
|
||||
*
|
||||
* This function initializes the web server and should be
|
||||
* called at system boot-up.
|
||||
*/
|
||||
void
|
||||
httpd_init(void)
|
||||
{
|
||||
uip_listen(HTONS(80));
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @} */
|
62
examples/emac/emac_uip/httpd.h
Normal file
62
examples/emac/emac_uip/httpd.h
Normal file
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2005, Adam Dunkels.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the uIP TCP/IP stack.
|
||||
*
|
||||
* $Id: httpd.h,v 1.2 2006/06/11 21:46:38 adam Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __HTTPD_H__
|
||||
#define __HTTPD_H__
|
||||
|
||||
#include "psock.h"
|
||||
#include "httpd-fs.h"
|
||||
|
||||
struct httpd_state {
|
||||
unsigned char timer;
|
||||
struct psock sin, sout;
|
||||
struct pt outputpt, scriptpt;
|
||||
char inputbuf[50];
|
||||
char filename[20];
|
||||
char state;
|
||||
struct httpd_fs_file file;
|
||||
int len;
|
||||
char *scriptptr;
|
||||
int scriptlen;
|
||||
|
||||
unsigned short count;
|
||||
};
|
||||
|
||||
void httpd_init(void);
|
||||
void httpd_appcall(void);
|
||||
|
||||
void httpd_log(char *msg);
|
||||
void httpd_log_file(u16_t *requester, char *file);
|
||||
|
||||
#endif /* __HTTPD_H__ */
|
76
examples/emac/emac_uip/lc-switch.h
Normal file
76
examples/emac/emac_uip/lc-switch.h
Normal file
@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright (c) 2004-2005, Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the uIP TCP/IP stack
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: lc-switch.h,v 1.2 2006/06/12 08:00:30 adam Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
* \addtogroup lc
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* Implementation of local continuations based on switch() statment
|
||||
* \author Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* This implementation of local continuations uses the C switch()
|
||||
* statement to resume execution of a function somewhere inside the
|
||||
* function's body. The implementation is based on the fact that
|
||||
* switch() statements are able to jump directly into the bodies of
|
||||
* control structures such as if() or while() statmenets.
|
||||
*
|
||||
* This implementation borrows heavily from Simon Tatham's coroutines
|
||||
* implementation in C:
|
||||
* http://www.chiark.greenend.org.uk/~sgtatham/coroutines.html
|
||||
*/
|
||||
|
||||
#ifndef __LC_SWITCH_H__
|
||||
#define __LC_SWTICH_H__
|
||||
|
||||
/* WARNING! lc implementation using switch() does not work if an
|
||||
LC_SET() is done within another switch() statement! */
|
||||
|
||||
/** \hideinitializer */
|
||||
typedef unsigned short lc_t;
|
||||
|
||||
#define LC_INIT(s) s = 0;
|
||||
|
||||
#define LC_RESUME(s) switch(s) { case 0:
|
||||
|
||||
#define LC_SET(s) s = __LINE__; case __LINE__:
|
||||
|
||||
#define LC_END(s) }
|
||||
|
||||
#endif /* __LC_SWITCH_H__ */
|
||||
|
||||
/** @} */
|
131
examples/emac/emac_uip/lc.h
Normal file
131
examples/emac/emac_uip/lc.h
Normal file
@ -0,0 +1,131 @@
|
||||
/*
|
||||
* Copyright (c) 2004-2005, Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the uIP TCP/IP stack
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: lc.h,v 1.2 2006/06/12 08:00:30 adam Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
* \addtogroup pt
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* \defgroup lc Local continuations
|
||||
* @{
|
||||
*
|
||||
* Local continuations form the basis for implementing protothreads. A
|
||||
* local continuation can be <i>set</i> in a specific function to
|
||||
* capture the state of the function. After a local continuation has
|
||||
* been set can be <i>resumed</i> in order to restore the state of the
|
||||
* function at the point where the local continuation was set.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file lc.h
|
||||
* Local continuations
|
||||
* \author
|
||||
* Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef DOXYGEN
|
||||
/**
|
||||
* Initialize a local continuation.
|
||||
*
|
||||
* This operation initializes the local continuation, thereby
|
||||
* unsetting any previously set continuation state.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define LC_INIT(lc)
|
||||
|
||||
/**
|
||||
* Set a local continuation.
|
||||
*
|
||||
* The set operation saves the state of the function at the point
|
||||
* where the operation is executed. As far as the set operation is
|
||||
* concerned, the state of the function does <b>not</b> include the
|
||||
* call-stack or local (automatic) variables, but only the program
|
||||
* counter and such CPU registers that needs to be saved.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define LC_SET(lc)
|
||||
|
||||
/**
|
||||
* Resume a local continuation.
|
||||
*
|
||||
* The resume operation resumes a previously set local continuation, thus
|
||||
* restoring the state in which the function was when the local
|
||||
* continuation was set. If the local continuation has not been
|
||||
* previously set, the resume operation does nothing.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define LC_RESUME(lc)
|
||||
|
||||
/**
|
||||
* Mark the end of local continuation usage.
|
||||
*
|
||||
* The end operation signifies that local continuations should not be
|
||||
* used any more in the function. This operation is not needed for
|
||||
* most implementations of local continuation, but is required by a
|
||||
* few implementations.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define LC_END(lc)
|
||||
|
||||
/**
|
||||
* \var typedef lc_t;
|
||||
*
|
||||
* The local continuation type.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#endif /* DOXYGEN */
|
||||
|
||||
#ifndef __LC_H__
|
||||
#define __LC_H__
|
||||
|
||||
#ifdef LC_CONF_INCLUDE
|
||||
#include LC_CONF_INCLUDE
|
||||
#else
|
||||
#include "lc-switch.h"
|
||||
#endif /* LC_CONF_INCLUDE */
|
||||
|
||||
#endif /* __LC_H__ */
|
||||
|
||||
/** @} */
|
||||
/** @} */
|
338
examples/emac/emac_uip/psock.c
Normal file
338
examples/emac/emac_uip/psock.c
Normal file
@ -0,0 +1,338 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the uIP TCP/IP stack
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: psock.c,v 1.2 2006/06/12 08:00:30 adam Exp $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "uipopt.h"
|
||||
#include "psock.h"
|
||||
#include "uip.h"
|
||||
|
||||
#define STATE_NONE 0
|
||||
#define STATE_ACKED 1
|
||||
#define STATE_READ 2
|
||||
#define STATE_BLOCKED_NEWDATA 3
|
||||
#define STATE_BLOCKED_CLOSE 4
|
||||
#define STATE_BLOCKED_SEND 5
|
||||
#define STATE_DATA_SENT 6
|
||||
|
||||
/*
|
||||
* Return value of the buffering functions that indicates that a
|
||||
* buffer was not filled by incoming data.
|
||||
*
|
||||
*/
|
||||
#define BUF_NOT_FULL 0
|
||||
#define BUF_NOT_FOUND 0
|
||||
|
||||
/*
|
||||
* Return value of the buffering functions that indicates that a
|
||||
* buffer was completely filled by incoming data.
|
||||
*
|
||||
*/
|
||||
#define BUF_FULL 1
|
||||
|
||||
/*
|
||||
* Return value of the buffering functions that indicates that an
|
||||
* end-marker byte was found.
|
||||
*
|
||||
*/
|
||||
#define BUF_FOUND 2
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
buf_setup(struct psock_buf *buf,
|
||||
u8_t *bufptr, u16_t bufsize)
|
||||
{
|
||||
buf->ptr = bufptr;
|
||||
buf->left = bufsize;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static u8_t
|
||||
buf_bufdata(struct psock_buf *buf, u16_t len,
|
||||
u8_t **dataptr, u16_t *datalen)
|
||||
{
|
||||
if(*datalen < buf->left) {
|
||||
memcpy(buf->ptr, *dataptr, *datalen);
|
||||
buf->ptr += *datalen;
|
||||
buf->left -= *datalen;
|
||||
*dataptr += *datalen;
|
||||
*datalen = 0;
|
||||
return BUF_NOT_FULL;
|
||||
} else if(*datalen == buf->left) {
|
||||
memcpy(buf->ptr, *dataptr, *datalen);
|
||||
buf->ptr += *datalen;
|
||||
buf->left = 0;
|
||||
*dataptr += *datalen;
|
||||
*datalen = 0;
|
||||
return BUF_FULL;
|
||||
} else {
|
||||
memcpy(buf->ptr, *dataptr, buf->left);
|
||||
buf->ptr += buf->left;
|
||||
*datalen -= buf->left;
|
||||
*dataptr += buf->left;
|
||||
buf->left = 0;
|
||||
return BUF_FULL;
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static u8_t
|
||||
buf_bufto(register struct psock_buf *buf, u8_t endmarker,
|
||||
register u8_t **dataptr, register u16_t *datalen)
|
||||
{
|
||||
u8_t c;
|
||||
while(buf->left > 0 && *datalen > 0) {
|
||||
c = *buf->ptr = **dataptr;
|
||||
++*dataptr;
|
||||
++buf->ptr;
|
||||
--*datalen;
|
||||
--buf->left;
|
||||
|
||||
if(c == endmarker) {
|
||||
return BUF_FOUND;
|
||||
}
|
||||
}
|
||||
|
||||
if(*datalen == 0) {
|
||||
return BUF_NOT_FOUND;
|
||||
}
|
||||
|
||||
while(*datalen > 0) {
|
||||
c = **dataptr;
|
||||
--*datalen;
|
||||
++*dataptr;
|
||||
|
||||
if(c == endmarker) {
|
||||
return BUF_FOUND | BUF_FULL;
|
||||
}
|
||||
}
|
||||
|
||||
return BUF_FULL;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static char
|
||||
send_data(register struct psock *s)
|
||||
{
|
||||
if(s->state != STATE_DATA_SENT || uip_rexmit()) {
|
||||
if(s->sendlen > uip_mss()) {
|
||||
uip_send(s->sendptr, uip_mss());
|
||||
} else {
|
||||
uip_send(s->sendptr, s->sendlen);
|
||||
}
|
||||
s->state = STATE_DATA_SENT;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static char
|
||||
data_acked(register struct psock *s)
|
||||
{
|
||||
if(s->state == STATE_DATA_SENT && uip_acked()) {
|
||||
if(s->sendlen > uip_mss()) {
|
||||
s->sendlen -= uip_mss();
|
||||
s->sendptr += uip_mss();
|
||||
} else {
|
||||
s->sendptr += s->sendlen;
|
||||
s->sendlen = 0;
|
||||
}
|
||||
s->state = STATE_ACKED;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PT_THREAD(psock_send(register struct psock *s, const char *buf,
|
||||
unsigned int len))
|
||||
{
|
||||
PT_BEGIN(&s->psockpt);
|
||||
|
||||
/* If there is no data to send, we exit immediately. */
|
||||
if(len == 0) {
|
||||
PT_EXIT(&s->psockpt);
|
||||
}
|
||||
|
||||
/* Save the length of and a pointer to the data that is to be
|
||||
sent. */
|
||||
s->sendptr = buf;
|
||||
s->sendlen = len;
|
||||
|
||||
s->state = STATE_NONE;
|
||||
|
||||
/* We loop here until all data is sent. The s->sendlen variable is
|
||||
updated by the data_sent() function. */
|
||||
while(s->sendlen > 0) {
|
||||
|
||||
/*
|
||||
* The condition for this PT_WAIT_UNTIL is a little tricky: the
|
||||
* protothread will wait here until all data has been acknowledged
|
||||
* (data_acked() returns true) and until all data has been sent
|
||||
* (send_data() returns true). The two functions data_acked() and
|
||||
* send_data() must be called in succession to ensure that all
|
||||
* data is sent. Therefore the & operator is used instead of the
|
||||
* && operator, which would cause only the data_acked() function
|
||||
* to be called when it returns false.
|
||||
*/
|
||||
PT_WAIT_UNTIL(&s->psockpt, data_acked(s) & send_data(s));
|
||||
}
|
||||
|
||||
s->state = STATE_NONE;
|
||||
|
||||
PT_END(&s->psockpt);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PT_THREAD(psock_generator_send(register struct psock *s,
|
||||
unsigned short (*generate)(void *), void *arg))
|
||||
{
|
||||
PT_BEGIN(&s->psockpt);
|
||||
|
||||
/* Ensure that there is a generator function to call. */
|
||||
if(generate == NULL) {
|
||||
PT_EXIT(&s->psockpt);
|
||||
}
|
||||
|
||||
/* Call the generator function to generate the data in the
|
||||
uip_appdata buffer. */
|
||||
s->sendlen = generate(arg);
|
||||
s->sendptr = uip_appdata;
|
||||
|
||||
s->state = STATE_NONE;
|
||||
do {
|
||||
/* Call the generator function again if we are called to perform a
|
||||
retransmission. */
|
||||
if(uip_rexmit()) {
|
||||
generate(arg);
|
||||
}
|
||||
/* Wait until all data is sent and acknowledged. */
|
||||
PT_WAIT_UNTIL(&s->psockpt, data_acked(s) & send_data(s));
|
||||
} while(s->sendlen > 0);
|
||||
|
||||
s->state = STATE_NONE;
|
||||
|
||||
PT_END(&s->psockpt);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
u16_t
|
||||
psock_datalen(struct psock *psock)
|
||||
{
|
||||
return psock->bufsize - psock->buf.left;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
char
|
||||
psock_newdata(struct psock *s)
|
||||
{
|
||||
if(s->readlen > 0) {
|
||||
/* There is data in the uip_appdata buffer that has not yet been
|
||||
read with the PSOCK_READ functions. */
|
||||
return 1;
|
||||
} else if(s->state == STATE_READ) {
|
||||
/* All data in uip_appdata buffer already consumed. */
|
||||
s->state = STATE_BLOCKED_NEWDATA;
|
||||
return 0;
|
||||
} else if(uip_newdata()) {
|
||||
/* There is new data that has not been consumed. */
|
||||
return 1;
|
||||
} else {
|
||||
/* There is no new data. */
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PT_THREAD(psock_readto(register struct psock *psock, unsigned char c))
|
||||
{
|
||||
PT_BEGIN(&psock->psockpt);
|
||||
|
||||
buf_setup(&psock->buf, psock->bufptr, psock->bufsize);
|
||||
|
||||
/* XXX: Should add buf_checkmarker() before do{} loop, if
|
||||
incoming data has been handled while waiting for a write. */
|
||||
|
||||
do {
|
||||
if(psock->readlen == 0) {
|
||||
PT_WAIT_UNTIL(&psock->psockpt, psock_newdata(psock));
|
||||
psock->state = STATE_READ;
|
||||
psock->readptr = (u8_t *)uip_appdata;
|
||||
psock->readlen = uip_datalen();
|
||||
}
|
||||
} while((buf_bufto(&psock->buf, c,
|
||||
&psock->readptr,
|
||||
&psock->readlen) & BUF_FOUND) == 0);
|
||||
|
||||
if(psock_datalen(psock) == 0) {
|
||||
psock->state = STATE_NONE;
|
||||
PT_RESTART(&psock->psockpt);
|
||||
}
|
||||
PT_END(&psock->psockpt);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PT_THREAD(psock_readbuf(register struct psock *psock))
|
||||
{
|
||||
PT_BEGIN(&psock->psockpt);
|
||||
|
||||
buf_setup(&psock->buf, psock->bufptr, psock->bufsize);
|
||||
|
||||
/* XXX: Should add buf_checkmarker() before do{} loop, if
|
||||
incoming data has been handled while waiting for a write. */
|
||||
|
||||
do {
|
||||
if(psock->readlen == 0) {
|
||||
PT_WAIT_UNTIL(&psock->psockpt, psock_newdata(psock));
|
||||
printf("Waited for newdata\n");
|
||||
psock->state = STATE_READ;
|
||||
psock->readptr = (u8_t *)uip_appdata;
|
||||
psock->readlen = uip_datalen();
|
||||
}
|
||||
} while(buf_bufdata(&psock->buf, psock->bufsize,
|
||||
&psock->readptr,
|
||||
&psock->readlen) != BUF_FULL);
|
||||
|
||||
if(psock_datalen(psock) == 0) {
|
||||
psock->state = STATE_NONE;
|
||||
PT_RESTART(&psock->psockpt);
|
||||
}
|
||||
PT_END(&psock->psockpt);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
psock_init(register struct psock *psock, char *buffer, unsigned int buffersize)
|
||||
{
|
||||
psock->state = STATE_NONE;
|
||||
psock->readlen = 0;
|
||||
psock->bufptr = buffer;
|
||||
psock->bufsize = buffersize;
|
||||
buf_setup(&psock->buf, buffer, buffersize);
|
||||
PT_INIT(&psock->pt);
|
||||
PT_INIT(&psock->psockpt);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
380
examples/emac/emac_uip/psock.h
Normal file
380
examples/emac/emac_uip/psock.h
Normal file
@ -0,0 +1,380 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the uIP TCP/IP stack
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: psock.h,v 1.3 2006/06/12 08:00:30 adam Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
* \defgroup psock Protosockets library
|
||||
* @{
|
||||
*
|
||||
* The protosocket library provides an interface to the uIP stack that is
|
||||
* similar to the traditional BSD socket interface. Unlike programs
|
||||
* written for the ordinary uIP event-driven interface, programs
|
||||
* written with the protosocket library are executed in a sequential
|
||||
* fashion and does not have to be implemented as explicit state
|
||||
* machines.
|
||||
*
|
||||
* Protosockets only work with TCP connections.
|
||||
*
|
||||
* The protosocket library uses \ref pt protothreads to provide
|
||||
* sequential control flow. This makes the protosockets lightweight in
|
||||
* terms of memory, but also means that protosockets inherits the
|
||||
* functional limitations of protothreads. Each protosocket lives only
|
||||
* within a single function. Automatic variables (stack variables) are
|
||||
* not retained across a protosocket library function call.
|
||||
*
|
||||
* \note Because the protosocket library uses protothreads, local
|
||||
* variables will not always be saved across a call to a protosocket
|
||||
* library function. It is therefore advised that local variables are
|
||||
* used with extreme care.
|
||||
*
|
||||
* The protosocket library provides functions for sending data without
|
||||
* having to deal with retransmissions and acknowledgements, as well
|
||||
* as functions for reading data without having to deal with data
|
||||
* being split across more than one TCP segment.
|
||||
*
|
||||
* Because each protosocket runs as a protothread, the protosocket has to be
|
||||
* started with a call to PSOCK_BEGIN() at the start of the function
|
||||
* in which the protosocket is used. Similarly, the protosocket protothread can
|
||||
* be terminated by a call to PSOCK_EXIT().
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* Protosocket library header file
|
||||
* \author
|
||||
* Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __PSOCK_H__
|
||||
#define __PSOCK_H__
|
||||
|
||||
#include "uipopt.h"
|
||||
#include "pt.h"
|
||||
|
||||
/*
|
||||
* The structure that holds the state of a buffer.
|
||||
*
|
||||
* This structure holds the state of a uIP buffer. The structure has
|
||||
* no user-visible elements, but is used through the functions
|
||||
* provided by the library.
|
||||
*
|
||||
*/
|
||||
struct psock_buf {
|
||||
u8_t *ptr;
|
||||
unsigned short left;
|
||||
};
|
||||
|
||||
/**
|
||||
* The representation of a protosocket.
|
||||
*
|
||||
* The protosocket structrure is an opaque structure with no user-visible
|
||||
* elements.
|
||||
*/
|
||||
struct psock {
|
||||
struct pt pt, psockpt; /* Protothreads - one that's using the psock
|
||||
functions, and one that runs inside the
|
||||
psock functions. */
|
||||
const u8_t *sendptr; /* Pointer to the next data to be sent. */
|
||||
u8_t *readptr; /* Pointer to the next data to be read. */
|
||||
|
||||
char *bufptr; /* Pointer to the buffer used for buffering
|
||||
incoming data. */
|
||||
|
||||
u16_t sendlen; /* The number of bytes left to be sent. */
|
||||
u16_t readlen; /* The number of bytes left to be read. */
|
||||
|
||||
struct psock_buf buf; /* The structure holding the state of the
|
||||
input buffer. */
|
||||
unsigned int bufsize; /* The size of the input buffer. */
|
||||
|
||||
unsigned char state; /* The state of the protosocket. */
|
||||
};
|
||||
|
||||
void psock_init(struct psock *psock, char *buffer, unsigned int buffersize);
|
||||
/**
|
||||
* Initialize a protosocket.
|
||||
*
|
||||
* This macro initializes a protosocket and must be called before the
|
||||
* protosocket is used. The initialization also specifies the input buffer
|
||||
* for the protosocket.
|
||||
*
|
||||
* \param psock (struct psock *) A pointer to the protosocket to be
|
||||
* initialized
|
||||
*
|
||||
* \param buffer (char *) A pointer to the input buffer for the
|
||||
* protosocket.
|
||||
*
|
||||
* \param buffersize (unsigned int) The size of the input buffer.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define PSOCK_INIT(psock, buffer, buffersize) \
|
||||
psock_init(psock, buffer, buffersize)
|
||||
|
||||
/**
|
||||
* Start the protosocket protothread in a function.
|
||||
*
|
||||
* This macro starts the protothread associated with the protosocket and
|
||||
* must come before other protosocket calls in the function it is used.
|
||||
*
|
||||
* \param psock (struct psock *) A pointer to the protosocket to be
|
||||
* started.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define PSOCK_BEGIN(psock) PT_BEGIN(&((psock)->pt))
|
||||
|
||||
PT_THREAD(psock_send(struct psock *psock, const char *buf, unsigned int len));
|
||||
/**
|
||||
* Send data.
|
||||
*
|
||||
* This macro sends data over a protosocket. The protosocket protothread blocks
|
||||
* until all data has been sent and is known to have been received by
|
||||
* the remote end of the TCP connection.
|
||||
*
|
||||
* \param psock (struct psock *) A pointer to the protosocket over which
|
||||
* data is to be sent.
|
||||
*
|
||||
* \param data (char *) A pointer to the data that is to be sent.
|
||||
*
|
||||
* \param datalen (unsigned int) The length of the data that is to be
|
||||
* sent.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define PSOCK_SEND(psock, data, datalen) \
|
||||
PT_WAIT_THREAD(&((psock)->pt), psock_send(psock, data, datalen))
|
||||
|
||||
/**
|
||||
* \brief Send a null-terminated string.
|
||||
* \param psock Pointer to the protosocket.
|
||||
* \param str The string to be sent.
|
||||
*
|
||||
* This function sends a null-terminated string over the
|
||||
* protosocket.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define PSOCK_SEND_STR(psock, str) \
|
||||
PT_WAIT_THREAD(&((psock)->pt), psock_send(psock, str, strlen(str)))
|
||||
|
||||
PT_THREAD(psock_generator_send(struct psock *psock,
|
||||
unsigned short (*f)(void *), void *arg));
|
||||
|
||||
/**
|
||||
* \brief Generate data with a function and send it
|
||||
* \param psock Pointer to the protosocket.
|
||||
* \param generator Pointer to the generator function
|
||||
* \param arg Argument to the generator function
|
||||
*
|
||||
* This function generates data and sends it over the
|
||||
* protosocket. This can be used to dynamically generate
|
||||
* data for a transmission, instead of generating the data
|
||||
* in a buffer beforehand. This function reduces the need for
|
||||
* buffer memory. The generator function is implemented by
|
||||
* the application, and a pointer to the function is given
|
||||
* as an argument with the call to PSOCK_GENERATOR_SEND().
|
||||
*
|
||||
* The generator function should place the generated data
|
||||
* directly in the uip_appdata buffer, and return the
|
||||
* length of the generated data. The generator function is
|
||||
* called by the protosocket layer when the data first is
|
||||
* sent, and once for every retransmission that is needed.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define PSOCK_GENERATOR_SEND(psock, generator, arg) \
|
||||
PT_WAIT_THREAD(&((psock)->pt), \
|
||||
psock_generator_send(psock, generator, arg))
|
||||
|
||||
|
||||
/**
|
||||
* Close a protosocket.
|
||||
*
|
||||
* This macro closes a protosocket and can only be called from within the
|
||||
* protothread in which the protosocket lives.
|
||||
*
|
||||
* \param psock (struct psock *) A pointer to the protosocket that is to
|
||||
* be closed.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define PSOCK_CLOSE(psock) uip_close()
|
||||
|
||||
PT_THREAD(psock_readbuf(struct psock *psock));
|
||||
/**
|
||||
* Read data until the buffer is full.
|
||||
*
|
||||
* This macro will block waiting for data and read the data into the
|
||||
* input buffer specified with the call to PSOCK_INIT(). Data is read
|
||||
* until the buffer is full..
|
||||
*
|
||||
* \param psock (struct psock *) A pointer to the protosocket from which
|
||||
* data should be read.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define PSOCK_READBUF(psock) \
|
||||
PT_WAIT_THREAD(&((psock)->pt), psock_readbuf(psock))
|
||||
|
||||
PT_THREAD(psock_readto(struct psock *psock, unsigned char c));
|
||||
/**
|
||||
* Read data up to a specified character.
|
||||
*
|
||||
* This macro will block waiting for data and read the data into the
|
||||
* input buffer specified with the call to PSOCK_INIT(). Data is only
|
||||
* read until the specifieed character appears in the data stream.
|
||||
*
|
||||
* \param psock (struct psock *) A pointer to the protosocket from which
|
||||
* data should be read.
|
||||
*
|
||||
* \param c (char) The character at which to stop reading.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define PSOCK_READTO(psock, c) \
|
||||
PT_WAIT_THREAD(&((psock)->pt), psock_readto(psock, c))
|
||||
|
||||
/**
|
||||
* The length of the data that was previously read.
|
||||
*
|
||||
* This macro returns the length of the data that was previously read
|
||||
* using PSOCK_READTO() or PSOCK_READ().
|
||||
*
|
||||
* \param psock (struct psock *) A pointer to the protosocket holding the data.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define PSOCK_DATALEN(psock) psock_datalen(psock)
|
||||
|
||||
u16_t psock_datalen(struct psock *psock);
|
||||
|
||||
/**
|
||||
* Exit the protosocket's protothread.
|
||||
*
|
||||
* This macro terminates the protothread of the protosocket and should
|
||||
* almost always be used in conjunction with PSOCK_CLOSE().
|
||||
*
|
||||
* \sa PSOCK_CLOSE_EXIT()
|
||||
*
|
||||
* \param psock (struct psock *) A pointer to the protosocket.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define PSOCK_EXIT(psock) PT_EXIT(&((psock)->pt))
|
||||
|
||||
/**
|
||||
* Close a protosocket and exit the protosocket's protothread.
|
||||
*
|
||||
* This macro closes a protosocket and exits the protosocket's protothread.
|
||||
*
|
||||
* \param psock (struct psock *) A pointer to the protosocket.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define PSOCK_CLOSE_EXIT(psock) \
|
||||
do { \
|
||||
PSOCK_CLOSE(psock); \
|
||||
PSOCK_EXIT(psock); \
|
||||
} while(0)
|
||||
|
||||
/**
|
||||
* Declare the end of a protosocket's protothread.
|
||||
*
|
||||
* This macro is used for declaring that the protosocket's protothread
|
||||
* ends. It must always be used together with a matching PSOCK_BEGIN()
|
||||
* macro.
|
||||
*
|
||||
* \param psock (struct psock *) A pointer to the protosocket.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define PSOCK_END(psock) PT_END(&((psock)->pt))
|
||||
|
||||
char psock_newdata(struct psock *s);
|
||||
|
||||
/**
|
||||
* Check if new data has arrived on a protosocket.
|
||||
*
|
||||
* This macro is used in conjunction with the PSOCK_WAIT_UNTIL()
|
||||
* macro to check if data has arrived on a protosocket.
|
||||
*
|
||||
* \param psock (struct psock *) A pointer to the protosocket.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define PSOCK_NEWDATA(psock) psock_newdata(psock)
|
||||
|
||||
/**
|
||||
* Wait until a condition is true.
|
||||
*
|
||||
* This macro blocks the protothread until the specified condition is
|
||||
* true. The macro PSOCK_NEWDATA() can be used to check if new data
|
||||
* arrives when the protosocket is waiting.
|
||||
*
|
||||
* Typically, this macro is used as follows:
|
||||
*
|
||||
\code
|
||||
PT_THREAD(thread(struct psock *s, struct timer *t))
|
||||
{
|
||||
PSOCK_BEGIN(s);
|
||||
|
||||
PSOCK_WAIT_UNTIL(s, PSOCK_NEWADATA(s) || timer_expired(t));
|
||||
|
||||
if(PSOCK_NEWDATA(s)) {
|
||||
PSOCK_READTO(s, '\n');
|
||||
} else {
|
||||
handle_timed_out(s);
|
||||
}
|
||||
|
||||
PSOCK_END(s);
|
||||
}
|
||||
\endcode
|
||||
*
|
||||
* \param psock (struct psock *) A pointer to the protosocket.
|
||||
* \param condition The condition to wait for.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define PSOCK_WAIT_UNTIL(psock, condition) \
|
||||
PT_WAIT_UNTIL(&((psock)->pt), (condition));
|
||||
|
||||
#define PSOCK_WAIT_THREAD(psock, condition) \
|
||||
PT_WAIT_THREAD(&((psock)->pt), (condition))
|
||||
|
||||
#endif /* __PSOCK_H__ */
|
||||
|
||||
/** @} */
|
323
examples/emac/emac_uip/pt.h
Normal file
323
examples/emac/emac_uip/pt.h
Normal file
@ -0,0 +1,323 @@
|
||||
/*
|
||||
* Copyright (c) 2004-2005, Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the uIP TCP/IP stack
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: pt.h,v 1.2 2006/06/12 08:00:30 adam Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
* \addtogroup pt
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* Protothreads implementation.
|
||||
* \author
|
||||
* Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __PT_H__
|
||||
#define __PT_H__
|
||||
|
||||
#include "lc.h"
|
||||
|
||||
struct pt {
|
||||
lc_t lc;
|
||||
};
|
||||
|
||||
#define PT_WAITING 0
|
||||
#define PT_EXITED 1
|
||||
#define PT_ENDED 2
|
||||
#define PT_YIELDED 3
|
||||
|
||||
/**
|
||||
* \name Initialization
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Initialize a protothread.
|
||||
*
|
||||
* Initializes a protothread. Initialization must be done prior to
|
||||
* starting to execute the protothread.
|
||||
*
|
||||
* \param pt A pointer to the protothread control structure.
|
||||
*
|
||||
* \sa PT_SPAWN()
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define PT_INIT(pt) LC_INIT((pt)->lc)
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* \name Declaration and definition
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Declaration of a protothread.
|
||||
*
|
||||
* This macro is used to declare a protothread. All protothreads must
|
||||
* be declared with this macro.
|
||||
*
|
||||
* \param name_args The name and arguments of the C function
|
||||
* implementing the protothread.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define PT_THREAD(name_args) char name_args
|
||||
|
||||
/**
|
||||
* Declare the start of a protothread inside the C function
|
||||
* implementing the protothread.
|
||||
*
|
||||
* This macro is used to declare the starting point of a
|
||||
* protothread. It should be placed at the start of the function in
|
||||
* which the protothread runs. All C statements above the PT_BEGIN()
|
||||
* invokation will be executed each time the protothread is scheduled.
|
||||
*
|
||||
* \param pt A pointer to the protothread control structure.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define PT_BEGIN(pt) { char PT_YIELD_FLAG = 1; LC_RESUME((pt)->lc)
|
||||
|
||||
/**
|
||||
* Declare the end of a protothread.
|
||||
*
|
||||
* This macro is used for declaring that a protothread ends. It must
|
||||
* always be used together with a matching PT_BEGIN() macro.
|
||||
*
|
||||
* \param pt A pointer to the protothread control structure.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define PT_END(pt) LC_END((pt)->lc); PT_YIELD_FLAG = 0; \
|
||||
PT_INIT(pt); return PT_ENDED; }
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* \name Blocked wait
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Block and wait until condition is true.
|
||||
*
|
||||
* This macro blocks the protothread until the specified condition is
|
||||
* true.
|
||||
*
|
||||
* \param pt A pointer to the protothread control structure.
|
||||
* \param condition The condition.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define PT_WAIT_UNTIL(pt, condition) \
|
||||
do { \
|
||||
LC_SET((pt)->lc); \
|
||||
if(!(condition)) { \
|
||||
return PT_WAITING; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
/**
|
||||
* Block and wait while condition is true.
|
||||
*
|
||||
* This function blocks and waits while condition is true. See
|
||||
* PT_WAIT_UNTIL().
|
||||
*
|
||||
* \param pt A pointer to the protothread control structure.
|
||||
* \param cond The condition.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define PT_WAIT_WHILE(pt, cond) PT_WAIT_UNTIL((pt), !(cond))
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* \name Hierarchical protothreads
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Block and wait until a child protothread completes.
|
||||
*
|
||||
* This macro schedules a child protothread. The current protothread
|
||||
* will block until the child protothread completes.
|
||||
*
|
||||
* \note The child protothread must be manually initialized with the
|
||||
* PT_INIT() function before this function is used.
|
||||
*
|
||||
* \param pt A pointer to the protothread control structure.
|
||||
* \param thread The child protothread with arguments
|
||||
*
|
||||
* \sa PT_SPAWN()
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define PT_WAIT_THREAD(pt, thread) PT_WAIT_WHILE((pt), PT_SCHEDULE(thread))
|
||||
|
||||
/**
|
||||
* Spawn a child protothread and wait until it exits.
|
||||
*
|
||||
* This macro spawns a child protothread and waits until it exits. The
|
||||
* macro can only be used within a protothread.
|
||||
*
|
||||
* \param pt A pointer to the protothread control structure.
|
||||
* \param child A pointer to the child protothread's control structure.
|
||||
* \param thread The child protothread with arguments
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define PT_SPAWN(pt, child, thread) \
|
||||
do { \
|
||||
PT_INIT((child)); \
|
||||
PT_WAIT_THREAD((pt), (thread)); \
|
||||
} while(0)
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* \name Exiting and restarting
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Restart the protothread.
|
||||
*
|
||||
* This macro will block and cause the running protothread to restart
|
||||
* its execution at the place of the PT_BEGIN() call.
|
||||
*
|
||||
* \param pt A pointer to the protothread control structure.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define PT_RESTART(pt) \
|
||||
do { \
|
||||
PT_INIT(pt); \
|
||||
return PT_WAITING; \
|
||||
} while(0)
|
||||
|
||||
/**
|
||||
* Exit the protothread.
|
||||
*
|
||||
* This macro causes the protothread to exit. If the protothread was
|
||||
* spawned by another protothread, the parent protothread will become
|
||||
* unblocked and can continue to run.
|
||||
*
|
||||
* \param pt A pointer to the protothread control structure.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define PT_EXIT(pt) \
|
||||
do { \
|
||||
PT_INIT(pt); \
|
||||
return PT_EXITED; \
|
||||
} while(0)
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* \name Calling a protothread
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Schedule a protothread.
|
||||
*
|
||||
* This function shedules a protothread. The return value of the
|
||||
* function is non-zero if the protothread is running or zero if the
|
||||
* protothread has exited.
|
||||
*
|
||||
* \param f The call to the C function implementing the protothread to
|
||||
* be scheduled
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define PT_SCHEDULE(f) ((f) == PT_WAITING)
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* \name Yielding from a protothread
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Yield from the current protothread.
|
||||
*
|
||||
* This function will yield the protothread, thereby allowing other
|
||||
* processing to take place in the system.
|
||||
*
|
||||
* \param pt A pointer to the protothread control structure.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define PT_YIELD(pt) \
|
||||
do { \
|
||||
PT_YIELD_FLAG = 0; \
|
||||
LC_SET((pt)->lc); \
|
||||
if(PT_YIELD_FLAG == 0) { \
|
||||
return PT_YIELDED; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
/**
|
||||
* \brief Yield from the protothread until a condition occurs.
|
||||
* \param pt A pointer to the protothread control structure.
|
||||
* \param cond The condition.
|
||||
*
|
||||
* This function will yield the protothread, until the
|
||||
* specified condition evaluates to true.
|
||||
*
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define PT_YIELD_UNTIL(pt, cond) \
|
||||
do { \
|
||||
PT_YIELD_FLAG = 0; \
|
||||
LC_SET((pt)->lc); \
|
||||
if((PT_YIELD_FLAG == 0) || !(cond)) { \
|
||||
return PT_YIELDED; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
/** @} */
|
||||
|
||||
#endif /* __PT_H__ */
|
||||
|
||||
/** @} */
|
75
examples/emac/emac_uip/tapdev.c
Normal file
75
examples/emac/emac_uip/tapdev.c
Normal file
@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright (c) 2001, Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: tapdev.c,v 1.8 2006/06/07 08:39:58 adam Exp $
|
||||
*/
|
||||
|
||||
#define UIP_DRIPADDR0 192
|
||||
#define UIP_DRIPADDR1 168
|
||||
#define UIP_DRIPADDR2 0
|
||||
#define UIP_DRIPADDR3 1
|
||||
|
||||
#include "uip.h"
|
||||
|
||||
#include "bl702_common.h"
|
||||
#include "bl702_glb.h"
|
||||
#include "bl702_emac.h"
|
||||
#include "bflb_platform.h"
|
||||
|
||||
#include "emac_bd.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
tapdev_init(void)
|
||||
{
|
||||
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
unsigned int
|
||||
tapdev_read(void)
|
||||
{
|
||||
BL_Err_Type ret;
|
||||
uint32_t len;
|
||||
|
||||
ret = EMAC_BD_RX_dequeue(-1, &len, uip_buf);
|
||||
len = (SUCCESS == ret) ? len : 0;
|
||||
|
||||
return len;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
tapdev_send(void)
|
||||
{
|
||||
EMAC_BD_TX_enqueue(-1, uip_len, uip_buf);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
45
examples/emac/emac_uip/tapdev.h
Normal file
45
examples/emac/emac_uip/tapdev.h
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) 2001, Adam Dunkels.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Adam Dunkels.
|
||||
* 4. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the uIP TCP/IP stack.
|
||||
*
|
||||
* $Id: tapdev.h,v 1.1 2002/01/10 06:22:56 adam Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __TAPDEV_H__
|
||||
#define __TAPDEV_H__
|
||||
|
||||
void tapdev_init(void);
|
||||
unsigned int tapdev_read(void);
|
||||
void tapdev_send(void);
|
||||
|
||||
#endif /* __TAPDEV_H__ */
|
127
examples/emac/emac_uip/timer.c
Normal file
127
examples/emac/emac_uip/timer.c
Normal file
@ -0,0 +1,127 @@
|
||||
/**
|
||||
* \addtogroup timer
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* Timer library implementation.
|
||||
* \author
|
||||
* Adam Dunkels <adam@sics.se>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2004, Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the uIP TCP/IP stack
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: timer.c,v 1.2 2006/06/12 08:00:30 adam Exp $
|
||||
*/
|
||||
|
||||
#include "clock.h"
|
||||
#include "timer.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* Set a timer.
|
||||
*
|
||||
* This function is used to set a timer for a time sometime in the
|
||||
* future. The function timer_expired() will evaluate to true after
|
||||
* the timer has expired.
|
||||
*
|
||||
* \param t A pointer to the timer
|
||||
* \param interval The interval before the timer expires.
|
||||
*
|
||||
*/
|
||||
void
|
||||
timer_set(struct timer *t, clock_time_t interval)
|
||||
{
|
||||
t->interval = interval;
|
||||
t->start = clock_time();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* Reset the timer with the same interval.
|
||||
*
|
||||
* This function resets the timer with the same interval that was
|
||||
* given to the timer_set() function. The start point of the interval
|
||||
* is the exact time that the timer last expired. Therefore, this
|
||||
* function will cause the timer to be stable over time, unlike the
|
||||
* timer_rester() function.
|
||||
*
|
||||
* \param t A pointer to the timer.
|
||||
*
|
||||
* \sa timer_restart()
|
||||
*/
|
||||
void
|
||||
timer_reset(struct timer *t)
|
||||
{
|
||||
t->start += t->interval;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* Restart the timer from the current point in time
|
||||
*
|
||||
* This function restarts a timer with the same interval that was
|
||||
* given to the timer_set() function. The timer will start at the
|
||||
* current time.
|
||||
*
|
||||
* \note A periodic timer will drift if this function is used to reset
|
||||
* it. For preioric timers, use the timer_reset() function instead.
|
||||
*
|
||||
* \param t A pointer to the timer.
|
||||
*
|
||||
* \sa timer_reset()
|
||||
*/
|
||||
void
|
||||
timer_restart(struct timer *t)
|
||||
{
|
||||
t->start = clock_time();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* Check if a timer has expired.
|
||||
*
|
||||
* This function tests if a timer has expired and returns true or
|
||||
* false depending on its status.
|
||||
*
|
||||
* \param t A pointer to the timer
|
||||
*
|
||||
* \return Non-zero if the timer has expired, zero otherwise.
|
||||
*
|
||||
*/
|
||||
int
|
||||
timer_expired(struct timer *t)
|
||||
{
|
||||
return (clock_time_t)(clock_time() - t->start) >= (clock_time_t)t->interval;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/** @} */
|
86
examples/emac/emac_uip/timer.h
Normal file
86
examples/emac/emac_uip/timer.h
Normal file
@ -0,0 +1,86 @@
|
||||
/**
|
||||
* \defgroup timer Timer library
|
||||
*
|
||||
* The timer library provides functions for setting, resetting and
|
||||
* restarting timers, and for checking if a timer has expired. An
|
||||
* application must "manually" check if its timers have expired; this
|
||||
* is not done automatically.
|
||||
*
|
||||
* A timer is declared as a \c struct \c timer and all access to the
|
||||
* timer is made by a pointer to the declared timer.
|
||||
*
|
||||
* \note The timer library uses the \ref clock "Clock library" to
|
||||
* measure time. Intervals should be specified in the format used by
|
||||
* the clock library.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* \file
|
||||
* Timer library header file.
|
||||
* \author
|
||||
* Adam Dunkels <adam@sics.se>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2004, Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the uIP TCP/IP stack
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: timer.h,v 1.3 2006/06/11 21:46:39 adam Exp $
|
||||
*/
|
||||
#ifndef __TIMER_H__
|
||||
#define __TIMER_H__
|
||||
|
||||
#include "clock.h"
|
||||
|
||||
/**
|
||||
* A timer.
|
||||
*
|
||||
* This structure is used for declaring a timer. The timer must be set
|
||||
* with timer_set() before it can be used.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
struct timer {
|
||||
clock_time_t start;
|
||||
clock_time_t interval;
|
||||
};
|
||||
|
||||
void timer_set(struct timer *t, clock_time_t interval);
|
||||
void timer_reset(struct timer *t);
|
||||
void timer_restart(struct timer *t);
|
||||
int timer_expired(struct timer *t);
|
||||
|
||||
#endif /* __TIMER_H__ */
|
||||
|
||||
/** @} */
|
157
examples/emac/emac_uip/uip-conf.h
Normal file
157
examples/emac/emac_uip/uip-conf.h
Normal file
@ -0,0 +1,157 @@
|
||||
/**
|
||||
* \addtogroup uipopt
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* \name Project-specific configuration options
|
||||
* @{
|
||||
*
|
||||
* uIP has a number of configuration options that can be overridden
|
||||
* for each project. These are kept in a project-specific uip-conf.h
|
||||
* file and all configuration names have the prefix UIP_CONF.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006, Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the uIP TCP/IP stack
|
||||
*
|
||||
* $Id: uip-conf.h,v 1.6 2006/06/12 08:00:31 adam Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* An example uIP configuration file
|
||||
* \author
|
||||
* Adam Dunkels <adam@sics.se>
|
||||
*/
|
||||
|
||||
#ifndef __UIP_CONF_H__
|
||||
#define __UIP_CONF_H__
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
/**
|
||||
* 8 bit datatype
|
||||
*
|
||||
* This typedef defines the 8-bit type used throughout uIP.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
typedef uint8_t u8_t;
|
||||
|
||||
/**
|
||||
* 16 bit datatype
|
||||
*
|
||||
* This typedef defines the 16-bit type used throughout uIP.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
typedef uint16_t u16_t;
|
||||
|
||||
/**
|
||||
* Statistics datatype
|
||||
*
|
||||
* This typedef defines the dataype used for keeping statistics in
|
||||
* uIP.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
typedef unsigned short uip_stats_t;
|
||||
|
||||
/**
|
||||
* Maximum number of TCP connections.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define UIP_CONF_MAX_CONNECTIONS 40
|
||||
|
||||
/**
|
||||
* Maximum number of listening TCP ports.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define UIP_CONF_MAX_LISTENPORTS 40
|
||||
|
||||
/**
|
||||
* uIP buffer size.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define UIP_CONF_BUFFER_SIZE 420
|
||||
|
||||
/**
|
||||
* CPU byte order.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define UIP_CONF_BYTE_ORDER LITTLE_ENDIAN
|
||||
|
||||
/**
|
||||
* Logging on or off
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define UIP_CONF_LOGGING 1
|
||||
|
||||
/**
|
||||
* UDP support on or off
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define UIP_CONF_UDP 0
|
||||
|
||||
/**
|
||||
* UDP checksums on or off
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define UIP_CONF_UDP_CHECKSUMS 1
|
||||
|
||||
/**
|
||||
* uIP statistics on or off
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define UIP_CONF_STATISTICS 1
|
||||
|
||||
/* Here we include the header file for the application(s) we use in
|
||||
our project. */
|
||||
/*#include "smtp.h"*/
|
||||
/*#include "hello-world.h"*/
|
||||
/*#include "telnetd.h"*/
|
||||
#include "webserver.h"
|
||||
/*#include "dhcpc.h"*/
|
||||
/*#include "resolv.h"*/
|
||||
/*#include "webclient.h"*/
|
||||
|
||||
#endif /* __UIP_CONF_H__ */
|
||||
|
||||
/** @} */
|
||||
/** @} */
|
1897
examples/emac/emac_uip/uip.c
Normal file
1897
examples/emac/emac_uip/uip.c
Normal file
File diff suppressed because it is too large
Load Diff
1601
examples/emac/emac_uip/uip.h
Normal file
1601
examples/emac/emac_uip/uip.h
Normal file
File diff suppressed because it is too large
Load Diff
138
examples/emac/emac_uip/uip_arch.h
Normal file
138
examples/emac/emac_uip/uip_arch.h
Normal file
@ -0,0 +1,138 @@
|
||||
/**
|
||||
* \addtogroup uip
|
||||
* {@
|
||||
*/
|
||||
|
||||
/**
|
||||
* \defgroup uiparch Architecture specific uIP functions
|
||||
* @{
|
||||
*
|
||||
* The functions in the architecture specific module implement the IP
|
||||
* check sum and 32-bit additions.
|
||||
*
|
||||
* The IP checksum calculation is the most computationally expensive
|
||||
* operation in the TCP/IP stack and it therefore pays off to
|
||||
* implement this in efficient assembler. The purpose of the uip-arch
|
||||
* module is to let the checksum functions to be implemented in
|
||||
* architecture specific assembler.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* Declarations of architecture specific functions.
|
||||
* \author Adam Dunkels <adam@dunkels.com>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001, Adam Dunkels.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the uIP TCP/IP stack.
|
||||
*
|
||||
* $Id: uip_arch.h,v 1.2 2006/06/07 09:15:19 adam Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __UIP_ARCH_H__
|
||||
#define __UIP_ARCH_H__
|
||||
|
||||
#include "uip.h"
|
||||
|
||||
/**
|
||||
* Carry out a 32-bit addition.
|
||||
*
|
||||
* Because not all architectures for which uIP is intended has native
|
||||
* 32-bit arithmetic, uIP uses an external C function for doing the
|
||||
* required 32-bit additions in the TCP protocol processing. This
|
||||
* function should add the two arguments and place the result in the
|
||||
* global variable uip_acc32.
|
||||
*
|
||||
* \note The 32-bit integer pointed to by the op32 parameter and the
|
||||
* result in the uip_acc32 variable are in network byte order (big
|
||||
* endian).
|
||||
*
|
||||
* \param op32 A pointer to a 4-byte array representing a 32-bit
|
||||
* integer in network byte order (big endian).
|
||||
*
|
||||
* \param op16 A 16-bit integer in host byte order.
|
||||
*/
|
||||
void uip_add32(u8_t *op32, u16_t op16);
|
||||
|
||||
/**
|
||||
* Calculate the Internet checksum over a buffer.
|
||||
*
|
||||
* The Internet checksum is the one's complement of the one's
|
||||
* complement sum of all 16-bit words in the buffer.
|
||||
*
|
||||
* See RFC1071.
|
||||
*
|
||||
* \note This function is not called in the current version of uIP,
|
||||
* but future versions might make use of it.
|
||||
*
|
||||
* \param buf A pointer to the buffer over which the checksum is to be
|
||||
* computed.
|
||||
*
|
||||
* \param len The length of the buffer over which the checksum is to
|
||||
* be computed.
|
||||
*
|
||||
* \return The Internet checksum of the buffer.
|
||||
*/
|
||||
u16_t uip_chksum(u16_t *buf, u16_t len);
|
||||
|
||||
/**
|
||||
* Calculate the IP header checksum of the packet header in uip_buf.
|
||||
*
|
||||
* The IP header checksum is the Internet checksum of the 20 bytes of
|
||||
* the IP header.
|
||||
*
|
||||
* \return The IP header checksum of the IP header in the uip_buf
|
||||
* buffer.
|
||||
*/
|
||||
u16_t uip_ipchksum(void);
|
||||
|
||||
/**
|
||||
* Calculate the TCP checksum of the packet in uip_buf and uip_appdata.
|
||||
*
|
||||
* The TCP checksum is the Internet checksum of data contents of the
|
||||
* TCP segment, and a pseudo-header as defined in RFC793.
|
||||
*
|
||||
* \note The uip_appdata pointer that points to the packet data may
|
||||
* point anywhere in memory, so it is not possible to simply calculate
|
||||
* the Internet checksum of the contents of the uip_buf buffer.
|
||||
*
|
||||
* \return The TCP checksum of the TCP segment in uip_buf and pointed
|
||||
* to by uip_appdata.
|
||||
*/
|
||||
u16_t uip_tcpchksum(void);
|
||||
|
||||
u16_t uip_udpchksum(void);
|
||||
|
||||
/** @} */
|
||||
/** @} */
|
||||
|
||||
#endif /* __UIP_ARCH_H__ */
|
423
examples/emac/emac_uip/uip_arp.c
Normal file
423
examples/emac/emac_uip/uip_arp.c
Normal file
@ -0,0 +1,423 @@
|
||||
/**
|
||||
* \addtogroup uip
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* \defgroup uiparp uIP Address Resolution Protocol
|
||||
* @{
|
||||
*
|
||||
* The Address Resolution Protocol ARP is used for mapping between IP
|
||||
* addresses and link level addresses such as the Ethernet MAC
|
||||
* addresses. ARP uses broadcast queries to ask for the link level
|
||||
* address of a known IP address and the host which is configured with
|
||||
* the IP address for which the query was meant, will respond with its
|
||||
* link level address.
|
||||
*
|
||||
* \note This ARP implementation only supports Ethernet.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* Implementation of the ARP Address Resolution Protocol.
|
||||
* \author Adam Dunkels <adam@dunkels.com>
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2003, Adam Dunkels.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the uIP TCP/IP stack.
|
||||
*
|
||||
* $Id: uip_arp.c,v 1.8 2006/06/02 23:36:21 adam Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "uip_arp.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
struct arp_hdr {
|
||||
struct uip_eth_hdr ethhdr;
|
||||
u16_t hwtype;
|
||||
u16_t protocol;
|
||||
u8_t hwlen;
|
||||
u8_t protolen;
|
||||
u16_t opcode;
|
||||
struct uip_eth_addr shwaddr;
|
||||
u16_t sipaddr[2];
|
||||
struct uip_eth_addr dhwaddr;
|
||||
u16_t dipaddr[2];
|
||||
};
|
||||
|
||||
struct ethip_hdr {
|
||||
struct uip_eth_hdr ethhdr;
|
||||
/* IP header. */
|
||||
u8_t vhl,
|
||||
tos,
|
||||
len[2],
|
||||
ipid[2],
|
||||
ipoffset[2],
|
||||
ttl,
|
||||
proto;
|
||||
u16_t ipchksum;
|
||||
u16_t srcipaddr[2],
|
||||
destipaddr[2];
|
||||
};
|
||||
|
||||
#define ARP_REQUEST 1
|
||||
#define ARP_REPLY 2
|
||||
|
||||
#define ARP_HWTYPE_ETH 1
|
||||
|
||||
struct arp_entry {
|
||||
u16_t ipaddr[2];
|
||||
struct uip_eth_addr ethaddr;
|
||||
u8_t time;
|
||||
};
|
||||
|
||||
static const struct uip_eth_addr broadcast_ethaddr =
|
||||
{{0xff,0xff,0xff,0xff,0xff,0xff}};
|
||||
static const u16_t broadcast_ipaddr[2] = {0xffff,0xffff};
|
||||
|
||||
static struct arp_entry arp_table[UIP_ARPTAB_SIZE];
|
||||
static u16_t ipaddr[2];
|
||||
static u8_t i, c;
|
||||
|
||||
static u8_t arptime;
|
||||
static u8_t tmpage;
|
||||
|
||||
#define BUF ((struct arp_hdr *)&uip_buf[0])
|
||||
#define IPBUF ((struct ethip_hdr *)&uip_buf[0])
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* Initialize the ARP module.
|
||||
*
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
uip_arp_init(void)
|
||||
{
|
||||
for(i = 0; i < UIP_ARPTAB_SIZE; ++i) {
|
||||
memset(arp_table[i].ipaddr, 0, 4);
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* Periodic ARP processing function.
|
||||
*
|
||||
* This function performs periodic timer processing in the ARP module
|
||||
* and should be called at regular intervals. The recommended interval
|
||||
* is 10 seconds between the calls.
|
||||
*
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
uip_arp_timer(void)
|
||||
{
|
||||
struct arp_entry *tabptr;
|
||||
|
||||
++arptime;
|
||||
for(i = 0; i < UIP_ARPTAB_SIZE; ++i) {
|
||||
tabptr = &arp_table[i];
|
||||
if((tabptr->ipaddr[0] | tabptr->ipaddr[1]) != 0 &&
|
||||
arptime - tabptr->time >= UIP_ARP_MAXAGE) {
|
||||
memset(tabptr->ipaddr, 0, 4);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
uip_arp_update(u16_t *ipaddr, struct uip_eth_addr *ethaddr)
|
||||
{
|
||||
register struct arp_entry *tabptr;
|
||||
/* Walk through the ARP mapping table and try to find an entry to
|
||||
update. If none is found, the IP -> MAC address mapping is
|
||||
inserted in the ARP table. */
|
||||
for(i = 0; i < UIP_ARPTAB_SIZE; ++i) {
|
||||
|
||||
tabptr = &arp_table[i];
|
||||
/* Only check those entries that are actually in use. */
|
||||
if(tabptr->ipaddr[0] != 0 &&
|
||||
tabptr->ipaddr[1] != 0) {
|
||||
|
||||
/* Check if the source IP address of the incoming packet matches
|
||||
the IP address in this ARP table entry. */
|
||||
if(ipaddr[0] == tabptr->ipaddr[0] &&
|
||||
ipaddr[1] == tabptr->ipaddr[1]) {
|
||||
|
||||
/* An old entry found, update this and return. */
|
||||
memcpy(tabptr->ethaddr.addr, ethaddr->addr, 6);
|
||||
tabptr->time = arptime;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* If we get here, no existing ARP table entry was found, so we
|
||||
create one. */
|
||||
|
||||
/* First, we try to find an unused entry in the ARP table. */
|
||||
for(i = 0; i < UIP_ARPTAB_SIZE; ++i) {
|
||||
tabptr = &arp_table[i];
|
||||
if(tabptr->ipaddr[0] == 0 &&
|
||||
tabptr->ipaddr[1] == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* If no unused entry is found, we try to find the oldest entry and
|
||||
throw it away. */
|
||||
if(i == UIP_ARPTAB_SIZE) {
|
||||
tmpage = 0;
|
||||
c = 0;
|
||||
for(i = 0; i < UIP_ARPTAB_SIZE; ++i) {
|
||||
tabptr = &arp_table[i];
|
||||
if(arptime - tabptr->time > tmpage) {
|
||||
tmpage = arptime - tabptr->time;
|
||||
c = i;
|
||||
}
|
||||
}
|
||||
i = c;
|
||||
tabptr = &arp_table[i];
|
||||
}
|
||||
|
||||
/* Now, i is the ARP table entry which we will fill with the new
|
||||
information. */
|
||||
memcpy(tabptr->ipaddr, ipaddr, 4);
|
||||
memcpy(tabptr->ethaddr.addr, ethaddr->addr, 6);
|
||||
tabptr->time = arptime;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* ARP processing for incoming IP packets
|
||||
*
|
||||
* This function should be called by the device driver when an IP
|
||||
* packet has been received. The function will check if the address is
|
||||
* in the ARP cache, and if so the ARP cache entry will be
|
||||
* refreshed. If no ARP cache entry was found, a new one is created.
|
||||
*
|
||||
* This function expects an IP packet with a prepended Ethernet header
|
||||
* in the uip_buf[] buffer, and the length of the packet in the global
|
||||
* variable uip_len.
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
#if 0
|
||||
void
|
||||
uip_arp_ipin(void)
|
||||
{
|
||||
uip_len -= sizeof(struct uip_eth_hdr);
|
||||
|
||||
/* Only insert/update an entry if the source IP address of the
|
||||
incoming IP packet comes from a host on the local network. */
|
||||
if((IPBUF->srcipaddr[0] & uip_netmask[0]) !=
|
||||
(uip_hostaddr[0] & uip_netmask[0])) {
|
||||
return;
|
||||
}
|
||||
if((IPBUF->srcipaddr[1] & uip_netmask[1]) !=
|
||||
(uip_hostaddr[1] & uip_netmask[1])) {
|
||||
return;
|
||||
}
|
||||
uip_arp_update(IPBUF->srcipaddr, &(IPBUF->ethhdr.src));
|
||||
|
||||
return;
|
||||
}
|
||||
#endif /* 0 */
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* ARP processing for incoming ARP packets.
|
||||
*
|
||||
* This function should be called by the device driver when an ARP
|
||||
* packet has been received. The function will act differently
|
||||
* depending on the ARP packet type: if it is a reply for a request
|
||||
* that we previously sent out, the ARP cache will be filled in with
|
||||
* the values from the ARP reply. If the incoming ARP packet is an ARP
|
||||
* request for our IP address, an ARP reply packet is created and put
|
||||
* into the uip_buf[] buffer.
|
||||
*
|
||||
* When the function returns, the value of the global variable uip_len
|
||||
* indicates whether the device driver should send out a packet or
|
||||
* not. If uip_len is zero, no packet should be sent. If uip_len is
|
||||
* non-zero, it contains the length of the outbound packet that is
|
||||
* present in the uip_buf[] buffer.
|
||||
*
|
||||
* This function expects an ARP packet with a prepended Ethernet
|
||||
* header in the uip_buf[] buffer, and the length of the packet in the
|
||||
* global variable uip_len.
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
uip_arp_arpin(void)
|
||||
{
|
||||
|
||||
if(uip_len < sizeof(struct arp_hdr)) {
|
||||
uip_len = 0;
|
||||
return;
|
||||
}
|
||||
uip_len = 0;
|
||||
|
||||
switch(BUF->opcode) {
|
||||
case HTONS(ARP_REQUEST):
|
||||
/* ARP request. If it asked for our address, we send out a
|
||||
reply. */
|
||||
if(uip_ipaddr_cmp(BUF->dipaddr, uip_hostaddr)) {
|
||||
/* First, we register the one who made the request in our ARP
|
||||
table, since it is likely that we will do more communication
|
||||
with this host in the future. */
|
||||
uip_arp_update(BUF->sipaddr, &BUF->shwaddr);
|
||||
|
||||
/* The reply opcode is 2. */
|
||||
BUF->opcode = HTONS(2);
|
||||
|
||||
memcpy(BUF->dhwaddr.addr, BUF->shwaddr.addr, 6);
|
||||
memcpy(BUF->shwaddr.addr, uip_ethaddr.addr, 6);
|
||||
memcpy(BUF->ethhdr.src.addr, uip_ethaddr.addr, 6);
|
||||
memcpy(BUF->ethhdr.dest.addr, BUF->dhwaddr.addr, 6);
|
||||
|
||||
BUF->dipaddr[0] = BUF->sipaddr[0];
|
||||
BUF->dipaddr[1] = BUF->sipaddr[1];
|
||||
BUF->sipaddr[0] = uip_hostaddr[0];
|
||||
BUF->sipaddr[1] = uip_hostaddr[1];
|
||||
|
||||
BUF->ethhdr.type = HTONS(UIP_ETHTYPE_ARP);
|
||||
uip_len = sizeof(struct arp_hdr);
|
||||
}
|
||||
break;
|
||||
case HTONS(ARP_REPLY):
|
||||
/* ARP reply. We insert or update the ARP table if it was meant
|
||||
for us. */
|
||||
if(uip_ipaddr_cmp(BUF->dipaddr, uip_hostaddr)) {
|
||||
uip_arp_update(BUF->sipaddr, &BUF->shwaddr);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* Prepend Ethernet header to an outbound IP packet and see if we need
|
||||
* to send out an ARP request.
|
||||
*
|
||||
* This function should be called before sending out an IP packet. The
|
||||
* function checks the destination IP address of the IP packet to see
|
||||
* what Ethernet MAC address that should be used as a destination MAC
|
||||
* address on the Ethernet.
|
||||
*
|
||||
* If the destination IP address is in the local network (determined
|
||||
* by logical ANDing of netmask and our IP address), the function
|
||||
* checks the ARP cache to see if an entry for the destination IP
|
||||
* address is found. If so, an Ethernet header is prepended and the
|
||||
* function returns. If no ARP cache entry is found for the
|
||||
* destination IP address, the packet in the uip_buf[] is replaced by
|
||||
* an ARP request packet for the IP address. The IP packet is dropped
|
||||
* and it is assumed that they higher level protocols (e.g., TCP)
|
||||
* eventually will retransmit the dropped packet.
|
||||
*
|
||||
* If the destination IP address is not on the local network, the IP
|
||||
* address of the default router is used instead.
|
||||
*
|
||||
* When the function returns, a packet is present in the uip_buf[]
|
||||
* buffer, and the length of the packet is in the global variable
|
||||
* uip_len.
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
uip_arp_out(void)
|
||||
{
|
||||
struct arp_entry *tabptr;
|
||||
|
||||
/* Find the destination IP address in the ARP table and construct
|
||||
the Ethernet header. If the destination IP addres isn't on the
|
||||
local network, we use the default router's IP address instead.
|
||||
|
||||
If not ARP table entry is found, we overwrite the original IP
|
||||
packet with an ARP request for the IP address. */
|
||||
|
||||
/* First check if destination is a local broadcast. */
|
||||
if(uip_ipaddr_cmp(IPBUF->destipaddr, broadcast_ipaddr)) {
|
||||
memcpy(IPBUF->ethhdr.dest.addr, broadcast_ethaddr.addr, 6);
|
||||
} else {
|
||||
/* Check if the destination address is on the local network. */
|
||||
if(!uip_ipaddr_maskcmp(IPBUF->destipaddr, uip_hostaddr, uip_netmask)) {
|
||||
/* Destination address was not on the local network, so we need to
|
||||
use the default router's IP address instead of the destination
|
||||
address when determining the MAC address. */
|
||||
uip_ipaddr_copy(ipaddr, uip_draddr);
|
||||
} else {
|
||||
/* Else, we use the destination IP address. */
|
||||
uip_ipaddr_copy(ipaddr, IPBUF->destipaddr);
|
||||
}
|
||||
|
||||
for(i = 0; i < UIP_ARPTAB_SIZE; ++i) {
|
||||
tabptr = &arp_table[i];
|
||||
if(uip_ipaddr_cmp(ipaddr, tabptr->ipaddr)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(i == UIP_ARPTAB_SIZE) {
|
||||
/* The destination address was not in our ARP table, so we
|
||||
overwrite the IP packet with an ARP request. */
|
||||
|
||||
memset(BUF->ethhdr.dest.addr, 0xff, 6);
|
||||
memset(BUF->dhwaddr.addr, 0x00, 6);
|
||||
memcpy(BUF->ethhdr.src.addr, uip_ethaddr.addr, 6);
|
||||
memcpy(BUF->shwaddr.addr, uip_ethaddr.addr, 6);
|
||||
|
||||
uip_ipaddr_copy(BUF->dipaddr, ipaddr);
|
||||
uip_ipaddr_copy(BUF->sipaddr, uip_hostaddr);
|
||||
BUF->opcode = HTONS(ARP_REQUEST); /* ARP request. */
|
||||
BUF->hwtype = HTONS(ARP_HWTYPE_ETH);
|
||||
BUF->protocol = HTONS(UIP_ETHTYPE_IP);
|
||||
BUF->hwlen = 6;
|
||||
BUF->protolen = 4;
|
||||
BUF->ethhdr.type = HTONS(UIP_ETHTYPE_ARP);
|
||||
|
||||
uip_appdata = &uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN];
|
||||
|
||||
uip_len = sizeof(struct arp_hdr);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Build an ethernet header. */
|
||||
memcpy(IPBUF->ethhdr.dest.addr, tabptr->ethaddr.addr, 6);
|
||||
}
|
||||
memcpy(IPBUF->ethhdr.src.addr, uip_ethaddr.addr, 6);
|
||||
|
||||
IPBUF->ethhdr.type = HTONS(UIP_ETHTYPE_IP);
|
||||
|
||||
uip_len += sizeof(struct uip_eth_hdr);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/** @} */
|
||||
/** @} */
|
144
examples/emac/emac_uip/uip_arp.h
Normal file
144
examples/emac/emac_uip/uip_arp.h
Normal file
@ -0,0 +1,144 @@
|
||||
/**
|
||||
* \addtogroup uip
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* \addtogroup uiparp
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* Macros and definitions for the ARP module.
|
||||
* \author Adam Dunkels <adam@dunkels.com>
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2003, Adam Dunkels.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the uIP TCP/IP stack.
|
||||
*
|
||||
* $Id: uip_arp.h,v 1.5 2006/06/11 21:46:39 adam Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __UIP_ARP_H__
|
||||
#define __UIP_ARP_H__
|
||||
|
||||
#include "uip.h"
|
||||
|
||||
|
||||
extern struct uip_eth_addr uip_ethaddr;
|
||||
|
||||
/**
|
||||
* The Ethernet header.
|
||||
*/
|
||||
struct uip_eth_hdr {
|
||||
struct uip_eth_addr dest;
|
||||
struct uip_eth_addr src;
|
||||
u16_t type;
|
||||
};
|
||||
|
||||
#define UIP_ETHTYPE_ARP 0x0806
|
||||
#define UIP_ETHTYPE_IP 0x0800
|
||||
#define UIP_ETHTYPE_IP6 0x86dd
|
||||
|
||||
|
||||
/* The uip_arp_init() function must be called before any of the other
|
||||
ARP functions. */
|
||||
void uip_arp_init(void);
|
||||
|
||||
/* The uip_arp_ipin() function should be called whenever an IP packet
|
||||
arrives from the Ethernet. This function refreshes the ARP table or
|
||||
inserts a new mapping if none exists. The function assumes that an
|
||||
IP packet with an Ethernet header is present in the uip_buf buffer
|
||||
and that the length of the packet is in the uip_len variable. */
|
||||
/*void uip_arp_ipin(void);*/
|
||||
#define uip_arp_ipin()
|
||||
|
||||
/* The uip_arp_arpin() should be called when an ARP packet is received
|
||||
by the Ethernet driver. This function also assumes that the
|
||||
Ethernet frame is present in the uip_buf buffer. When the
|
||||
uip_arp_arpin() function returns, the contents of the uip_buf
|
||||
buffer should be sent out on the Ethernet if the uip_len variable
|
||||
is > 0. */
|
||||
void uip_arp_arpin(void);
|
||||
|
||||
/* The uip_arp_out() function should be called when an IP packet
|
||||
should be sent out on the Ethernet. This function creates an
|
||||
Ethernet header before the IP header in the uip_buf buffer. The
|
||||
Ethernet header will have the correct Ethernet MAC destination
|
||||
address filled in if an ARP table entry for the destination IP
|
||||
address (or the IP address of the default router) is present. If no
|
||||
such table entry is found, the IP packet is overwritten with an ARP
|
||||
request and we rely on TCP to retransmit the packet that was
|
||||
overwritten. In any case, the uip_len variable holds the length of
|
||||
the Ethernet frame that should be transmitted. */
|
||||
void uip_arp_out(void);
|
||||
|
||||
/* The uip_arp_timer() function should be called every ten seconds. It
|
||||
is responsible for flushing old entries in the ARP table. */
|
||||
void uip_arp_timer(void);
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* \addtogroup uipconffunc
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Specifiy the Ethernet MAC address.
|
||||
*
|
||||
* The ARP code needs to know the MAC address of the Ethernet card in
|
||||
* order to be able to respond to ARP queries and to generate working
|
||||
* Ethernet headers.
|
||||
*
|
||||
* \note This macro only specifies the Ethernet MAC address to the ARP
|
||||
* code. It cannot be used to change the MAC address of the Ethernet
|
||||
* card.
|
||||
*
|
||||
* \param eaddr A pointer to a struct uip_eth_addr containing the
|
||||
* Ethernet MAC address of the Ethernet card.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define uip_setethaddr(eaddr) do {uip_ethaddr.addr[0] = eaddr.addr[0]; \
|
||||
uip_ethaddr.addr[1] = eaddr.addr[1];\
|
||||
uip_ethaddr.addr[2] = eaddr.addr[2];\
|
||||
uip_ethaddr.addr[3] = eaddr.addr[3];\
|
||||
uip_ethaddr.addr[4] = eaddr.addr[4];\
|
||||
uip_ethaddr.addr[5] = eaddr.addr[5];} while(0)
|
||||
|
||||
/** @} */
|
||||
/** @} */
|
||||
|
||||
#endif /* __UIP_ARP_H__ */
|
224
examples/emac/emac_uip/uip_main.c
Normal file
224
examples/emac/emac_uip/uip_main.c
Normal file
@ -0,0 +1,224 @@
|
||||
/*
|
||||
* Copyright (c) 2001, Adam Dunkels.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Adam Dunkels.
|
||||
* 4. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the uIP TCP/IP stack.
|
||||
*
|
||||
* $Id: main.c,v 1.16 2006/06/11 21:55:03 adam Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "uip.h"
|
||||
#include "uip_arp.h"
|
||||
#include "tapdev.h"
|
||||
|
||||
#include "timer.h"
|
||||
|
||||
#include "bl702_common.h"
|
||||
#include "bflb_platform.h"
|
||||
#include "bl702_glb.h"
|
||||
#include "bl702_emac.h"
|
||||
|
||||
#define BUF ((struct uip_eth_hdr *)&uip_buf[0])
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL (void *)0
|
||||
#endif /* NULL */
|
||||
|
||||
extern EMAC_CFG_Type emacCfg;
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int
|
||||
uip_main(void)
|
||||
{
|
||||
int i;
|
||||
uip_ipaddr_t ipaddr;
|
||||
struct timer periodic_timer, arp_timer;
|
||||
|
||||
timer_set(&periodic_timer, CLOCK_SECOND / 2);
|
||||
timer_set(&arp_timer, CLOCK_SECOND * 10);
|
||||
|
||||
tapdev_init();
|
||||
uip_init();
|
||||
|
||||
uip_ipaddr(ipaddr, 192,168,29,145);
|
||||
uip_sethostaddr(ipaddr);
|
||||
uip_ipaddr(ipaddr, 192,168,29,1);
|
||||
uip_setdraddr(ipaddr);
|
||||
uip_ipaddr(ipaddr, 255,255,255,0);
|
||||
uip_setnetmask(ipaddr);
|
||||
|
||||
memcpy(uip_ethaddr.addr, emacCfg.macAddr, 6);
|
||||
|
||||
httpd_init();
|
||||
|
||||
/* telnetd_init();*/
|
||||
|
||||
/* hello_world_init();*/
|
||||
|
||||
/* {
|
||||
u8_t mac[6] = {1,2,3,4,5,6};
|
||||
dhcpc_init(&mac, 6);
|
||||
}*/
|
||||
|
||||
/*uip_ipaddr(ipaddr, 127,0,0,1);
|
||||
smtp_configure("localhost", ipaddr);
|
||||
SMTP_SEND("adam@sics.se", NULL, "uip-testing@example.com",
|
||||
"Testing SMTP from uIP",
|
||||
"Test message sent by uIP\r\n");*/
|
||||
|
||||
/*
|
||||
webclient_init();
|
||||
resolv_init();
|
||||
uip_ipaddr(ipaddr, 195,54,122,204);
|
||||
resolv_conf(ipaddr);
|
||||
resolv_query("www.sics.se");*/
|
||||
|
||||
|
||||
|
||||
while(1) {
|
||||
uip_len = tapdev_read();
|
||||
if(uip_len > 0) {
|
||||
if(BUF->type == htons(UIP_ETHTYPE_IP)) {
|
||||
uip_arp_ipin();
|
||||
uip_input();
|
||||
/* If the above function invocation resulted in data that
|
||||
should be sent out on the network, the global variable
|
||||
uip_len is set to a value > 0. */
|
||||
if(uip_len > 0) {
|
||||
uip_arp_out();
|
||||
tapdev_send();
|
||||
}
|
||||
} else if(BUF->type == htons(UIP_ETHTYPE_ARP)) {
|
||||
uip_arp_arpin();
|
||||
/* If the above function invocation resulted in data that
|
||||
should be sent out on the network, the global variable
|
||||
uip_len is set to a value > 0. */
|
||||
if(uip_len > 0) {
|
||||
tapdev_send();
|
||||
}
|
||||
}
|
||||
} else if(timer_expired(&periodic_timer)) {
|
||||
timer_reset(&periodic_timer);
|
||||
for(i = 0; i < UIP_CONNS; i++) {
|
||||
uip_periodic(i);
|
||||
/* If the above function invocation resulted in data that
|
||||
should be sent out on the network, the global variable
|
||||
uip_len is set to a value > 0. */
|
||||
if(uip_len > 0) {
|
||||
uip_arp_out();
|
||||
tapdev_send();
|
||||
}
|
||||
}
|
||||
#if UIP_UDP
|
||||
for(i = 0; i < UIP_UDP_CONNS; i++) {
|
||||
uip_udp_periodic(i);
|
||||
/* If the above function invocation resulted in data that
|
||||
should be sent out on the network, the global variable
|
||||
uip_len is set to a value > 0. */
|
||||
if(uip_len > 0) {
|
||||
uip_arp_out();
|
||||
tapdev_send();
|
||||
}
|
||||
}
|
||||
#endif /* UIP_UDP */
|
||||
/* Call the ARP timer function every 10 seconds. */
|
||||
if(timer_expired(&arp_timer)) {
|
||||
timer_reset(&arp_timer);
|
||||
uip_arp_timer();
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
uip_log(char *m)
|
||||
{
|
||||
MSG("uIP log message: %s\n", m);
|
||||
}
|
||||
void
|
||||
resolv_found(char *name, u16_t *ipaddr)
|
||||
{
|
||||
u16_t *ipaddr2;
|
||||
|
||||
if(ipaddr == NULL) {
|
||||
MSG("Host '%s' not found.\n", name);
|
||||
} else {
|
||||
MSG("Found name '%s' = %d.%d.%d.%d\n", name,
|
||||
htons(ipaddr[0]) >> 8,
|
||||
htons(ipaddr[0]) & 0xff,
|
||||
htons(ipaddr[1]) >> 8,
|
||||
htons(ipaddr[1]) & 0xff);
|
||||
/* webclient_get("www.sics.se", 80, "/~adam/uip");*/
|
||||
}
|
||||
}
|
||||
#ifdef __DHCPC_H__
|
||||
void
|
||||
dhcpc_configured(const struct dhcpc_state *s)
|
||||
{
|
||||
uip_sethostaddr(s->ipaddr);
|
||||
uip_setnetmask(s->netmask);
|
||||
uip_setdraddr(s->default_router);
|
||||
resolv_conf(s->dnsaddr);
|
||||
}
|
||||
#endif /* __DHCPC_H__ */
|
||||
void
|
||||
smtp_done(unsigned char code)
|
||||
{
|
||||
MSG("SMTP done with code %d\n", code);
|
||||
}
|
||||
void
|
||||
webclient_closed(void)
|
||||
{
|
||||
MSG("Webclient: connection closed\n");
|
||||
}
|
||||
void
|
||||
webclient_aborted(void)
|
||||
{
|
||||
MSG("Webclient: connection aborted\n");
|
||||
}
|
||||
void
|
||||
webclient_timedout(void)
|
||||
{
|
||||
MSG("Webclient: connection timed out\n");
|
||||
}
|
||||
void
|
||||
webclient_connected(void)
|
||||
{
|
||||
MSG("Webclient: connected, waiting for data...\n");
|
||||
}
|
||||
void
|
||||
webclient_datahandler(char *data, u16_t len)
|
||||
{
|
||||
MSG("Webclient: got %d bytes of data.\n", len);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
539
examples/emac/emac_uip/uipopt.h
Normal file
539
examples/emac/emac_uip/uipopt.h
Normal file
@ -0,0 +1,539 @@
|
||||
/**
|
||||
* \defgroup uipopt Configuration options for uIP
|
||||
* @{
|
||||
*
|
||||
* uIP is configured using the per-project configuration file
|
||||
* uipopt.h. This file contains all compile-time options for uIP and
|
||||
* should be tweaked to match each specific project. The uIP
|
||||
* distribution contains a documented example "uipopt.h" that can be
|
||||
* copied and modified for each project.
|
||||
*
|
||||
* \note Most of the configuration options in the uipopt.h should not
|
||||
* be changed, but rather the per-project uip-conf.h file.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* Configuration options for uIP.
|
||||
* \author Adam Dunkels <adam@dunkels.com>
|
||||
*
|
||||
* This file is used for tweaking various configuration options for
|
||||
* uIP. You should make a copy of this file into one of your project's
|
||||
* directories instead of editing this example "uipopt.h" file that
|
||||
* comes with the uIP distribution.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2003, Adam Dunkels.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the uIP TCP/IP stack.
|
||||
*
|
||||
* $Id: uipopt.h,v 1.4 2006/06/12 08:00:31 adam Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __UIPOPT_H__
|
||||
#define __UIPOPT_H__
|
||||
|
||||
#ifndef UIP_LITTLE_ENDIAN
|
||||
#define UIP_LITTLE_ENDIAN 3412
|
||||
#endif /* UIP_LITTLE_ENDIAN */
|
||||
#ifndef UIP_BIG_ENDIAN
|
||||
#define UIP_BIG_ENDIAN 1234
|
||||
#endif /* UIP_BIG_ENDIAN */
|
||||
|
||||
#include "uip-conf.h"
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* \name Static configuration options
|
||||
* @{
|
||||
*
|
||||
* These configuration options can be used for setting the IP address
|
||||
* settings statically, but only if UIP_FIXEDADDR is set to 1. The
|
||||
* configuration options for a specific node includes IP address,
|
||||
* netmask and default router as well as the Ethernet address. The
|
||||
* netmask, default router and Ethernet address are appliciable only
|
||||
* if uIP should be run over Ethernet.
|
||||
*
|
||||
* All of these should be changed to suit your project.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Determines if uIP should use a fixed IP address or not.
|
||||
*
|
||||
* If uIP should use a fixed IP address, the settings are set in the
|
||||
* uipopt.h file. If not, the macros uip_sethostaddr(),
|
||||
* uip_setdraddr() and uip_setnetmask() should be used instead.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define UIP_FIXEDADDR 0
|
||||
|
||||
/**
|
||||
* Ping IP address asignment.
|
||||
*
|
||||
* uIP uses a "ping" packets for setting its own IP address if this
|
||||
* option is set. If so, uIP will start with an empty IP address and
|
||||
* the destination IP address of the first incoming "ping" (ICMP echo)
|
||||
* packet will be used for setting the hosts IP address.
|
||||
*
|
||||
* \note This works only if UIP_FIXEDADDR is 0.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#ifdef UIP_CONF_PINGADDRCONF
|
||||
#define UIP_PINGADDRCONF UIP_CONF_PINGADDRCONF
|
||||
#else /* UIP_CONF_PINGADDRCONF */
|
||||
#define UIP_PINGADDRCONF 0
|
||||
#endif /* UIP_CONF_PINGADDRCONF */
|
||||
|
||||
|
||||
/**
|
||||
* Specifies if the uIP ARP module should be compiled with a fixed
|
||||
* Ethernet MAC address or not.
|
||||
*
|
||||
* If this configuration option is 0, the macro uip_setethaddr() can
|
||||
* be used to specify the Ethernet address at run-time.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define UIP_FIXEDETHADDR 0
|
||||
|
||||
/** @} */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \name IP configuration options
|
||||
* @{
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* The IP TTL (time to live) of IP packets sent by uIP.
|
||||
*
|
||||
* This should normally not be changed.
|
||||
*/
|
||||
#define UIP_TTL 64
|
||||
|
||||
/**
|
||||
* Turn on support for IP packet reassembly.
|
||||
*
|
||||
* uIP supports reassembly of fragmented IP packets. This features
|
||||
* requires an additonal amount of RAM to hold the reassembly buffer
|
||||
* and the reassembly code size is approximately 700 bytes. The
|
||||
* reassembly buffer is of the same size as the uip_buf buffer
|
||||
* (configured by UIP_BUFSIZE).
|
||||
*
|
||||
* \note IP packet reassembly is not heavily tested.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define UIP_REASSEMBLY 0
|
||||
|
||||
/**
|
||||
* The maximum time an IP fragment should wait in the reassembly
|
||||
* buffer before it is dropped.
|
||||
*
|
||||
*/
|
||||
#define UIP_REASS_MAXAGE 40
|
||||
|
||||
/** @} */
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \name UDP configuration options
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Toggles wether UDP support should be compiled in or not.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#ifdef UIP_CONF_UDP
|
||||
#define UIP_UDP UIP_CONF_UDP
|
||||
#else /* UIP_CONF_UDP */
|
||||
#define UIP_UDP 0
|
||||
#endif /* UIP_CONF_UDP */
|
||||
|
||||
/**
|
||||
* Toggles if UDP checksums should be used or not.
|
||||
*
|
||||
* \note Support for UDP checksums is currently not included in uIP,
|
||||
* so this option has no function.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#ifdef UIP_CONF_UDP_CHECKSUMS
|
||||
#define UIP_UDP_CHECKSUMS UIP_CONF_UDP_CHECKSUMS
|
||||
#else
|
||||
#define UIP_UDP_CHECKSUMS 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The maximum amount of concurrent UDP connections.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#ifdef UIP_CONF_UDP_CONNS
|
||||
#define UIP_UDP_CONNS UIP_CONF_UDP_CONNS
|
||||
#else /* UIP_CONF_UDP_CONNS */
|
||||
#define UIP_UDP_CONNS 10
|
||||
#endif /* UIP_CONF_UDP_CONNS */
|
||||
|
||||
/**
|
||||
* The name of the function that should be called when UDP datagrams arrive.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
|
||||
|
||||
/** @} */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \name TCP configuration options
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Determines if support for opening connections from uIP should be
|
||||
* compiled in.
|
||||
*
|
||||
* If the applications that are running on top of uIP for this project
|
||||
* do not need to open outgoing TCP connections, this configration
|
||||
* option can be turned off to reduce the code size of uIP.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define UIP_ACTIVE_OPEN 1
|
||||
|
||||
/**
|
||||
* The maximum number of simultaneously open TCP connections.
|
||||
*
|
||||
* Since the TCP connections are statically allocated, turning this
|
||||
* configuration knob down results in less RAM used. Each TCP
|
||||
* connection requires approximatly 30 bytes of memory.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#ifndef UIP_CONF_MAX_CONNECTIONS
|
||||
#define UIP_CONNS 10
|
||||
#else /* UIP_CONF_MAX_CONNECTIONS */
|
||||
#define UIP_CONNS UIP_CONF_MAX_CONNECTIONS
|
||||
#endif /* UIP_CONF_MAX_CONNECTIONS */
|
||||
|
||||
|
||||
/**
|
||||
* The maximum number of simultaneously listening TCP ports.
|
||||
*
|
||||
* Each listening TCP port requires 2 bytes of memory.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#ifndef UIP_CONF_MAX_LISTENPORTS
|
||||
#define UIP_LISTENPORTS 20
|
||||
#else /* UIP_CONF_MAX_LISTENPORTS */
|
||||
#define UIP_LISTENPORTS UIP_CONF_MAX_LISTENPORTS
|
||||
#endif /* UIP_CONF_MAX_LISTENPORTS */
|
||||
|
||||
/**
|
||||
* Determines if support for TCP urgent data notification should be
|
||||
* compiled in.
|
||||
*
|
||||
* Urgent data (out-of-band data) is a rarely used TCP feature that
|
||||
* very seldom would be required.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define UIP_URGDATA 0
|
||||
|
||||
/**
|
||||
* The initial retransmission timeout counted in timer pulses.
|
||||
*
|
||||
* This should not be changed.
|
||||
*/
|
||||
#define UIP_RTO 3
|
||||
|
||||
/**
|
||||
* The maximum number of times a segment should be retransmitted
|
||||
* before the connection should be aborted.
|
||||
*
|
||||
* This should not be changed.
|
||||
*/
|
||||
#define UIP_MAXRTX 8
|
||||
|
||||
/**
|
||||
* The maximum number of times a SYN segment should be retransmitted
|
||||
* before a connection request should be deemed to have been
|
||||
* unsuccessful.
|
||||
*
|
||||
* This should not need to be changed.
|
||||
*/
|
||||
#define UIP_MAXSYNRTX 5
|
||||
|
||||
/**
|
||||
* The TCP maximum segment size.
|
||||
*
|
||||
* This is should not be to set to more than
|
||||
* UIP_BUFSIZE - UIP_LLH_LEN - UIP_TCPIP_HLEN.
|
||||
*/
|
||||
#define UIP_TCP_MSS (UIP_BUFSIZE - UIP_LLH_LEN - UIP_TCPIP_HLEN)
|
||||
|
||||
/**
|
||||
* The size of the advertised receiver's window.
|
||||
*
|
||||
* Should be set low (i.e., to the size of the uip_buf buffer) is the
|
||||
* application is slow to process incoming data, or high (32768 bytes)
|
||||
* if the application processes data quickly.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#ifndef UIP_CONF_RECEIVE_WINDOW
|
||||
#define UIP_RECEIVE_WINDOW UIP_TCP_MSS
|
||||
#else
|
||||
#define UIP_RECEIVE_WINDOW UIP_CONF_RECEIVE_WINDOW
|
||||
#endif
|
||||
|
||||
/**
|
||||
* How long a connection should stay in the TIME_WAIT state.
|
||||
*
|
||||
* This configiration option has no real implication, and it should be
|
||||
* left untouched.
|
||||
*/
|
||||
#define UIP_TIME_WAIT_TIMEOUT 120
|
||||
|
||||
|
||||
/** @} */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \name ARP configuration options
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* The size of the ARP table.
|
||||
*
|
||||
* This option should be set to a larger value if this uIP node will
|
||||
* have many connections from the local network.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#ifdef UIP_CONF_ARPTAB_SIZE
|
||||
#define UIP_ARPTAB_SIZE UIP_CONF_ARPTAB_SIZE
|
||||
#else
|
||||
#define UIP_ARPTAB_SIZE 8
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The maxium age of ARP table entries measured in 10ths of seconds.
|
||||
*
|
||||
* An UIP_ARP_MAXAGE of 120 corresponds to 20 minutes (BSD
|
||||
* default).
|
||||
*/
|
||||
#define UIP_ARP_MAXAGE 120
|
||||
|
||||
/** @} */
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* \name General configuration options
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* The size of the uIP packet buffer.
|
||||
*
|
||||
* The uIP packet buffer should not be smaller than 60 bytes, and does
|
||||
* not need to be larger than 1500 bytes. Lower size results in lower
|
||||
* TCP throughput, larger size results in higher TCP throughput.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#ifndef UIP_CONF_BUFFER_SIZE
|
||||
#define UIP_BUFSIZE 400
|
||||
#else /* UIP_CONF_BUFFER_SIZE */
|
||||
#define UIP_BUFSIZE UIP_CONF_BUFFER_SIZE
|
||||
#endif /* UIP_CONF_BUFFER_SIZE */
|
||||
|
||||
|
||||
/**
|
||||
* Determines if statistics support should be compiled in.
|
||||
*
|
||||
* The statistics is useful for debugging and to show the user.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#ifndef UIP_CONF_STATISTICS
|
||||
#define UIP_STATISTICS 0
|
||||
#else /* UIP_CONF_STATISTICS */
|
||||
#define UIP_STATISTICS UIP_CONF_STATISTICS
|
||||
#endif /* UIP_CONF_STATISTICS */
|
||||
|
||||
/**
|
||||
* Determines if logging of certain events should be compiled in.
|
||||
*
|
||||
* This is useful mostly for debugging. The function uip_log()
|
||||
* must be implemented to suit the architecture of the project, if
|
||||
* logging is turned on.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#ifndef UIP_CONF_LOGGING
|
||||
#define UIP_LOGGING 0
|
||||
#else /* UIP_CONF_LOGGING */
|
||||
#define UIP_LOGGING UIP_CONF_LOGGING
|
||||
#endif /* UIP_CONF_LOGGING */
|
||||
|
||||
/**
|
||||
* Broadcast support.
|
||||
*
|
||||
* This flag configures IP broadcast support. This is useful only
|
||||
* together with UDP.
|
||||
*
|
||||
* \hideinitializer
|
||||
*
|
||||
*/
|
||||
#ifndef UIP_CONF_BROADCAST
|
||||
#define UIP_BROADCAST 0
|
||||
#else /* UIP_CONF_BROADCAST */
|
||||
#define UIP_BROADCAST UIP_CONF_BROADCAST
|
||||
#endif /* UIP_CONF_BROADCAST */
|
||||
|
||||
/**
|
||||
* Print out a uIP log message.
|
||||
*
|
||||
* This function must be implemented by the module that uses uIP, and
|
||||
* is called by uIP whenever a log message is generated.
|
||||
*/
|
||||
void uip_log(char *msg);
|
||||
|
||||
/**
|
||||
* The link level header length.
|
||||
*
|
||||
* This is the offset into the uip_buf where the IP header can be
|
||||
* found. For Ethernet, this should be set to 14. For SLIP, this
|
||||
* should be set to 0.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#ifdef UIP_CONF_LLH_LEN
|
||||
#define UIP_LLH_LEN UIP_CONF_LLH_LEN
|
||||
#else /* UIP_CONF_LLH_LEN */
|
||||
#define UIP_LLH_LEN 14
|
||||
#endif /* UIP_CONF_LLH_LEN */
|
||||
|
||||
/** @} */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \name CPU architecture configuration
|
||||
* @{
|
||||
*
|
||||
* The CPU architecture configuration is where the endianess of the
|
||||
* CPU on which uIP is to be run is specified. Most CPUs today are
|
||||
* little endian, and the most notable exception are the Motorolas
|
||||
* which are big endian. The BYTE_ORDER macro should be changed to
|
||||
* reflect the CPU architecture on which uIP is to be run.
|
||||
*/
|
||||
|
||||
/**
|
||||
* The byte order of the CPU architecture on which uIP is to be run.
|
||||
*
|
||||
* This option can be either BIG_ENDIAN (Motorola byte order) or
|
||||
* LITTLE_ENDIAN (Intel byte order).
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#ifdef UIP_CONF_BYTE_ORDER
|
||||
#define UIP_BYTE_ORDER UIP_CONF_BYTE_ORDER
|
||||
#else /* UIP_CONF_BYTE_ORDER */
|
||||
#define UIP_BYTE_ORDER UIP_LITTLE_ENDIAN
|
||||
#endif /* UIP_CONF_BYTE_ORDER */
|
||||
|
||||
/** @} */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* \name Appication specific configurations
|
||||
* @{
|
||||
*
|
||||
* An uIP application is implemented using a single application
|
||||
* function that is called by uIP whenever a TCP/IP event occurs. The
|
||||
* name of this function must be registered with uIP at compile time
|
||||
* using the UIP_APPCALL definition.
|
||||
*
|
||||
* uIP applications can store the application state within the
|
||||
* uip_conn structure by specifying the type of the application
|
||||
* structure by typedef:ing the type uip_tcp_appstate_t and uip_udp_appstate_t.
|
||||
*
|
||||
* The file containing the definitions must be included in the
|
||||
* uipopt.h file.
|
||||
*
|
||||
* The following example illustrates how this can look.
|
||||
\code
|
||||
|
||||
void httpd_appcall(void);
|
||||
#define UIP_APPCALL httpd_appcall
|
||||
|
||||
struct httpd_state {
|
||||
u8_t state;
|
||||
u16_t count;
|
||||
char *dataptr;
|
||||
char *script;
|
||||
};
|
||||
typedef struct httpd_state uip_tcp_appstate_t
|
||||
\endcode
|
||||
*/
|
||||
|
||||
/**
|
||||
* \var #define UIP_APPCALL
|
||||
*
|
||||
* The name of the application function that uIP should call in
|
||||
* response to TCP/IP events.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* \var typedef uip_tcp_appstate_t
|
||||
*
|
||||
* The type of the application state that is to be stored in the
|
||||
* uip_conn structure. This usually is typedef:ed to a struct holding
|
||||
* application state information.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \var typedef uip_udp_appstate_t
|
||||
*
|
||||
* The type of the application state that is to be stored in the
|
||||
* uip_conn structure. This usually is typedef:ed to a struct holding
|
||||
* application state information.
|
||||
*/
|
||||
/** @} */
|
||||
/** @} */
|
||||
|
||||
#endif /* __UIPOPT_H__ */
|
49
examples/emac/emac_uip/webserver.h
Normal file
49
examples/emac/emac_uip/webserver.h
Normal file
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) 2002, Adam Dunkels.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the uIP TCP/IP stack
|
||||
*
|
||||
* $Id: webserver.h,v 1.2 2006/06/11 21:46:38 adam Exp $
|
||||
*
|
||||
*/
|
||||
#ifndef __WEBSERVER_H__
|
||||
#define __WEBSERVER_H__
|
||||
|
||||
#include "httpd.h"
|
||||
|
||||
typedef struct httpd_state uip_tcp_appstate_t;
|
||||
/* UIP_APPCALL: the name of the application function. This function
|
||||
must return void and take no arguments (i.e., C type "void
|
||||
appfunc(void)"). */
|
||||
#ifndef UIP_APPCALL
|
||||
#define UIP_APPCALL httpd_appcall
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* __WEBSERVER_H__ */
|
6
examples/flash/flash_rw_test/CMakeLists.txt
Normal file
6
examples/flash/flash_rw_test/CMakeLists.txt
Normal file
@ -0,0 +1,6 @@
|
||||
set(mains main.c)
|
||||
#set(TARGET_REQUIRED_SRCS apple.c)
|
||||
generate_bin()
|
||||
|
||||
|
||||
|
729
examples/flash/flash_rw_test/cdk/flash_rw_test.cdkproj
Normal file
729
examples/flash/flash_rw_test/cdk/flash_rw_test.cdkproj
Normal file
@ -0,0 +1,729 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Project Name="flash_rw_test" Version="1" Language="C">
|
||||
<Description>CPU: RV32IMAFC
|
||||
Chip: bl70x
|
||||
Board: bl70x_iot
|
||||
</Description>
|
||||
<Dependencies Name="Debug"/>
|
||||
<VirtualDirectory Name="app">
|
||||
<File Name="../main.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
</VirtualDirectory>
|
||||
<VirtualDirectory Name="chip">
|
||||
<VirtualDirectory Name="riscv">
|
||||
<File Name="../../../../drivers/bl702_driver/startup/interrupt.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/startup/system_bl702.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
</VirtualDirectory>
|
||||
<VirtualDirectory Name="startup">
|
||||
<File Name="../../../../drivers/bl702_driver/startup/GCC/entry.S">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/startup/GCC/start_load.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
</VirtualDirectory>
|
||||
</VirtualDirectory>
|
||||
<VirtualDirectory Name="hal">
|
||||
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_adc.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_dac.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_dma.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_gpio.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_i2c.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_i2s.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_mtimer.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_pwm.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_spi.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_timer.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_uart.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_usb.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_clock.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_cam.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_mjpeg.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_flash.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
</VirtualDirectory>
|
||||
<VirtualDirectory Name="std">
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_acomp.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_adc.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_aon.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_cam.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_clock.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_dac.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_dma.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_ef_ctrl.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_emac.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_glb.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_hbn.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_i2c.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_i2c_gpio_sim.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_i2s.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_ir.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_common.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_kys.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_l1c.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_mjpeg.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_pds.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_psram.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_pwm.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_qdec.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_romapi.c" ExcludeProjConfig="BuildSet">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_romdriver.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_sec_dbg.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_sec_eng.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_sf_cfg.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_sf_cfg_ext.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_sf_ctrl.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_sflash.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_sflash_ext.c" ExcludeProjConfig="">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_spi.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_timer.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_uart.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_usb.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_xip_sflash.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_xip_sflash_ext.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
</VirtualDirectory>
|
||||
<VirtualDirectory Name="board">
|
||||
<File Name="../../../../bsp/board/bl706_iot/board.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../bsp/bsp_common/platform/bflb_platform.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
</VirtualDirectory>
|
||||
<VirtualDirectory Name="common">
|
||||
<File Name="../../../../common/device/drv_device.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/memheap/drv_mmheap.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/ring_buffer/ring_buffer.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/soft_crc/softcrc.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<VirtualDirectory Name="libc">
|
||||
<File Name="../../../../common/libc/src/atof.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/atoi.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/atol.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/atoll.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/atox.c" ExcludeProjConfig="BuildSet">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/bsearch.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/common.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/ctype_isalnum.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/ctype_isalpha.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/ctype_isascii.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/ctype_isblank.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/ctype_iscntrl.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/ctype_isdigit.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/ctype_isgraph.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/ctype_islower.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/ctype_isprint.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/ctype_ispunct.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/ctype_isspace.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/ctype_isupper.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/ctype_isxdigit.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/ctype_tolower.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/ctype_toupper.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/ctypes.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/fnmatch.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/jrand48.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/lrand48.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/memccpy.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/memchr.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/memcmp.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/memcpy.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/memmem.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/memrchr.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/memset.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/memswap.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/mrand48.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/nrand48.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/qsort.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/seed48.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/snprintf.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/sprintf.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/srand48.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/sscanf.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/stdlib.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strcasecmp.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strcat.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strchr.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strcmp.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strcpy.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strcspn.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strlcat.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strlcpy.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strlen.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strncasecmp.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strncat.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strncmp.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strncpy.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strnlen.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strntoimax.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strntoumax.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strpbrk.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strrchr.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strsep.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strspn.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strstr.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strtoimax.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strtok.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strtok_r.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strtol.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strtoll.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strtoul.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strtoull.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strtoumax.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strtox.c" ExcludeProjConfig="BuildSet">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/strxspn.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/vsnprintf.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/vsprintf.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../common/libc/src/vsscanf.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
</VirtualDirectory>
|
||||
<File Name="../../../../common/misc/misc.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
</VirtualDirectory>
|
||||
<VirtualDirectory Name="script">
|
||||
<File Name="../../../../tools/openocd/bl70x_gdb.init">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../drivers/bl702_driver/regs/bl70x_reg.svc">
|
||||
<FileOption/>
|
||||
</File>
|
||||
</VirtualDirectory>
|
||||
<MonitorProgress>
|
||||
<DebugLaunch>156</DebugLaunch>
|
||||
<FlashOperate>105</FlashOperate>
|
||||
</MonitorProgress>
|
||||
<VirtualDirectory Name="components">
|
||||
<VirtualDirectory Name="fatfs">
|
||||
<File Name="../../../../components/fatfs/diskio.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../components/fatfs/ff.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../components/fatfs/ffsystem.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
<File Name="../../../../components/fatfs/ffunicode.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
</VirtualDirectory>
|
||||
<VirtualDirectory Name="shell">
|
||||
<File Name="../../../../components/shell/drv_shell.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
</VirtualDirectory>
|
||||
<VirtualDirectory Name="usb_stack">
|
||||
<VirtualDirectory Name="class">
|
||||
<VirtualDirectory Name="cdc">
|
||||
<File Name="../../../../components/usb_stack/class/cdc/usbd_cdc.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
</VirtualDirectory>
|
||||
<VirtualDirectory Name="hid">
|
||||
<File Name="../../../../components/usb_stack/class/hid/usbd_hid.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
</VirtualDirectory>
|
||||
<VirtualDirectory Name="msc">
|
||||
<File Name="../../../../components/usb_stack/class/msc/usbd_msc.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
</VirtualDirectory>
|
||||
</VirtualDirectory>
|
||||
<VirtualDirectory Name="core">
|
||||
<File Name="../../../../components/usb_stack/core/usbd_core.c">
|
||||
<FileOption/>
|
||||
</File>
|
||||
</VirtualDirectory>
|
||||
</VirtualDirectory>
|
||||
</VirtualDirectory>
|
||||
<Dependencies Name="BuildSet"/>
|
||||
<BuildConfigs>
|
||||
<BuildConfig Name="BuildSet">
|
||||
<Target>
|
||||
<ROMBank Selected="1">
|
||||
<ROM1>
|
||||
<InUse>no</InUse>
|
||||
<Start>0x23000000</Start>
|
||||
<Size>0x100000</Size>
|
||||
</ROM1>
|
||||
<ROM2>
|
||||
<InUse>no</InUse>
|
||||
<Start>0x22014000</Start>
|
||||
<Size>0x4000</Size>
|
||||
</ROM2>
|
||||
<ROM3>
|
||||
<InUse>no</InUse>
|
||||
<Start>0x42018000</Start>
|
||||
<Size>0x8000</Size>
|
||||
</ROM3>
|
||||
<ROM4>
|
||||
<InUse>no</InUse>
|
||||
<Start/>
|
||||
<Size/>
|
||||
</ROM4>
|
||||
<ROM5>
|
||||
<InUse>no</InUse>
|
||||
<Start/>
|
||||
<Size/>
|
||||
</ROM5>
|
||||
</ROMBank>
|
||||
<RAMBank>
|
||||
<RAM1>
|
||||
<InUse>yes</InUse>
|
||||
<Start>0x42020000</Start>
|
||||
<Size>0xc000</Size>
|
||||
<Init>yes</Init>
|
||||
</RAM1>
|
||||
<RAM2>
|
||||
<InUse>no</InUse>
|
||||
<Start/>
|
||||
<Size/>
|
||||
<Init>yes</Init>
|
||||
</RAM2>
|
||||
<RAM3>
|
||||
<InUse>no</InUse>
|
||||
<Start/>
|
||||
<Size/>
|
||||
<Init>yes</Init>
|
||||
</RAM3>
|
||||
<RAM4>
|
||||
<InUse>no</InUse>
|
||||
<Start/>
|
||||
<Size/>
|
||||
<Init>yes</Init>
|
||||
</RAM4>
|
||||
<RAM5>
|
||||
<InUse>no</InUse>
|
||||
<Start/>
|
||||
<Size/>
|
||||
<Init>yes</Init>
|
||||
</RAM5>
|
||||
</RAMBank>
|
||||
<CPU>rv32imafc</CPU>
|
||||
<UseMiniLib>no</UseMiniLib>
|
||||
<Endian>little</Endian>
|
||||
<UseHardFloat>no</UseHardFloat>
|
||||
<UseEnhancedLRW>no</UseEnhancedLRW>
|
||||
<UseContinueBuild>no</UseContinueBuild>
|
||||
<UseSemiHost>no</UseSemiHost>
|
||||
</Target>
|
||||
<Output>
|
||||
<OutputName>$(ProjectName)</OutputName>
|
||||
<Type>Executable</Type>
|
||||
<CreateHexFile>no</CreateHexFile>
|
||||
<CreateBinFile>yes</CreateBinFile>
|
||||
<Preprocessor>no</Preprocessor>
|
||||
<Disassmeble>yes</Disassmeble>
|
||||
<CallGraph>no</CallGraph>
|
||||
<Map>yes</Map>
|
||||
</Output>
|
||||
<User>
|
||||
<BeforeCompile>
|
||||
<RunUserProg>no</RunUserProg>
|
||||
<UserProgName/>
|
||||
</BeforeCompile>
|
||||
<BeforeMake>
|
||||
<RunUserProg>no</RunUserProg>
|
||||
<UserProgName/>
|
||||
</BeforeMake>
|
||||
<AfterMake>
|
||||
<RunUserProg>no</RunUserProg>
|
||||
<UserProgName>$(ProjectPath)../../../../tools/bflb_flash_tool/bflb_mcu_tool.exe --chipname=bl702 --firmware="D:/BouffaloLabWS/cdk_ws/bl_mcu_sdk/examples/hellowd/Obj/helloworld.bin" </UserProgName>
|
||||
</AfterMake>
|
||||
</User>
|
||||
<Compiler>
|
||||
<Define>ARCH_RISCV;</Define>
|
||||
<Undefine/>
|
||||
<Optim>Optimize more (-O2)</Optim>
|
||||
<DebugLevel>Default (-g)</DebugLevel>
|
||||
<IncludePath>$(ProjectPath);$(ProjectPath)../;$(ProjectPath)../../../../components/fatfs;$(ProjectPath)../../../../components/freertos/Source/include;$(ProjectPath)../../../../components/shell;$(ProjectPath)../../../../components/usb_stack/class/audio;$(ProjectPath)../../../../components/usb_stack/class/cdc;$(ProjectPath)../../../../components/usb_stack/class/hid;$(ProjectPath)../../../../components/usb_stack/class/msc;$(ProjectPath)../../../../components/usb_stack/class/video;$(ProjectPath)../../../../components/usb_stack/class/webusb;$(ProjectPath)../../../../components/usb_stack/class/winusb;$(ProjectPath)../../../../components/usb_stack/common;$(ProjectPath)../../../../components/usb_stack/core;$(ProjectPath)../../../../bsp/board/bl706_iot;$(ProjectPath)../../../../bsp/bsp_common/platform;$(ProjectPath)../../../../common/libc/inc;$(ProjectPath)../../../../common/libc/inc/arm_gcc;$(ProjectPath)../../../../common/libc/inc/bits;$(ProjectPath)../../../../common/libc/inc/sys;$(ProjectPath)../../../../common/libc/src;$(ProjectPath)../../../../common/device;$(ProjectPath)../../../../common/list;$(ProjectPath)../../../../common/memheap;$(ProjectPath)../../../../common/misc;$(ProjectPath)../../../../common/ring_buffer;$(ProjectPath)../../../../common/soft_crc;$(ProjectPath)../../../../components/shell;$(ProjectPath)../../../../drivers/bl702_driver/hal_drv/default_config;$(ProjectPath)../../../../drivers/bl702_driver/risc-v/Core/Include;$(ProjectPath)../../../../drivers/bl702_driver/hal_drv/inc;$(ProjectPath)../../../../drivers/bl702_driver/regs;$(ProjectPath)../../../../drivers/bl702_driver/startup;$(ProjectPath)../../../../drivers/bl702_driver/std_drv/inc;$(ProjectPath)../../../../drivers/bl602_driver/risc-v/Core/Include;$(ProjectPath)../../../../drivers/bl602_driver/hal_drv/inc;$(ProjectPath)../../../../drivers/bl602_driver/hal_drv/default_config;$(ProjectPath)../../../../drivers/bl602_driver/regs;$(ProjectPath)../../../../drivers/bl602_driver/std_drv/inc</IncludePath>
|
||||
<OtherFlags>-fshort-enums -fno-common -fms-extensions -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -Wall -Wshift-negative-value -Wchar-subscripts -Wformat -Wuninitialized -Winit-self -fno-jump-tables -Wignored-qualifiers -Wswitch-default -Wunused -Wundef -msmall-data-limit=4</OtherFlags>
|
||||
<Verbose>no</Verbose>
|
||||
<Ansi>no</Ansi>
|
||||
<Syntax>no</Syntax>
|
||||
<Pedantic>no</Pedantic>
|
||||
<PedanticErr>no</PedanticErr>
|
||||
<InhibitWarn>no</InhibitWarn>
|
||||
<AllWarn>yes</AllWarn>
|
||||
<WarnErr>no</WarnErr>
|
||||
<OneElfS>yes</OneElfS>
|
||||
<Fstrict>no</Fstrict>
|
||||
</Compiler>
|
||||
<Asm>
|
||||
<Define/>
|
||||
<Undefine/>
|
||||
<IncludePath>$(ProjectPath);$(ProjectPath)../;$(ProjectPath)../../../../components/fatfs;$(ProjectPath)../../../../components/freertos/Source/include;$(ProjectPath)../../../../components/shell;$(ProjectPath)../../../../components/usb_stack/class/audio;$(ProjectPath)../../../../components/usb_stack/class/cdc;$(ProjectPath)../../../../components/usb_stack/class/hid;$(ProjectPath)../../../../components/usb_stack/class/msc;$(ProjectPath)../../../../components/usb_stack/class/video;$(ProjectPath)../../../../components/usb_stack/class/webusb;$(ProjectPath)../../../../components/usb_stack/class/winusb;$(ProjectPath)../../../../components/usb_stack/common;$(ProjectPath)../../../../components/usb_stack/core;$(ProjectPath)../../../../bsp/board/bl706_iot;$(ProjectPath)../../../../bsp/bsp_common/platform;$(ProjectPath)../../../../common/device;$(ProjectPath)../../../../common/list;$(ProjectPath)../../../../common/memheap;$(ProjectPath)../../../../common/misc;$(ProjectPath)../../../../common/ring_buffer;$(ProjectPath)../../../../common/soft_crc;$(ProjectPath)../../../../components/shell;$(ProjectPath)../../../../drivers/bl702_driver/hal_drv/default_config;$(ProjectPath)../../../../drivers/bl702_driver/hal_drv/inc;$(ProjectPath)../../../../drivers/bl702_driver/risc-v/Core/Include;$(ProjectPath)../../../../drivers/bl702_driver/regs;$(ProjectPath)../../../../drivers/bl702_driver/startup;$(ProjectPath)../../../../drivers/bl702_driver/std_drv/inc;$(ProjectPath)../../../../drivers/bl602_driver/risc-v/Core/Include;$(ProjectPath)../../../../drivers/bl602_driver/startup;$(ProjectPath)../../../../drivers/bl602_driver/hal_drv/inc;$(ProjectPath)../../../../drivers/bl602_driver/hal_drv/default_config;$(ProjectPath)../../../../drivers/bl602_driver/regs;$(ProjectPath)../../../../drivers/bl602_driver/std_drv/inc</IncludePath>
|
||||
<OtherFlags/>
|
||||
<DebugLevel>gdwarf2</DebugLevel>
|
||||
</Asm>
|
||||
<Linker>
|
||||
<Garbage>yes</Garbage>
|
||||
<Garbage2>yes</Garbage2>
|
||||
<LDFile>$(ProjectPath)../../../../drivers/bl702_driver/bl702_flash.ld</LDFile>
|
||||
<LibName>c;gcc</LibName>
|
||||
<LibPath/>
|
||||
<OtherFlags/>
|
||||
<AutoLDFile>no</AutoLDFile>
|
||||
<LinkType/>
|
||||
</Linker>
|
||||
<Debug>
|
||||
<LoadApplicationAtStartup>yes</LoadApplicationAtStartup>
|
||||
<Connector>ICE</Connector>
|
||||
<StopAt>yes</StopAt>
|
||||
<StopAtText>main</StopAtText>
|
||||
<InitFile/>
|
||||
<AfterLoadFile>$(ProjectPath)/../../../../tools/openocd/bl70x_gdb.init</AfterLoadFile>
|
||||
<AutoRun>yes</AutoRun>
|
||||
<ResetType>Hard Reset</ResetType>
|
||||
<SoftResetVal>23000000</SoftResetVal>
|
||||
<ResetAfterLoad>no</ResetAfterLoad>
|
||||
<Dumpcore>no</Dumpcore>
|
||||
<DumpcoreText>$(ProjectPath)/$(ProjectName).cdkcore</DumpcoreText>
|
||||
<ConfigICE>
|
||||
<IP>localhost</IP>
|
||||
<PORT>1025</PORT>
|
||||
<CPUNumber>0</CPUNumber>
|
||||
<Clock>2000</Clock>
|
||||
<Delay>10</Delay>
|
||||
<WaitReset>50</WaitReset>
|
||||
<DDC>yes</DDC>
|
||||
<TRST>no</TRST>
|
||||
<DebugPrint>no</DebugPrint>
|
||||
<Connect>Normal</Connect>
|
||||
<ResetType>Hard Reset</ResetType>
|
||||
<SoftResetVal>21000000</SoftResetVal>
|
||||
<RTOSType>Bare Metal</RTOSType>
|
||||
<DownloadToFlash>yes</DownloadToFlash>
|
||||
<ResetAfterConnect>yes</ResetAfterConnect>
|
||||
<GDBName/>
|
||||
<GDBServerType>Local</GDBServerType>
|
||||
<OtherFlags>-arch riscv</OtherFlags>
|
||||
</ConfigICE>
|
||||
<ConfigSIM>
|
||||
<SIMTarget/>
|
||||
<OtherFlags/>
|
||||
<NoGraphic>yes</NoGraphic>
|
||||
<Log>no</Log>
|
||||
<SimTrace>no</SimTrace>
|
||||
</ConfigSIM>
|
||||
<ConfigOpenOCD>
|
||||
<OpenOCDExecutablePath>openocd-bl702</OpenOCDExecutablePath>
|
||||
<OpenOCDTelnetPortEnable>no</OpenOCDTelnetPortEnable>
|
||||
<OpenOCDTelnetPort>4444</OpenOCDTelnetPort>
|
||||
<OpenOCDTclPortEnable>no</OpenOCDTclPortEnable>
|
||||
<OpenOCDTclPort>6666</OpenOCDTclPort>
|
||||
<OpenOCDConfigOptions>-f openocd_bl702_evb.cfg</OpenOCDConfigOptions>
|
||||
</ConfigOpenOCD>
|
||||
</Debug>
|
||||
<Flash>
|
||||
<InitFile/>
|
||||
<Erase>Erase Sectors</Erase>
|
||||
<Algorithms Path="">bl702_flasher.elf</Algorithms>
|
||||
<Program>yes</Program>
|
||||
<Verify>yes</Verify>
|
||||
<ResetAndRun>no</ResetAndRun>
|
||||
<ResetType>Hard Reset</ResetType>
|
||||
<SoftResetVal/>
|
||||
<External>no</External>
|
||||
<Command/>
|
||||
<Arguments/>
|
||||
</Flash>
|
||||
</BuildConfig>
|
||||
</BuildConfigs>
|
||||
<DebugSessions>
|
||||
<watchExpressions/>
|
||||
<memoryExpressions>;;;</memoryExpressions>
|
||||
<statistics>;;MHZ;</statistics>
|
||||
<peripheralTabs>
|
||||
<Tab disFormat="Hex">glb</Tab>
|
||||
<Tab disFormat="Hex">uart</Tab>
|
||||
</peripheralTabs>
|
||||
<WatchDisplayFormat>1</WatchDisplayFormat>
|
||||
<LocalDisplayFormat>1</LocalDisplayFormat>
|
||||
<debugLayout/>
|
||||
<memoryTabColSizeExpressions>100:8;100:8;100:8;100:8;</memoryTabColSizeExpressions>
|
||||
</DebugSessions>
|
||||
<DebugSessions>
|
||||
<watchExpressions/>
|
||||
<memoryExpressions>;;;</memoryExpressions>
|
||||
<statistics>;;MHZ;</statistics>
|
||||
<peripheralTabs/>
|
||||
<WatchDisplayFormat>1</WatchDisplayFormat>
|
||||
<LocalDisplayFormat>1</LocalDisplayFormat>
|
||||
<debugLayout/>
|
||||
<memoryTabColSizeExpressions>100:8;100:8;100:8;100:8;</memoryTabColSizeExpressions>
|
||||
</DebugSessions>
|
||||
</Project>
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user