[update][examples] update demos
This commit is contained in:
parent
0ea925c313
commit
fb718ae09b
@ -5,6 +5,5 @@ set(CONFIG_BFLOG 1)
|
|||||||
set(CONFIG_BFLOG_USER 1)
|
set(CONFIG_BFLOG_USER 1)
|
||||||
set(CONFIG_FATFS 1)
|
set(CONFIG_FATFS 1)
|
||||||
|
|
||||||
set(CONFIG_BSP_COMMON 1)
|
|
||||||
set(CONFIG_BSP_SDH_SDCARD 1)
|
set(CONFIG_BSP_SDH_SDCARD 1)
|
||||||
set(CONFIG_BSP_FATFS_SDH_SDCARD 1)
|
set(CONFIG_BSP_FATFS_SDH_SDCARD 1)
|
@ -4,6 +4,5 @@ set(CONFIG_VLIBC_FATFS 1)
|
|||||||
set(CONFIG_BFLOG 0)
|
set(CONFIG_BFLOG 0)
|
||||||
set(CONFIG_FATFS 1)
|
set(CONFIG_FATFS 1)
|
||||||
|
|
||||||
set(CONFIG_BSP_COMMON 1)
|
|
||||||
set(CONFIG_BSP_SDH_SDCARD 1)
|
set(CONFIG_BSP_SDH_SDCARD 1)
|
||||||
set(CONFIG_FATFS_SDH_SDCARD 1)
|
set(CONFIG_FATFS_SDH_SDCARD 1)
|
@ -6,6 +6,5 @@ set(CONFIG_FATFS 1)
|
|||||||
set(CONFIG_LUA 1)
|
set(CONFIG_LUA 1)
|
||||||
set(CONFIG_LUA_LHAL 1)
|
set(CONFIG_LUA_LHAL 1)
|
||||||
|
|
||||||
set(CONFIG_BSP_COMMON 1)
|
|
||||||
set(CONFIG_BSP_SDH_SDCARD 1)
|
set(CONFIG_BSP_SDH_SDCARD 1)
|
||||||
set(CONFIG_BSP_FATFS_SDH_SDCARD 1)
|
set(CONFIG_BSP_FATFS_SDH_SDCARD 1)
|
@ -1,3 +1,2 @@
|
|||||||
set(CONFIG_BSP_COMMON 1)
|
|
||||||
set(CONFIG_BSP_LCD 1)
|
set(CONFIG_BSP_LCD 1)
|
||||||
set(CONFIG_LVGL 1)
|
set(CONFIG_LVGL 1)
|
9
examples/peripherals/cam/cam_crop/CMakeLists.txt
Normal file
9
examples/peripherals/cam/cam_crop/CMakeLists.txt
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.15)
|
||||||
|
|
||||||
|
include(proj.conf)
|
||||||
|
|
||||||
|
find_package(bouffalo_sdk REQUIRED HINTS $ENV{BL_SDK_BASE})
|
||||||
|
|
||||||
|
sdk_set_main_file(main.c)
|
||||||
|
|
||||||
|
project(cam_crop)
|
13
examples/peripherals/cam/cam_crop/Makefile
Normal file
13
examples/peripherals/cam/cam_crop/Makefile
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
SDK_DEMO_PATH ?= .
|
||||||
|
BL_SDK_BASE ?= $(SDK_DEMO_PATH)/../../../..
|
||||||
|
|
||||||
|
export BL_SDK_BASE
|
||||||
|
|
||||||
|
CHIP ?= bl616
|
||||||
|
BOARD ?= bl616dk
|
||||||
|
CROSS_COMPILE ?= riscv64-unknown-elf-
|
||||||
|
|
||||||
|
# add custom cmake definition
|
||||||
|
#cmake_definition+=-Dxxx=sss
|
||||||
|
|
||||||
|
include $(BL_SDK_BASE)/project.build
|
69
examples/peripherals/cam/cam_crop/main.c
Normal file
69
examples/peripherals/cam/cam_crop/main.c
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
#include "bflb_mtimer.h"
|
||||||
|
#include "bflb_i2c.h"
|
||||||
|
#include "bflb_cam.h"
|
||||||
|
#include "image_sensor.h"
|
||||||
|
#include "board.h"
|
||||||
|
|
||||||
|
#define CROP_WQVGA_X 416
|
||||||
|
#define CROP_WQVGA_Y 240
|
||||||
|
#define CAM_FRAME_COUNT_USE 50
|
||||||
|
|
||||||
|
static struct bflb_device_s *i2c0;
|
||||||
|
static struct bflb_device_s *cam0;
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
uint32_t i, pic_size;
|
||||||
|
uint8_t *pic;
|
||||||
|
struct bflb_cam_config_s cam_config;
|
||||||
|
struct image_sensor_config_s *sensor_config;
|
||||||
|
|
||||||
|
board_init();
|
||||||
|
board_dvp_gpio_init();
|
||||||
|
|
||||||
|
i2c0 = bflb_device_get_by_name("i2c0");
|
||||||
|
cam0 = bflb_device_get_by_name("cam0");
|
||||||
|
|
||||||
|
if (image_sensor_scan(i2c0, &sensor_config)) {
|
||||||
|
printf("\r\nSensor name: %s\r\n", sensor_config->name);
|
||||||
|
} else {
|
||||||
|
printf("\r\nError! Can't identify sensor!\r\n");
|
||||||
|
while (1) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Crop resolution_x, should be set before init */
|
||||||
|
bflb_cam_crop_hsync(cam0, 112, 112 + CROP_WQVGA_X);
|
||||||
|
/* Crop resolution_y, should be set before init */
|
||||||
|
bflb_cam_crop_vsync(cam0, 120, 120 + CROP_WQVGA_Y);
|
||||||
|
|
||||||
|
memcpy(&cam_config, sensor_config, IMAGE_SENSOR_INFO_COPY_SIZE);
|
||||||
|
cam_config.with_mjpeg = false;
|
||||||
|
cam_config.output_format = CAM_OUTPUT_FORMAT_AUTO;
|
||||||
|
cam_config.output_bufaddr = BFLB_PSRAM_BASE;
|
||||||
|
cam_config.output_bufsize = CROP_WQVGA_X * CROP_WQVGA_Y * 8;
|
||||||
|
|
||||||
|
bflb_cam_init(cam0, &cam_config);
|
||||||
|
bflb_cam_start(cam0);
|
||||||
|
|
||||||
|
for (i = 0; i < CAM_FRAME_COUNT_USE; i++) {
|
||||||
|
while (bflb_cam_get_frame_count(cam0) == 0) {
|
||||||
|
}
|
||||||
|
pic_size = bflb_cam_get_frame_info(cam0, &pic);
|
||||||
|
bflb_cam_pop_one_frame(cam0);
|
||||||
|
printf("pop picture %d: 0x%08x, len: %d\r\n", i, (uint32_t)pic, pic_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
bflb_cam_stop(cam0);
|
||||||
|
|
||||||
|
//for (i = 0; i < pic_size; i++) {
|
||||||
|
// printf("%02x", pic[i]);
|
||||||
|
//}
|
||||||
|
//printf("\r\n");
|
||||||
|
|
||||||
|
printf("end\r\n");
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
bflb_mtimer_delay_ms(1000);
|
||||||
|
}
|
||||||
|
}
|
2
examples/peripherals/cam/cam_crop/proj.conf
Normal file
2
examples/peripherals/cam/cam_crop/proj.conf
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
set(CONFIG_BSP_IMAGE_SENSOR 1)
|
||||||
|
set(CONFIG_PSRAM 1)
|
9
examples/peripherals/cam/cam_int/CMakeLists.txt
Normal file
9
examples/peripherals/cam/cam_int/CMakeLists.txt
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.15)
|
||||||
|
|
||||||
|
include(proj.conf)
|
||||||
|
|
||||||
|
find_package(bouffalo_sdk REQUIRED HINTS $ENV{BL_SDK_BASE})
|
||||||
|
|
||||||
|
sdk_set_main_file(main.c)
|
||||||
|
|
||||||
|
project(cam_int)
|
13
examples/peripherals/cam/cam_int/Makefile
Normal file
13
examples/peripherals/cam/cam_int/Makefile
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
SDK_DEMO_PATH ?= .
|
||||||
|
BL_SDK_BASE ?= $(SDK_DEMO_PATH)/../../../..
|
||||||
|
|
||||||
|
export BL_SDK_BASE
|
||||||
|
|
||||||
|
CHIP ?= bl616
|
||||||
|
BOARD ?= bl616dk
|
||||||
|
CROSS_COMPILE ?= riscv64-unknown-elf-
|
||||||
|
|
||||||
|
# add custom cmake definition
|
||||||
|
#cmake_definition+=-Dxxx=sss
|
||||||
|
|
||||||
|
include $(BL_SDK_BASE)/project.build
|
72
examples/peripherals/cam/cam_int/main.c
Normal file
72
examples/peripherals/cam/cam_int/main.c
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
#include "bflb_mtimer.h"
|
||||||
|
#include "bflb_i2c.h"
|
||||||
|
#include "bflb_cam.h"
|
||||||
|
#include "image_sensor.h"
|
||||||
|
#include "board.h"
|
||||||
|
|
||||||
|
#define CAM_FRAME_COUNT_USE 50
|
||||||
|
|
||||||
|
static struct bflb_device_s *i2c0;
|
||||||
|
static struct bflb_device_s *cam0;
|
||||||
|
|
||||||
|
static volatile uint32_t cam_int_cnt = 0, pic_size;
|
||||||
|
static uint8_t *pic;
|
||||||
|
|
||||||
|
void cam_isr(int irq, void *arg)
|
||||||
|
{
|
||||||
|
bflb_cam_int_clear(cam0, CAM_INTCLR_NORMAL);
|
||||||
|
cam_int_cnt++;
|
||||||
|
pic_size = bflb_cam_get_frame_info(cam0, &pic);
|
||||||
|
bflb_cam_pop_one_frame(cam0);
|
||||||
|
printf("CAM interrupt, pop picture %d: 0x%08x, len: %d\r\n", cam_int_cnt, (uint32_t)pic, pic_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
uint32_t i;
|
||||||
|
struct bflb_cam_config_s cam_config;
|
||||||
|
struct image_sensor_config_s *sensor_config;
|
||||||
|
|
||||||
|
board_init();
|
||||||
|
board_dvp_gpio_init();
|
||||||
|
|
||||||
|
i2c0 = bflb_device_get_by_name("i2c0");
|
||||||
|
cam0 = bflb_device_get_by_name("cam0");
|
||||||
|
|
||||||
|
if (image_sensor_scan(i2c0, &sensor_config)) {
|
||||||
|
printf("\r\nSensor name: %s\r\n", sensor_config->name);
|
||||||
|
} else {
|
||||||
|
printf("\r\nError! Can't identify sensor!\r\n");
|
||||||
|
while (1) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bflb_cam_int_mask(cam0, CAM_INTMASK_NORMAL, false);
|
||||||
|
bflb_irq_attach(cam0->irq_num, cam_isr, NULL);
|
||||||
|
bflb_irq_enable(cam0->irq_num);
|
||||||
|
|
||||||
|
memcpy(&cam_config, sensor_config, IMAGE_SENSOR_INFO_COPY_SIZE);
|
||||||
|
cam_config.with_mjpeg = false;
|
||||||
|
cam_config.output_format = CAM_OUTPUT_FORMAT_AUTO;
|
||||||
|
cam_config.output_bufaddr = BFLB_PSRAM_BASE;
|
||||||
|
cam_config.output_bufsize = cam_config.resolution_x * cam_config.resolution_y * 12;
|
||||||
|
|
||||||
|
bflb_cam_init(cam0, &cam_config);
|
||||||
|
bflb_cam_start(cam0);
|
||||||
|
|
||||||
|
while (cam_int_cnt < CAM_FRAME_COUNT_USE) {
|
||||||
|
}
|
||||||
|
|
||||||
|
bflb_cam_stop(cam0);
|
||||||
|
|
||||||
|
//for (i = 0; i < pic_size; i++) {
|
||||||
|
// printf("%02x", pic[i]);
|
||||||
|
//}
|
||||||
|
//printf("\r\n");
|
||||||
|
|
||||||
|
printf("end\r\n");
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
bflb_mtimer_delay_ms(1000);
|
||||||
|
}
|
||||||
|
}
|
2
examples/peripherals/cam/cam_int/proj.conf
Normal file
2
examples/peripherals/cam/cam_int/proj.conf
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
set(CONFIG_BSP_IMAGE_SENSOR 1)
|
||||||
|
set(CONFIG_PSRAM 1)
|
9
examples/peripherals/cam/cam_normal/CMakeLists.txt
Normal file
9
examples/peripherals/cam/cam_normal/CMakeLists.txt
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.15)
|
||||||
|
|
||||||
|
include(proj.conf)
|
||||||
|
|
||||||
|
find_package(bouffalo_sdk REQUIRED HINTS $ENV{BL_SDK_BASE})
|
||||||
|
|
||||||
|
sdk_set_main_file(main.c)
|
||||||
|
|
||||||
|
project(cam_normal)
|
13
examples/peripherals/cam/cam_normal/Makefile
Normal file
13
examples/peripherals/cam/cam_normal/Makefile
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
SDK_DEMO_PATH ?= .
|
||||||
|
BL_SDK_BASE ?= $(SDK_DEMO_PATH)/../../../..
|
||||||
|
|
||||||
|
export BL_SDK_BASE
|
||||||
|
|
||||||
|
CHIP ?= bl616
|
||||||
|
BOARD ?= bl616dk
|
||||||
|
CROSS_COMPILE ?= riscv64-unknown-elf-
|
||||||
|
|
||||||
|
# add custom cmake definition
|
||||||
|
#cmake_definition+=-Dxxx=sss
|
||||||
|
|
||||||
|
include $(BL_SDK_BASE)/project.build
|
62
examples/peripherals/cam/cam_normal/main.c
Normal file
62
examples/peripherals/cam/cam_normal/main.c
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
#include "bflb_mtimer.h"
|
||||||
|
#include "bflb_i2c.h"
|
||||||
|
#include "bflb_cam.h"
|
||||||
|
#include "image_sensor.h"
|
||||||
|
#include "board.h"
|
||||||
|
|
||||||
|
#define CAM_FRAME_COUNT_USE 50
|
||||||
|
|
||||||
|
static struct bflb_device_s *i2c0;
|
||||||
|
static struct bflb_device_s *cam0;
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
uint32_t i, pic_size;
|
||||||
|
uint8_t *pic;
|
||||||
|
struct bflb_cam_config_s cam_config;
|
||||||
|
struct image_sensor_config_s *sensor_config;
|
||||||
|
|
||||||
|
board_init();
|
||||||
|
board_dvp_gpio_init();
|
||||||
|
|
||||||
|
i2c0 = bflb_device_get_by_name("i2c0");
|
||||||
|
cam0 = bflb_device_get_by_name("cam0");
|
||||||
|
|
||||||
|
if (image_sensor_scan(i2c0, &sensor_config)) {
|
||||||
|
printf("\r\nSensor name: %s\r\n", sensor_config->name);
|
||||||
|
} else {
|
||||||
|
printf("\r\nError! Can't identify sensor!\r\n");
|
||||||
|
while (1) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(&cam_config, sensor_config, IMAGE_SENSOR_INFO_COPY_SIZE);
|
||||||
|
cam_config.with_mjpeg = false;
|
||||||
|
cam_config.output_format = CAM_OUTPUT_FORMAT_AUTO;
|
||||||
|
cam_config.output_bufaddr = BFLB_PSRAM_BASE;
|
||||||
|
cam_config.output_bufsize = cam_config.resolution_x * cam_config.resolution_y * 8;
|
||||||
|
|
||||||
|
bflb_cam_init(cam0, &cam_config);
|
||||||
|
bflb_cam_start(cam0);
|
||||||
|
|
||||||
|
for (i = 0; i < CAM_FRAME_COUNT_USE; i++) {
|
||||||
|
while (bflb_cam_get_frame_count(cam0) == 0) {
|
||||||
|
}
|
||||||
|
pic_size = bflb_cam_get_frame_info(cam0, &pic);
|
||||||
|
bflb_cam_pop_one_frame(cam0);
|
||||||
|
printf("pop picture %d: 0x%08x, len: %d\r\n", i, (uint32_t)pic, pic_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
bflb_cam_stop(cam0);
|
||||||
|
|
||||||
|
//for (i = 0; i < pic_size; i++) {
|
||||||
|
// printf("%02x", pic[i]);
|
||||||
|
//}
|
||||||
|
//printf("\r\n");
|
||||||
|
|
||||||
|
printf("end\r\n");
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
bflb_mtimer_delay_ms(1000);
|
||||||
|
}
|
||||||
|
}
|
2
examples/peripherals/cam/cam_normal/proj.conf
Normal file
2
examples/peripherals/cam/cam_normal/proj.conf
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
set(CONFIG_BSP_IMAGE_SENSOR 1)
|
||||||
|
set(CONFIG_PSRAM 1)
|
9
examples/peripherals/cam/cam_yuv420/CMakeLists.txt
Normal file
9
examples/peripherals/cam/cam_yuv420/CMakeLists.txt
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.15)
|
||||||
|
|
||||||
|
include(proj.conf)
|
||||||
|
|
||||||
|
find_package(bouffalo_sdk REQUIRED HINTS $ENV{BL_SDK_BASE})
|
||||||
|
|
||||||
|
sdk_set_main_file(main.c)
|
||||||
|
|
||||||
|
project(cam_yuv420)
|
13
examples/peripherals/cam/cam_yuv420/Makefile
Normal file
13
examples/peripherals/cam/cam_yuv420/Makefile
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
SDK_DEMO_PATH ?= .
|
||||||
|
BL_SDK_BASE ?= $(SDK_DEMO_PATH)/../../../..
|
||||||
|
|
||||||
|
export BL_SDK_BASE
|
||||||
|
|
||||||
|
CHIP ?= bl616
|
||||||
|
BOARD ?= bl616dk
|
||||||
|
CROSS_COMPILE ?= riscv64-unknown-elf-
|
||||||
|
|
||||||
|
# add custom cmake definition
|
||||||
|
#cmake_definition+=-Dxxx=sss
|
||||||
|
|
||||||
|
include $(BL_SDK_BASE)/project.build
|
82
examples/peripherals/cam/cam_yuv420/main.c
Normal file
82
examples/peripherals/cam/cam_yuv420/main.c
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
#include "bflb_mtimer.h"
|
||||||
|
#include "bflb_i2c.h"
|
||||||
|
#include "bflb_cam.h"
|
||||||
|
#include "image_sensor.h"
|
||||||
|
#include "board.h"
|
||||||
|
|
||||||
|
#define CAM_FRAME_COUNT_USE 50
|
||||||
|
|
||||||
|
static struct bflb_device_s *i2c0;
|
||||||
|
static struct bflb_device_s *cam0_y;
|
||||||
|
static struct bflb_device_s *cam1_uv;
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
uint32_t i, pic_size_y, pic_size_uv;
|
||||||
|
uint8_t *pic_y, *pic_uv;
|
||||||
|
struct bflb_cam_config_s cam_config;
|
||||||
|
struct image_sensor_config_s *sensor_config;
|
||||||
|
|
||||||
|
board_init();
|
||||||
|
board_dvp_gpio_init();
|
||||||
|
|
||||||
|
i2c0 = bflb_device_get_by_name("i2c0");
|
||||||
|
cam0_y = bflb_device_get_by_name("cam0");
|
||||||
|
cam1_uv = bflb_device_get_by_name("cam1");
|
||||||
|
|
||||||
|
if (image_sensor_scan(i2c0, &sensor_config)) {
|
||||||
|
printf("\r\nSensor name: %s\r\n", sensor_config->name);
|
||||||
|
} else {
|
||||||
|
printf("\r\nError! Can't identify sensor!\r\n");
|
||||||
|
while (1) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Init cam0 for Y */
|
||||||
|
memcpy(&cam_config, sensor_config, IMAGE_SENSOR_INFO_COPY_SIZE);
|
||||||
|
cam_config.with_mjpeg = false;
|
||||||
|
cam_config.output_format = CAM_OUTPUT_FORMAT_GRAY;
|
||||||
|
cam_config.output_bufaddr = BFLB_PSRAM_BASE;
|
||||||
|
cam_config.output_bufsize = cam_config.resolution_x * cam_config.resolution_y * 6;
|
||||||
|
bflb_cam_init(cam0_y, &cam_config);
|
||||||
|
|
||||||
|
/* Init cam1 for UV */
|
||||||
|
cam_config.output_format = CAM_OUTPUT_FORMAT_YUV420_UV;
|
||||||
|
cam_config.output_bufaddr += cam_config.output_bufsize;
|
||||||
|
cam_config.output_bufsize /= 2;
|
||||||
|
bflb_cam_init(cam1_uv, &cam_config);
|
||||||
|
|
||||||
|
bflb_cam_start(cam0_y);
|
||||||
|
bflb_cam_start(cam1_uv);
|
||||||
|
|
||||||
|
for (i = 0; i < CAM_FRAME_COUNT_USE; i++) {
|
||||||
|
while (bflb_cam_get_frame_count(cam0_y) == 0 || bflb_cam_get_frame_count(cam1_uv) == 0) {
|
||||||
|
}
|
||||||
|
pic_size_y = bflb_cam_get_frame_info(cam0_y, &pic_y);
|
||||||
|
pic_size_uv = bflb_cam_get_frame_info(cam1_uv, &pic_uv);
|
||||||
|
bflb_cam_pop_one_frame(cam0_y);
|
||||||
|
bflb_cam_pop_one_frame(cam1_uv);
|
||||||
|
printf("pop picture_y %d: 0x%08x, len: %d\r\n", i, (uint32_t)pic_y, pic_size_y);
|
||||||
|
printf("pop picture_uv %d: 0x%08x, len: %d\r\n", i, (uint32_t)pic_uv, pic_size_uv);
|
||||||
|
}
|
||||||
|
|
||||||
|
bflb_cam_stop(cam0_y);
|
||||||
|
bflb_cam_stop(cam1_uv);
|
||||||
|
|
||||||
|
/* Printf Y */
|
||||||
|
//for (i = 0; i < pic_size_y; i++) {
|
||||||
|
// printf("%02x", pic_y[i]);
|
||||||
|
//}
|
||||||
|
|
||||||
|
/* Printf UV */
|
||||||
|
//for (i = 0; i < pic_size_uv; i++) {
|
||||||
|
// printf("%02x", pic_uv[i]);
|
||||||
|
//}
|
||||||
|
//printf("\r\n");
|
||||||
|
|
||||||
|
printf("end\r\n");
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
bflb_mtimer_delay_ms(1000);
|
||||||
|
}
|
||||||
|
}
|
2
examples/peripherals/cam/cam_yuv420/proj.conf
Normal file
2
examples/peripherals/cam/cam_yuv420/proj.conf
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
set(CONFIG_BSP_IMAGE_SENSOR 1)
|
||||||
|
set(CONFIG_PSRAM 1)
|
@ -70,7 +70,8 @@ int main(void)
|
|||||||
|
|
||||||
bflb_dma_channel_irq_attach(dma0_ch0, dma0_ch0_isr, NULL);
|
bflb_dma_channel_irq_attach(dma0_ch0, dma0_ch0_isr, NULL);
|
||||||
|
|
||||||
bflb_dac_init(dac, DAC_SAMPLING_FREQ_512K);
|
/* 512K / 1 = 512K */
|
||||||
|
bflb_dac_init(dac, DAC_CLK_DIV_1);
|
||||||
bflb_dac_channel_enable(dac, DAC_CHANNEL_A);
|
bflb_dac_channel_enable(dac, DAC_CHANNEL_A);
|
||||||
bflb_dac_channel_enable(dac, DAC_CHANNEL_B);
|
bflb_dac_channel_enable(dac, DAC_CHANNEL_B);
|
||||||
bflb_dac_link_txdma(dac, true);
|
bflb_dac_link_txdma(dac, true);
|
||||||
|
@ -43,7 +43,8 @@ int main(void)
|
|||||||
|
|
||||||
dac = bflb_device_get_by_name("dac");
|
dac = bflb_device_get_by_name("dac");
|
||||||
|
|
||||||
bflb_dac_init(dac, DAC_SAMPLING_FREQ_32K);
|
/* 512K / 16 = 32K */
|
||||||
|
bflb_dac_init(dac, DAC_CLK_DIV_16);
|
||||||
bflb_dac_channel_enable(dac, DAC_CHANNEL_A);
|
bflb_dac_channel_enable(dac, DAC_CHANNEL_A);
|
||||||
bflb_dac_channel_enable(dac, DAC_CHANNEL_B);
|
bflb_dac_channel_enable(dac, DAC_CHANNEL_B);
|
||||||
|
|
||||||
|
9
examples/peripherals/efuse/efuse_rw/CMakeLists.txt
Normal file
9
examples/peripherals/efuse/efuse_rw/CMakeLists.txt
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.15)
|
||||||
|
|
||||||
|
include(proj.conf)
|
||||||
|
|
||||||
|
find_package(bouffalo_sdk REQUIRED HINTS $ENV{BL_SDK_BASE})
|
||||||
|
|
||||||
|
sdk_set_main_file(main.c)
|
||||||
|
|
||||||
|
project(efuse_rw)
|
13
examples/peripherals/efuse/efuse_rw/Makefile
Normal file
13
examples/peripherals/efuse/efuse_rw/Makefile
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
SDK_DEMO_PATH ?= .
|
||||||
|
BL_SDK_BASE ?= $(SDK_DEMO_PATH)/../../../..
|
||||||
|
|
||||||
|
export BL_SDK_BASE
|
||||||
|
|
||||||
|
CHIP ?= bl616
|
||||||
|
BOARD ?= bl616dk
|
||||||
|
CROSS_COMPILE ?= riscv64-unknown-elf-
|
||||||
|
|
||||||
|
# add custom cmake definition
|
||||||
|
#cmake_definition+=-Dxxx=sss
|
||||||
|
|
||||||
|
include $(BL_SDK_BASE)/project.build
|
93
examples/peripherals/efuse/efuse_rw/main.c
Normal file
93
examples/peripherals/efuse/efuse_rw/main.c
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
#include "bflb_mtimer.h"
|
||||||
|
#include "board.h"
|
||||||
|
#include "bflb_ef_ctrl.h"
|
||||||
|
|
||||||
|
#define EFUSE_DATA_LEN 4
|
||||||
|
#define EFUSE_DATA_START_ADDR 0x1c
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
struct bflb_device_s *efuse_dev;
|
||||||
|
uint32_t efuse_data_write[EFUSE_DATA_LEN] = { 0xAAAAAAAA, 0x55555555, 0x12345678, 0x87654321 };
|
||||||
|
uint32_t efuse_data_read[EFUSE_DATA_LEN] = { 0 };
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
board_init();
|
||||||
|
|
||||||
|
efuse_dev = bflb_device_get_by_name("ef_ctrl");
|
||||||
|
if (NULL == efuse_dev) {
|
||||||
|
printf("efuse device driver not found!\r\n");
|
||||||
|
while (1)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("\r\neFuse read write case!\r\n");
|
||||||
|
printf("this case should be demo on bare efuse region !!!\r\n");
|
||||||
|
|
||||||
|
/* just write data to efuse data reg, not program */
|
||||||
|
printf("\r\nwrite but not program\r\n");
|
||||||
|
bflb_ef_ctrl_write_direct(efuse_dev, EFUSE_DATA_START_ADDR, (uint32_t *)efuse_data_write, EFUSE_DATA_LEN, 0);
|
||||||
|
|
||||||
|
printf("read back \r\n");
|
||||||
|
bflb_ef_ctrl_read_direct(efuse_dev, EFUSE_DATA_START_ADDR, (uint32_t *)efuse_data_read, EFUSE_DATA_LEN, 0);
|
||||||
|
for (i = 0; i < EFUSE_DATA_LEN; i++) {
|
||||||
|
if (efuse_data_read[i] != efuse_data_write[i]) {
|
||||||
|
printf("Efuse read back error\r\n");
|
||||||
|
printf("read=%08x,expected=%08x\r\n", efuse_data_read[i], efuse_data_write[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* we should get zeros since last write not programmed into eFuse(program=0) */
|
||||||
|
printf("read back with reload\r\n");
|
||||||
|
bflb_ef_ctrl_read_direct(efuse_dev, EFUSE_DATA_START_ADDR, (uint32_t *)efuse_data_read, EFUSE_DATA_LEN, 1);
|
||||||
|
for (i = 0; i < EFUSE_DATA_LEN; i++) {
|
||||||
|
if (efuse_data_read[i] != 0) {
|
||||||
|
printf("Efuse read back with reload error\r\n");
|
||||||
|
printf("read=%08x,expected=%08x\r\n", efuse_data_read[i], 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* write data to efuse data reg and program */
|
||||||
|
printf("\r\nwrite and program\r\n");
|
||||||
|
bflb_ef_ctrl_write_direct(efuse_dev, EFUSE_DATA_START_ADDR, (uint32_t *)efuse_data_write, EFUSE_DATA_LEN, 1);
|
||||||
|
|
||||||
|
printf("read back \r\n");
|
||||||
|
bflb_ef_ctrl_read_direct(efuse_dev, EFUSE_DATA_START_ADDR, (uint32_t *)efuse_data_read, EFUSE_DATA_LEN, 0);
|
||||||
|
for (i = 0; i < EFUSE_DATA_LEN; i++) {
|
||||||
|
if (efuse_data_read[i] != efuse_data_write[i]) {
|
||||||
|
printf("Efuse read back error\r\n");
|
||||||
|
printf("read=%08x,expected=%08x\r\n", efuse_data_read[i], efuse_data_write[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("read back with reload\r\n");
|
||||||
|
bflb_ef_ctrl_read_direct(efuse_dev, EFUSE_DATA_START_ADDR, (uint32_t *)efuse_data_read, EFUSE_DATA_LEN, 1);
|
||||||
|
for (i = 0; i < EFUSE_DATA_LEN; i++) {
|
||||||
|
if (efuse_data_read[i] != efuse_data_write[i]) {
|
||||||
|
printf("Efuse read back with reload error\r\n");
|
||||||
|
printf("read=%08x,expected=%08x\r\n", efuse_data_read[i], efuse_data_write[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* change the zero bits into 1 and program */
|
||||||
|
printf("\r\nwrite and program the zero bits\r\n");
|
||||||
|
for (i = 0; i < EFUSE_DATA_LEN; i++) {
|
||||||
|
efuse_data_write[i] = ~efuse_data_write[i];
|
||||||
|
}
|
||||||
|
bflb_ef_ctrl_write_direct(efuse_dev, EFUSE_DATA_START_ADDR, (uint32_t *)efuse_data_write, EFUSE_DATA_LEN, 1);
|
||||||
|
|
||||||
|
/* now,all the data should be 0xffffffff */
|
||||||
|
printf("read back with reload\r\n");
|
||||||
|
bflb_ef_ctrl_read_direct(efuse_dev, EFUSE_DATA_START_ADDR, (uint32_t *)efuse_data_read, EFUSE_DATA_LEN, 1);
|
||||||
|
for (i = 0; i < EFUSE_DATA_LEN; i++) {
|
||||||
|
if (efuse_data_read[i] != 0xffffffff) {
|
||||||
|
printf("Efuse read back with reload error\r\n");
|
||||||
|
printf("read=%08x,expected=%08x\r\n", efuse_data_read[i], 0xffffffff);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("case finished!\r\n");
|
||||||
|
while (1) {
|
||||||
|
bflb_mtimer_delay_ms(1000);
|
||||||
|
}
|
||||||
|
}
|
2
examples/peripherals/efuse/efuse_rw/proj.conf
Normal file
2
examples/peripherals/efuse/efuse_rw/proj.conf
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
set(CONFIG_VLIBC 0)
|
||||||
|
set(CONFIG_BFLOG 0)
|
9
examples/peripherals/efuse/efuse_trim/CMakeLists.txt
Normal file
9
examples/peripherals/efuse/efuse_trim/CMakeLists.txt
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.15)
|
||||||
|
|
||||||
|
include(proj.conf)
|
||||||
|
|
||||||
|
find_package(bouffalo_sdk REQUIRED HINTS $ENV{BL_SDK_BASE})
|
||||||
|
|
||||||
|
sdk_set_main_file(main.c)
|
||||||
|
|
||||||
|
project(efuse_trim)
|
13
examples/peripherals/efuse/efuse_trim/Makefile
Normal file
13
examples/peripherals/efuse/efuse_trim/Makefile
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
SDK_DEMO_PATH ?= .
|
||||||
|
BL_SDK_BASE ?= $(SDK_DEMO_PATH)/../../../..
|
||||||
|
|
||||||
|
export BL_SDK_BASE
|
||||||
|
|
||||||
|
CHIP ?= bl616
|
||||||
|
BOARD ?= bl616dk
|
||||||
|
CROSS_COMPILE ?= riscv64-unknown-elf-
|
||||||
|
|
||||||
|
# add custom cmake definition
|
||||||
|
#cmake_definition+=-Dxxx=sss
|
||||||
|
|
||||||
|
include $(BL_SDK_BASE)/project.build
|
44
examples/peripherals/efuse/efuse_trim/main.c
Normal file
44
examples/peripherals/efuse/efuse_trim/main.c
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
#include "bflb_mtimer.h"
|
||||||
|
#include "board.h"
|
||||||
|
#include "bflb_ef_ctrl.h"
|
||||||
|
|
||||||
|
char *trim_list[] = {
|
||||||
|
"rc32m",
|
||||||
|
"rc32k",
|
||||||
|
"tsen"
|
||||||
|
};
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
struct bflb_device_s *efuse_dev;
|
||||||
|
bflb_ef_ctrl_com_trim_t trim;
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
board_init();
|
||||||
|
printf("\r\neFuse read trim value case!\r\n");
|
||||||
|
|
||||||
|
efuse_dev = bflb_device_get_by_name("ef_ctrl");
|
||||||
|
if (NULL == efuse_dev) {
|
||||||
|
printf("efuse device driver not found!\r\n");
|
||||||
|
while (1)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < sizeof(trim_list) / sizeof(trim_list[0]); i++) {
|
||||||
|
bflb_ef_ctrl_read_common_trim(NULL, trim_list[i], &trim, 1);
|
||||||
|
if (trim.en) {
|
||||||
|
if (trim.parity == bflb_ef_ctrl_get_trim_parity(trim.value, trim.len)) {
|
||||||
|
printf("trim %s value=%d!\r\n", trim_list[i], trim.value);
|
||||||
|
} else {
|
||||||
|
printf("trim %s parity error!\r\n", trim_list[i]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
printf("trim %s not found!\r\n", trim_list[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("case finished!\r\n");
|
||||||
|
while (1) {
|
||||||
|
bflb_mtimer_delay_ms(1000);
|
||||||
|
}
|
||||||
|
}
|
2
examples/peripherals/efuse/efuse_trim/proj.conf
Normal file
2
examples/peripherals/efuse/efuse_trim/proj.conf
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
set(CONFIG_VLIBC 0)
|
||||||
|
set(CONFIG_BFLOG 0)
|
@ -105,7 +105,7 @@ int main(void)
|
|||||||
.mac_addr[5] = 0x56,
|
.mac_addr[5] = 0x56,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct emac_phy_cfg_s phy_cfg = {
|
struct bflb_emac_phy_cfg_s phy_cfg = {
|
||||||
.auto_negotiation = 1, /*!< Speed and mode auto negotiation */
|
.auto_negotiation = 1, /*!< Speed and mode auto negotiation */
|
||||||
.full_duplex = 0, /*!< Duplex mode */
|
.full_duplex = 0, /*!< Duplex mode */
|
||||||
.speed = 0, /*!< Speed mode */
|
.speed = 0, /*!< Speed mode */
|
||||||
@ -129,7 +129,7 @@ int main(void)
|
|||||||
bflb_emac_int_clear(emac0, EMAC_INT_EN_ALL);
|
bflb_emac_int_clear(emac0, EMAC_INT_EN_ALL);
|
||||||
bflb_emac_int_enable(emac0, EMAC_INT_EN_ALL, 1);
|
bflb_emac_int_enable(emac0, EMAC_INT_EN_ALL, 1);
|
||||||
|
|
||||||
printf("EMAC ARB Packet test!\r\n");
|
printf("EMAC ARP Packet test!\r\n");
|
||||||
|
|
||||||
/* phy module init */
|
/* phy module init */
|
||||||
ethernet_phy_init(emac0, &phy_cfg);
|
ethernet_phy_init(emac0, &phy_cfg);
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
set(CONFIG_VLIBC 0)
|
set(CONFIG_VLIBC 0)
|
||||||
set(CONFIG_BFLOG 0)
|
set(CONFIG_BFLOG 0)
|
||||||
|
|
||||||
set(CONFIG_BSP_COMMON 1)
|
|
||||||
set(CONFIG_ETHERNET 1)
|
set(CONFIG_ETHERNET 1)
|
@ -37,6 +37,7 @@
|
|||||||
|
|
||||||
#include "http_server.h"
|
#include "http_server.h"
|
||||||
|
|
||||||
|
|
||||||
const HtmlServerRouter_TypeDef httpRouter[] = {
|
const HtmlServerRouter_TypeDef httpRouter[] = {
|
||||||
{ "/", "/index.html" },
|
{ "/", "/index.html" },
|
||||||
{ "/favicon.ico", "/asset/favicon.ico" },
|
{ "/favicon.ico", "/asset/favicon.ico" },
|
||||||
|
@ -3,5 +3,4 @@ set(CONFIG_BFLOG 0)
|
|||||||
set(CONFIG_FREERTOS 1)
|
set(CONFIG_FREERTOS 1)
|
||||||
set(CONFIG_LWIP 1)
|
set(CONFIG_LWIP 1)
|
||||||
|
|
||||||
set(CONFIG_BSP_COMMON 1)
|
|
||||||
set(CONFIG_ETHERNET 1)
|
set(CONFIG_ETHERNET 1)
|
@ -3,5 +3,4 @@ set(CONFIG_BFLOG 0)
|
|||||||
set(CONFIG_FREERTOS 1)
|
set(CONFIG_FREERTOS 1)
|
||||||
set(CONFIG_LWIP 1)
|
set(CONFIG_LWIP 1)
|
||||||
|
|
||||||
set(CONFIG_BSP_COMMON 1)
|
|
||||||
set(CONFIG_ETHERNET 1)
|
set(CONFIG_ETHERNET 1)
|
@ -3,5 +3,4 @@ set(CONFIG_BFLOG 0)
|
|||||||
set(CONFIG_FREERTOS 1)
|
set(CONFIG_FREERTOS 1)
|
||||||
set(CONFIG_LWIP 1)
|
set(CONFIG_LWIP 1)
|
||||||
|
|
||||||
set(CONFIG_BSP_COMMON 1)
|
|
||||||
set(CONFIG_ETHERNET 1)
|
set(CONFIG_ETHERNET 1)
|
@ -31,6 +31,11 @@ static void bflb_data_compare(const uint8_t *expected, uint8_t *input, uint32_t
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This demo tests two decryption ways.
|
||||||
|
* One is decrypted by aes module, another is decrypted by flash aes module.
|
||||||
|
*/
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
board_init();
|
board_init();
|
||||||
@ -84,15 +89,10 @@ int main(void)
|
|||||||
printf("flash decrypt with flash aes ctr128 success\r\n");
|
printf("flash decrypt with flash aes ctr128 success\r\n");
|
||||||
|
|
||||||
bflb_flash_read(0x00010000, aes_ctr_tmp_buffer, AES_DATA_LEN);
|
bflb_flash_read(0x00010000, aes_ctr_tmp_buffer, AES_DATA_LEN);
|
||||||
bflb_aes_decrypt(aes, &aes_ctr_tmp_buffer[0], aes_ctr_128bit_iv, &aes_ctr_tmp_buffer2[0], 1024);
|
bflb_aes_decrypt(aes, &aes_ctr_tmp_buffer[0], aes_ctr_128bit_iv, &aes_ctr_tmp_buffer2[0], 1024); /* set new iv */
|
||||||
aes_ctr_128bit_iv[15] = 0x40; /* update counter */
|
bflb_aes_decrypt(aes, &aes_ctr_tmp_buffer[1024], NULL, &aes_ctr_tmp_buffer2[1024], 1024); /* use last iv */
|
||||||
bflb_aes_decrypt(aes, &aes_ctr_tmp_buffer[1024], aes_ctr_128bit_iv, &aes_ctr_tmp_buffer2[1024], 1024);
|
bflb_aes_decrypt(aes, &aes_ctr_tmp_buffer[1024 * 2], NULL, &aes_ctr_tmp_buffer2[1024 * 2], 1024); /* use last iv */
|
||||||
aes_ctr_128bit_iv[15] = 0x80; /* update counter */
|
bflb_aes_decrypt(aes, &aes_ctr_tmp_buffer[1024 * 3], NULL, &aes_ctr_tmp_buffer2[1024 * 3], 1024); /* use last iv */
|
||||||
bflb_aes_decrypt(aes, &aes_ctr_tmp_buffer[1024 * 2], aes_ctr_128bit_iv, &aes_ctr_tmp_buffer2[1024 * 2], 1024);
|
|
||||||
aes_ctr_128bit_iv[15] = 0xc0; /* update counter */
|
|
||||||
bflb_aes_decrypt(aes, &aes_ctr_tmp_buffer[1024 * 3], aes_ctr_128bit_iv, &aes_ctr_tmp_buffer2[1024 * 3], 1024);
|
|
||||||
aes_ctr_128bit_iv[15] = 0x00; /* update counter */
|
|
||||||
aes_ctr_128bit_iv[14] = 0x01;
|
|
||||||
bflb_data_compare(aes_ctr_pt_buffer, aes_ctr_tmp_buffer2, AES_DATA_LEN);
|
bflb_data_compare(aes_ctr_pt_buffer, aes_ctr_tmp_buffer2, AES_DATA_LEN);
|
||||||
printf("flash decrypt with sec eng aes ctr128 success\r\n");
|
printf("flash decrypt with sec eng aes ctr128 success\r\n");
|
||||||
|
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
#include "bflb_gpio.h"
|
#include "bflb_gpio.h"
|
||||||
|
#include "board.h"
|
||||||
|
|
||||||
struct bflb_device_s *gpio;
|
struct bflb_device_s *gpio;
|
||||||
|
|
||||||
extern void board_init(void);
|
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
board_init();
|
board_init();
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
#include "bflb_gpio.h"
|
#include "bflb_gpio.h"
|
||||||
#include "bflb_mtimer.h"
|
#include "bflb_mtimer.h"
|
||||||
|
#include "board.h"
|
||||||
|
|
||||||
struct bflb_device_s *gpio;
|
struct bflb_device_s *gpio;
|
||||||
|
|
||||||
extern void board_init(void);
|
|
||||||
|
|
||||||
void gpio_isr(int irq, void *arg)
|
void gpio_isr(int irq, void *arg)
|
||||||
{
|
{
|
||||||
static int i = 0;
|
static int i = 0;
|
||||||
@ -22,7 +21,7 @@ int main(void)
|
|||||||
gpio = bflb_device_get_by_name("gpio");
|
gpio = bflb_device_get_by_name("gpio");
|
||||||
printf("gpio interrupt\r\n");
|
printf("gpio interrupt\r\n");
|
||||||
|
|
||||||
bflb_gpio_int_init(gpio, GPIO_PIN_0, GPIO_INT_TRIG_MODE_SYNC_FALLING_EDGE);
|
bflb_gpio_int_init(gpio, GPIO_PIN_0, GPIO_INT_TRIG_MODE_SYNC_LOW_LEVEL);
|
||||||
bflb_gpio_int_mask(gpio, GPIO_PIN_0, false);
|
bflb_gpio_int_mask(gpio, GPIO_PIN_0, false);
|
||||||
|
|
||||||
bflb_irq_attach(gpio->irq_num, gpio_isr, gpio);
|
bflb_irq_attach(gpio->irq_num, gpio_isr, gpio);
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
#define EEPROM_SELECT_PAGE1 (1 << 5)
|
#define EEPROM_SELECT_PAGE1 (1 << 5)
|
||||||
|
|
||||||
static struct bflb_device_s *i2c0;
|
static struct bflb_device_s *i2c0;
|
||||||
|
static volatile uint32_t txFifoFlag = 0;
|
||||||
|
static volatile uint32_t rxFifoFlag = 0;
|
||||||
|
|
||||||
void i2c_isr(int irq, void *arg)
|
void i2c_isr(int irq, void *arg)
|
||||||
{
|
{
|
||||||
@ -18,6 +20,14 @@ void i2c_isr(int irq, void *arg)
|
|||||||
bflb_i2c_int_mask(i2c0, I2C_INT_END, true);
|
bflb_i2c_int_mask(i2c0, I2C_INT_END, true);
|
||||||
printf("Transfer end interrupt\r\n");
|
printf("Transfer end interrupt\r\n");
|
||||||
}
|
}
|
||||||
|
if (status & I2C_INTSTS_TX_FIFO) {
|
||||||
|
bflb_i2c_int_mask(i2c0, I2C_INT_TX_FIFO, true);
|
||||||
|
txFifoFlag = 1;
|
||||||
|
}
|
||||||
|
if (status & I2C_INTSTS_RX_FIFO) {
|
||||||
|
bflb_i2c_int_mask(i2c0, I2C_INT_RX_FIFO, true);
|
||||||
|
rxFifoFlag = 1;
|
||||||
|
}
|
||||||
if (status & I2C_INTSTS_NACK) {
|
if (status & I2C_INTSTS_NACK) {
|
||||||
bflb_i2c_int_mask(i2c0, I2C_INT_NACK, true);
|
bflb_i2c_int_mask(i2c0, I2C_INT_NACK, true);
|
||||||
printf("Error! NACK interrupt\r\n");
|
printf("Error! NACK interrupt\r\n");
|
||||||
@ -42,7 +52,7 @@ int main(void)
|
|||||||
bflb_i2c_init(i2c0, 400000);
|
bflb_i2c_init(i2c0, 400000);
|
||||||
|
|
||||||
/* Set i2c interrupt */
|
/* Set i2c interrupt */
|
||||||
bflb_i2c_int_mask(i2c0, I2C_INT_END | I2C_INT_NACK | I2C_INT_ARB | I2C_INT_FER, false);
|
bflb_i2c_int_mask(i2c0, I2C_INTEN_END | I2C_INTEN_TX_FIFO | I2C_INTEN_RX_FIFO | I2C_INTEN_NACK | I2C_INTEN_ARB | I2C_INTEN_FER, false);
|
||||||
bflb_irq_attach(i2c0->irq_num, i2c_isr, NULL);
|
bflb_irq_attach(i2c0->irq_num, i2c_isr, NULL);
|
||||||
bflb_irq_enable(i2c0->irq_num);
|
bflb_irq_enable(i2c0->irq_num);
|
||||||
|
|
||||||
@ -72,11 +82,19 @@ int main(void)
|
|||||||
msgs[1].length = EEPROM_TRANSFER_LENGTH;
|
msgs[1].length = EEPROM_TRANSFER_LENGTH;
|
||||||
|
|
||||||
bflb_i2c_transfer(i2c0, msgs, 2);
|
bflb_i2c_transfer(i2c0, msgs, 2);
|
||||||
|
if (txFifoFlag) {
|
||||||
|
printf("TX FIFO Ready interrupt generated\r\n");
|
||||||
|
txFifoFlag = 0;
|
||||||
|
}
|
||||||
|
if (rxFifoFlag) {
|
||||||
|
printf("RX FIFO Ready interrupt generated\r\n");
|
||||||
|
rxFifoFlag = 0;
|
||||||
|
}
|
||||||
printf("write over\r\n\r\n");
|
printf("write over\r\n\r\n");
|
||||||
bflb_mtimer_delay_ms(100);
|
bflb_mtimer_delay_ms(100);
|
||||||
|
|
||||||
/* Unmask interrupt */
|
/* Unmask interrupt */
|
||||||
bflb_i2c_int_mask(i2c0, I2C_INT_END | I2C_INT_NACK | I2C_INT_ARB | I2C_INT_FER, false);
|
bflb_i2c_int_mask(i2c0, I2C_INT_END | I2C_INT_TX_FIFO | I2C_INT_RX_FIFO | I2C_INT_NACK | I2C_INT_ARB | I2C_INT_FER, false);
|
||||||
|
|
||||||
/* Write page 1 */
|
/* Write page 1 */
|
||||||
subaddr[1] = EEPROM_SELECT_PAGE1;
|
subaddr[1] = EEPROM_SELECT_PAGE1;
|
||||||
@ -87,11 +105,19 @@ int main(void)
|
|||||||
msgs[1].length = EEPROM_TRANSFER_LENGTH;
|
msgs[1].length = EEPROM_TRANSFER_LENGTH;
|
||||||
|
|
||||||
bflb_i2c_transfer(i2c0, msgs, 2);
|
bflb_i2c_transfer(i2c0, msgs, 2);
|
||||||
|
if (txFifoFlag) {
|
||||||
|
printf("TX FIFO Ready interrupt generated\r\n");
|
||||||
|
txFifoFlag = 0;
|
||||||
|
}
|
||||||
|
if (rxFifoFlag) {
|
||||||
|
printf("RX FIFO Ready interrupt generated\r\n");
|
||||||
|
rxFifoFlag = 0;
|
||||||
|
}
|
||||||
printf("write over\r\n\r\n");
|
printf("write over\r\n\r\n");
|
||||||
bflb_mtimer_delay_ms(100);
|
bflb_mtimer_delay_ms(100);
|
||||||
|
|
||||||
/* Unmask interrupt */
|
/* Unmask interrupt */
|
||||||
bflb_i2c_int_mask(i2c0, I2C_INT_END | I2C_INT_NACK | I2C_INT_ARB | I2C_INT_FER, false);
|
bflb_i2c_int_mask(i2c0, I2C_INT_END | I2C_INT_TX_FIFO | I2C_INT_RX_FIFO | I2C_INT_NACK | I2C_INT_ARB | I2C_INT_FER, false);
|
||||||
|
|
||||||
/* Read page 0 */
|
/* Read page 0 */
|
||||||
subaddr[1] = EEPROM_SELECT_PAGE0;
|
subaddr[1] = EEPROM_SELECT_PAGE0;
|
||||||
@ -101,11 +127,19 @@ int main(void)
|
|||||||
msgs[1].buffer = read_data;
|
msgs[1].buffer = read_data;
|
||||||
msgs[1].length = EEPROM_TRANSFER_LENGTH;
|
msgs[1].length = EEPROM_TRANSFER_LENGTH;
|
||||||
bflb_i2c_transfer(i2c0, msgs, 2);
|
bflb_i2c_transfer(i2c0, msgs, 2);
|
||||||
|
if (txFifoFlag) {
|
||||||
|
printf("TX FIFO Ready interrupt generated\r\n");
|
||||||
|
txFifoFlag = 0;
|
||||||
|
}
|
||||||
|
if (rxFifoFlag) {
|
||||||
|
printf("RX FIFO Ready interrupt generated\r\n");
|
||||||
|
rxFifoFlag = 0;
|
||||||
|
}
|
||||||
printf("read over\r\n\r\n");
|
printf("read over\r\n\r\n");
|
||||||
bflb_mtimer_delay_ms(100);
|
bflb_mtimer_delay_ms(100);
|
||||||
|
|
||||||
/* Unmask interrupt */
|
/* Unmask interrupt */
|
||||||
bflb_i2c_int_mask(i2c0, I2C_INT_END | I2C_INT_NACK | I2C_INT_ARB | I2C_INT_FER, false);
|
bflb_i2c_int_mask(i2c0, I2C_INT_END | I2C_INT_TX_FIFO | I2C_INT_RX_FIFO | I2C_INT_NACK | I2C_INT_ARB | I2C_INT_FER, false);
|
||||||
|
|
||||||
/* Read page 1 */
|
/* Read page 1 */
|
||||||
subaddr[1] = EEPROM_SELECT_PAGE1;
|
subaddr[1] = EEPROM_SELECT_PAGE1;
|
||||||
@ -115,6 +149,14 @@ int main(void)
|
|||||||
msgs[1].buffer = read_data + EEPROM_TRANSFER_LENGTH;
|
msgs[1].buffer = read_data + EEPROM_TRANSFER_LENGTH;
|
||||||
msgs[1].length = EEPROM_TRANSFER_LENGTH;
|
msgs[1].length = EEPROM_TRANSFER_LENGTH;
|
||||||
bflb_i2c_transfer(i2c0, msgs, 2);
|
bflb_i2c_transfer(i2c0, msgs, 2);
|
||||||
|
if (txFifoFlag) {
|
||||||
|
printf("TX FIFO Ready interrupt generated\r\n");
|
||||||
|
txFifoFlag = 0;
|
||||||
|
}
|
||||||
|
if (rxFifoFlag) {
|
||||||
|
printf("RX FIFO Ready interrupt generated\r\n");
|
||||||
|
rxFifoFlag = 0;
|
||||||
|
}
|
||||||
printf("read over\r\n\r\n");
|
printf("read over\r\n\r\n");
|
||||||
bflb_mtimer_delay_ms(100);
|
bflb_mtimer_delay_ms(100);
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ export BL_SDK_BASE
|
|||||||
|
|
||||||
CHIP ?= bl808
|
CHIP ?= bl808
|
||||||
BOARD ?= bl808dk
|
BOARD ?= bl808dk
|
||||||
|
CPU_ID ?= m0
|
||||||
CROSS_COMPILE ?= riscv64-unknown-elf-
|
CROSS_COMPILE ?= riscv64-unknown-elf-
|
||||||
|
|
||||||
# add custom cmake definition
|
# add custom cmake definition
|
||||||
|
@ -13,7 +13,7 @@ int main(void)
|
|||||||
{
|
{
|
||||||
board_init();
|
board_init();
|
||||||
|
|
||||||
printf("IR NEC case:\n\r");
|
printf("IR NEC case:\r\n");
|
||||||
|
|
||||||
board_ir_gpio_init();
|
board_ir_gpio_init();
|
||||||
|
|
||||||
@ -58,16 +58,16 @@ int main(void)
|
|||||||
#ifdef IR_TX_NEC
|
#ifdef IR_TX_NEC
|
||||||
/* Check data received */
|
/* Check data received */
|
||||||
if (rx_data != tx_buffer[0]) {
|
if (rx_data != tx_buffer[0]) {
|
||||||
printf("Data error! receive bit: %d, value: 0x%016llx\n\r", rx_len, rx_data);
|
printf("Data error! receive bit: %d, value: 0x%016lx\r\n", rx_len, rx_data);
|
||||||
} else {
|
} else {
|
||||||
printf("Success\n\r");
|
printf("Received correctly. receive bit: %d, value: 0x%016lx\r\n", rx_len, rx_data);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
printf("Receive bit: %d, value: 0x%016llx\n\r", rx_len, rx_data);
|
printf("Receive bit: %d, value: 0x%016lx\r\n", rx_len, rx_data);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
printf("end\n\r");
|
printf("end\r\n");
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ export BL_SDK_BASE
|
|||||||
|
|
||||||
CHIP ?= bl808
|
CHIP ?= bl808
|
||||||
BOARD ?= bl808dk
|
BOARD ?= bl808dk
|
||||||
|
CPU_ID ?= m0
|
||||||
CROSS_COMPILE ?= riscv64-unknown-elf-
|
CROSS_COMPILE ?= riscv64-unknown-elf-
|
||||||
|
|
||||||
# add custom cmake definition
|
# add custom cmake definition
|
||||||
|
@ -13,7 +13,7 @@ int main(void)
|
|||||||
{
|
{
|
||||||
board_init();
|
board_init();
|
||||||
|
|
||||||
printf("IR RC-5 case:\n\r");
|
printf("IR RC-5 case:\r\n");
|
||||||
|
|
||||||
board_ir_gpio_init();
|
board_ir_gpio_init();
|
||||||
|
|
||||||
@ -58,16 +58,16 @@ int main(void)
|
|||||||
#ifdef IR_TX_NEC
|
#ifdef IR_TX_NEC
|
||||||
/* Check data received */
|
/* Check data received */
|
||||||
if (rx_data != tx_buffer[0]) {
|
if (rx_data != tx_buffer[0]) {
|
||||||
printf("Data error! receive bit: %d, value: 0x%016llx\n\r", rx_len, rx_data);
|
printf("Data error! receive bit: %d, value: 0x%016lx\r\n", rx_len, rx_data);
|
||||||
} else {
|
} else {
|
||||||
printf("Success\n\r");
|
printf("Received correctly. receive bit: %d, value: 0x%016lx\r\n", rx_len, rx_data);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
printf("Receive bit: %d, value: 0x%016llx\n\r", rx_len, rx_data);
|
printf("Receive bit: %d, value: 0x%016lx\r\n", rx_len, rx_data);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
printf("end\n\r");
|
printf("end\r\n");
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ export BL_SDK_BASE
|
|||||||
|
|
||||||
CHIP ?= bl808
|
CHIP ?= bl808
|
||||||
BOARD ?= bl808dk
|
BOARD ?= bl808dk
|
||||||
|
CPU_ID ?= m0
|
||||||
CROSS_COMPILE ?= riscv64-unknown-elf-
|
CROSS_COMPILE ?= riscv64-unknown-elf-
|
||||||
|
|
||||||
# add custom cmake definition
|
# add custom cmake definition
|
||||||
|
@ -15,7 +15,7 @@ int main(void)
|
|||||||
|
|
||||||
board_init();
|
board_init();
|
||||||
|
|
||||||
printf("IR SWM case:\n\r");
|
printf("IR SWM case:\r\n");
|
||||||
|
|
||||||
board_ir_gpio_init();
|
board_ir_gpio_init();
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ int main(void)
|
|||||||
printf("\r\n");
|
printf("\r\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
printf("\n\rend\n\r");
|
printf("end\r\n");
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ export BL_SDK_BASE
|
|||||||
|
|
||||||
CHIP ?= bl808
|
CHIP ?= bl808
|
||||||
BOARD ?= bl808dk
|
BOARD ?= bl808dk
|
||||||
|
CPU_ID ?= m0
|
||||||
CROSS_COMPILE ?= riscv64-unknown-elf-
|
CROSS_COMPILE ?= riscv64-unknown-elf-
|
||||||
|
|
||||||
# add custom cmake definition
|
# add custom cmake definition
|
||||||
|
@ -66,7 +66,7 @@ int main(void)
|
|||||||
|
|
||||||
board_init();
|
board_init();
|
||||||
|
|
||||||
printf("IR TX DMA case:\n\r");
|
printf("IR TX DMA case:\r\n");
|
||||||
|
|
||||||
board_ir_gpio_init();
|
board_ir_gpio_init();
|
||||||
|
|
||||||
@ -96,7 +96,7 @@ int main(void)
|
|||||||
}
|
}
|
||||||
printf("Check wave\r\n");
|
printf("Check wave\r\n");
|
||||||
|
|
||||||
printf("end\n\r");
|
printf("end\r\n");
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
}
|
}
|
||||||
|
@ -29,28 +29,6 @@ void mjpeg_isr(int irq, void *arg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint16_t q_table_50_y[64] = {
|
|
||||||
16, 11, 10, 16, 24, 40, 51, 61,
|
|
||||||
12, 12, 14, 19, 26, 58, 60, 55,
|
|
||||||
14, 13, 16, 24, 40, 57, 69, 56,
|
|
||||||
14, 17, 22, 29, 51, 87, 80, 62,
|
|
||||||
18, 22, 37, 56, 68, 109, 103, 77,
|
|
||||||
24, 35, 55, 64, 81, 104, 113, 92,
|
|
||||||
49, 64, 78, 87, 103, 121, 120, 101,
|
|
||||||
72, 92, 95, 98, 112, 100, 103, 99
|
|
||||||
};
|
|
||||||
|
|
||||||
static uint16_t q_table_50_uv[64] = {
|
|
||||||
17, 18, 24, 47, 99, 99, 99, 99,
|
|
||||||
18, 21, 26, 66, 99, 99, 99, 99,
|
|
||||||
24, 26, 56, 99, 99, 99, 99, 99,
|
|
||||||
47, 66, 99, 99, 99, 99, 99, 99,
|
|
||||||
99, 99, 99, 99, 99, 99, 99, 99,
|
|
||||||
99, 99, 99, 99, 99, 99, 99, 99,
|
|
||||||
99, 99, 99, 99, 99, 99, 99, 99,
|
|
||||||
99, 99, 99, 99, 99, 99, 99, 99
|
|
||||||
};
|
|
||||||
|
|
||||||
uint8_t jpg_head_buf[800] = { 0 };
|
uint8_t jpg_head_buf[800] = { 0 };
|
||||||
uint32_t jpg_head_len;
|
uint32_t jpg_head_len;
|
||||||
|
|
||||||
@ -81,9 +59,6 @@ void bflb_mjpeg_dump_hex(uint8_t *data, uint32_t len)
|
|||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
uint16_t tmp_table_y[64] = { 0 };
|
|
||||||
uint16_t tmp_table_uv[64] = { 0 };
|
|
||||||
|
|
||||||
board_init();
|
board_init();
|
||||||
|
|
||||||
mjpeg = bflb_device_get_by_name("mjpeg");
|
mjpeg = bflb_device_get_by_name("mjpeg");
|
||||||
@ -91,18 +66,18 @@ int main(void)
|
|||||||
struct bflb_mjpeg_config_s config;
|
struct bflb_mjpeg_config_s config;
|
||||||
|
|
||||||
config.format = MJPEG_FORMAT_YUV422_YUYV;
|
config.format = MJPEG_FORMAT_YUV422_YUYV;
|
||||||
|
config.quality = MJPEG_QUALITY;
|
||||||
config.resolution_x = X;
|
config.resolution_x = X;
|
||||||
config.resolution_y = Y;
|
config.resolution_y = Y;
|
||||||
config.input_bufaddr0 = (uint32_t)test_64x64;
|
config.input_bufaddr0 = (uint32_t)test_64x64;
|
||||||
config.input_bufaddr1 = 0;
|
config.input_bufaddr1 = 0;
|
||||||
config.output_bufaddr = (uint32_t)BSP_PSRAM_BASE + MJPEG_MAX_FRAME_COUNT * X * Y * 2;
|
config.output_bufaddr = (uint32_t)BSP_PSRAM_BASE + MJPEG_MAX_FRAME_COUNT * X * Y * 2;
|
||||||
config.output_bufsize = SIZE_BUFFER - MJPEG_MAX_FRAME_COUNT * X * Y * 2;
|
config.output_bufsize = SIZE_BUFFER - MJPEG_MAX_FRAME_COUNT * X * Y * 2;
|
||||||
|
config.input_yy_table = NULL; /* use default table */
|
||||||
|
config.input_uv_table = NULL; /* use default table */
|
||||||
|
|
||||||
bflb_mjpeg_init(mjpeg, &config);
|
bflb_mjpeg_init(mjpeg, &config);
|
||||||
|
|
||||||
bflb_mjpeg_calculate_quantize_table(MJPEG_QUALITY, q_table_50_y, tmp_table_y);
|
|
||||||
bflb_mjpeg_calculate_quantize_table(MJPEG_QUALITY, q_table_50_uv, tmp_table_uv);
|
|
||||||
bflb_mjpeg_fill_quantize_table(mjpeg, tmp_table_y, tmp_table_uv);
|
|
||||||
jpg_head_len = JpegHeadCreate(YUV_MODE_422, MJPEG_QUALITY, X, Y, jpg_head_buf);
|
jpg_head_len = JpegHeadCreate(YUV_MODE_422, MJPEG_QUALITY, X, Y, jpg_head_buf);
|
||||||
bflb_mjpeg_fill_jpeg_header_tail(mjpeg, jpg_head_buf, jpg_head_len);
|
bflb_mjpeg_fill_jpeg_header_tail(mjpeg, jpg_head_buf, jpg_head_len);
|
||||||
|
|
||||||
@ -113,7 +88,7 @@ int main(void)
|
|||||||
bflb_mjpeg_sw_run(mjpeg, MJPEG_MAX_FRAME_COUNT);
|
bflb_mjpeg_sw_run(mjpeg, MJPEG_MAX_FRAME_COUNT);
|
||||||
|
|
||||||
while (pic_count < MJPEG_MAX_FRAME_COUNT) {
|
while (pic_count < MJPEG_MAX_FRAME_COUNT) {
|
||||||
printf("pic count:%d\r\n",pic_count);
|
printf("pic count:%d\r\n", pic_count);
|
||||||
bflb_mtimer_delay_ms(200);
|
bflb_mtimer_delay_ms(200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,14 +1,6 @@
|
|||||||
#include "bflb_mtimer.h"
|
#include "bflb_core.h"
|
||||||
#include "board.h"
|
#include "board.h"
|
||||||
|
|
||||||
#if defined(BL702)
|
|
||||||
#define BSP_PSRAM_BASE 0x26000000
|
|
||||||
#elif defined(BL616)
|
|
||||||
#define BSP_PSRAM_BASE 0xA8000000
|
|
||||||
#elif defined(BL808)
|
|
||||||
#define BSP_PSRAM_BASE 0x50000000
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void test32(void)
|
void test32(void)
|
||||||
{
|
{
|
||||||
uint32_t i, val;
|
uint32_t i, val;
|
||||||
@ -16,12 +8,12 @@ void test32(void)
|
|||||||
printf("============= check uint32_t ==============\r\n");
|
printf("============= check uint32_t ==============\r\n");
|
||||||
|
|
||||||
for (i = 0; i < 256; i += 4) {
|
for (i = 0; i < 256; i += 4) {
|
||||||
*((volatile uint32_t *)(BSP_PSRAM_BASE + i)) = i / 4;
|
*((volatile uint32_t *)(BFLB_PSRAM_BASE + i)) = i / 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < 256; i += 4) {
|
for (i = 0; i < 256; i += 4) {
|
||||||
val = *((volatile uint32_t *)(BSP_PSRAM_BASE + i));
|
val = *((volatile uint32_t *)(BFLB_PSRAM_BASE + i));
|
||||||
printf("addr = 0x%08X, val = 0x%08X\r\n", (BSP_PSRAM_BASE + i), *((volatile uint32_t *)(BSP_PSRAM_BASE + i)));
|
printf("addr = 0x%08X, val = 0x%08X\r\n", (BFLB_PSRAM_BASE + i), *((volatile uint32_t *)(BFLB_PSRAM_BASE + i)));
|
||||||
|
|
||||||
if (i / 4 != val) {
|
if (i / 4 != val) {
|
||||||
printf("psram check fail\r\n");
|
printf("psram check fail\r\n");
|
||||||
@ -38,12 +30,12 @@ void test16(void)
|
|||||||
printf("============= check uint16_t ==============\r\n");
|
printf("============= check uint16_t ==============\r\n");
|
||||||
|
|
||||||
for (i = 0; i < 256; i += 2) {
|
for (i = 0; i < 256; i += 2) {
|
||||||
*((volatile uint16_t *)(BSP_PSRAM_BASE + i)) = i / 2;
|
*((volatile uint16_t *)(BFLB_PSRAM_BASE + i)) = i / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < 256; i += 2) {
|
for (i = 0; i < 256; i += 2) {
|
||||||
val = *((volatile uint16_t *)(BSP_PSRAM_BASE + i));
|
val = *((volatile uint16_t *)(BFLB_PSRAM_BASE + i));
|
||||||
printf("addr = 0x%08X, val = 0x%08X\r\n", (BSP_PSRAM_BASE + i), *((volatile uint16_t *)(BSP_PSRAM_BASE + i)));
|
printf("addr = 0x%08X, val = 0x%08X\r\n", (BFLB_PSRAM_BASE + i), *((volatile uint16_t *)(BFLB_PSRAM_BASE + i)));
|
||||||
|
|
||||||
if (i / 2 != val) {
|
if (i / 2 != val) {
|
||||||
printf("psram check fail\r\n");
|
printf("psram check fail\r\n");
|
||||||
@ -61,12 +53,12 @@ void test8(void)
|
|||||||
printf("============= check uint8_t ==============\r\n");
|
printf("============= check uint8_t ==============\r\n");
|
||||||
|
|
||||||
for (i = 0; i < 256; i++) {
|
for (i = 0; i < 256; i++) {
|
||||||
*((volatile uint8_t *)(BSP_PSRAM_BASE + i)) = i;
|
*((volatile uint8_t *)(BFLB_PSRAM_BASE + i)) = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < 256; i++) {
|
for (i = 0; i < 256; i++) {
|
||||||
val = *((volatile uint8_t *)(BSP_PSRAM_BASE + i));
|
val = *((volatile uint8_t *)(BFLB_PSRAM_BASE + i));
|
||||||
printf("addr = 0x%08X, val = 0x%08X\r\n", (BSP_PSRAM_BASE + i), *((volatile uint8_t *)(BSP_PSRAM_BASE + i)));
|
printf("addr = 0x%08X, val = 0x%08X\r\n", (BFLB_PSRAM_BASE + i), *((volatile uint8_t *)(BFLB_PSRAM_BASE + i)));
|
||||||
|
|
||||||
if ((uint8_t)i != val) {
|
if ((uint8_t)i != val) {
|
||||||
printf("psram check fail\r\n");
|
printf("psram check fail\r\n");
|
||||||
|
@ -132,6 +132,12 @@ void spi_isr(int irq, void *arg)
|
|||||||
//printf("tc done\r\n");
|
//printf("tc done\r\n");
|
||||||
spi_tc_done_count++;
|
spi_tc_done_count++;
|
||||||
}
|
}
|
||||||
|
if (intstatus & SPI_INTSTS_TX_FIFO) {
|
||||||
|
//printf("tx fifo\r\n");
|
||||||
|
}
|
||||||
|
if (intstatus & SPI_INTSTS_RX_FIFO) {
|
||||||
|
//printf("rx fifo\r\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
@ -140,10 +146,11 @@ int main(void)
|
|||||||
board_spi0_gpio_init();
|
board_spi0_gpio_init();
|
||||||
|
|
||||||
struct bflb_spi_config_s spi_cfg = {
|
struct bflb_spi_config_s spi_cfg = {
|
||||||
.freq = 20 * 1000 * 1000,
|
|
||||||
#if (SPI_CASE_SELECT == SPI_MASTER_CASE)
|
#if (SPI_CASE_SELECT == SPI_MASTER_CASE)
|
||||||
|
.freq = 1 * 1000 * 1000,
|
||||||
.role = SPI_ROLE_MASTER,
|
.role = SPI_ROLE_MASTER,
|
||||||
#else
|
#else
|
||||||
|
.freq = 32 * 1000 * 1000,
|
||||||
.role = SPI_ROLE_SLAVE,
|
.role = SPI_ROLE_SLAVE,
|
||||||
#endif
|
#endif
|
||||||
.mode = SPI_MODE3,
|
.mode = SPI_MODE3,
|
||||||
@ -157,6 +164,8 @@ int main(void)
|
|||||||
spi0 = bflb_device_get_by_name("spi0");
|
spi0 = bflb_device_get_by_name("spi0");
|
||||||
bflb_spi_init(spi0, &spi_cfg);
|
bflb_spi_init(spi0, &spi_cfg);
|
||||||
|
|
||||||
|
// bflb_spi_txint_mask(spi0, false);
|
||||||
|
// bflb_spi_rxint_mask(spi0, false);
|
||||||
bflb_spi_tcint_mask(spi0, false);
|
bflb_spi_tcint_mask(spi0, false);
|
||||||
bflb_irq_attach(spi0->irq_num, spi_isr, NULL);
|
bflb_irq_attach(spi0->irq_num, spi_isr, NULL);
|
||||||
bflb_irq_enable(spi0->irq_num);
|
bflb_irq_enable(spi0->irq_num);
|
||||||
@ -169,21 +178,27 @@ int main(void)
|
|||||||
} else {
|
} else {
|
||||||
printf("poll send 8-bit test success!\r\n");
|
printf("poll send 8-bit test success!\r\n");
|
||||||
}
|
}
|
||||||
|
#if (SPI_CASE_SELECT == SPI_MASTER_CASE)
|
||||||
|
bflb_mtimer_delay_ms(1000); /* delay for slave device prepare ok */
|
||||||
|
#endif
|
||||||
printf("\r\n************** spi poll send 16-bit test **************\r\n");
|
printf("\r\n************** spi poll send 16-bit test **************\r\n");
|
||||||
if (bflb_spi_poll_test(SPI_DATA_WIDTH_16BIT) < 0) {
|
if (bflb_spi_poll_test(SPI_DATA_WIDTH_16BIT) < 0) {
|
||||||
printf("poll send 16-bit test error!!!\r\n");
|
printf("poll send 16-bit test error!!!\r\n");
|
||||||
} else {
|
} else {
|
||||||
printf("poll send 16-bit test success!\r\n");
|
printf("poll send 16-bit test success!\r\n");
|
||||||
}
|
}
|
||||||
|
#if (SPI_CASE_SELECT == SPI_MASTER_CASE)
|
||||||
|
bflb_mtimer_delay_ms(1000); /* delay for slave device prepare ok */
|
||||||
|
#endif
|
||||||
printf("\r\n************** spi poll send 24-bit test **************\r\n");
|
printf("\r\n************** spi poll send 24-bit test **************\r\n");
|
||||||
if (bflb_spi_poll_test(SPI_DATA_WIDTH_24BIT) < 0) {
|
if (bflb_spi_poll_test(SPI_DATA_WIDTH_24BIT) < 0) {
|
||||||
printf("poll send 24-bit test error!!!\r\n");
|
printf("poll send 24-bit test error!!!\r\n");
|
||||||
} else {
|
} else {
|
||||||
printf("poll send 24-bit test success!\r\n");
|
printf("poll send 24-bit test success!\r\n");
|
||||||
}
|
}
|
||||||
|
#if (SPI_CASE_SELECT == SPI_MASTER_CASE)
|
||||||
|
bflb_mtimer_delay_ms(1000); /* delay for slave device prepare ok */
|
||||||
|
#endif
|
||||||
printf("\r\n************** spi poll send 32-bit test **************\r\n");
|
printf("\r\n************** spi poll send 32-bit test **************\r\n");
|
||||||
if (bflb_spi_poll_test(SPI_DATA_WIDTH_32BIT) < 0) {
|
if (bflb_spi_poll_test(SPI_DATA_WIDTH_32BIT) < 0) {
|
||||||
printf("poll send 32-bit test error!!!\r\n");
|
printf("poll send 32-bit test error!!!\r\n");
|
||||||
@ -191,7 +206,9 @@ int main(void)
|
|||||||
printf("poll send 32-bit test success!\r\n");
|
printf("poll send 32-bit test success!\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
bflb_mtimer_delay_ms(10);
|
#if (SPI_CASE_SELECT == SPI_MASTER_CASE)
|
||||||
|
bflb_mtimer_delay_ms(1000); /* delay for slave device prepare ok */
|
||||||
|
#endif
|
||||||
|
|
||||||
printf("\r\n************** spi poll exchange 8-bit test **************\r\n");
|
printf("\r\n************** spi poll exchange 8-bit test **************\r\n");
|
||||||
|
|
||||||
@ -200,21 +217,27 @@ int main(void)
|
|||||||
} else {
|
} else {
|
||||||
printf("poll exchange 8-bit test success!\r\n");
|
printf("poll exchange 8-bit test success!\r\n");
|
||||||
}
|
}
|
||||||
|
#if (SPI_CASE_SELECT == SPI_MASTER_CASE)
|
||||||
|
bflb_mtimer_delay_ms(1000); /* delay for slave device prepare ok */
|
||||||
|
#endif
|
||||||
printf("\r\n************** spi poll exchange 16-bit test **************\r\n");
|
printf("\r\n************** spi poll exchange 16-bit test **************\r\n");
|
||||||
if (bflb_spi_poll_exchange_test(SPI_DATA_WIDTH_16BIT) < 0) {
|
if (bflb_spi_poll_exchange_test(SPI_DATA_WIDTH_16BIT) < 0) {
|
||||||
printf("poll exchange 16-bit test error!!!\r\n");
|
printf("poll exchange 16-bit test error!!!\r\n");
|
||||||
} else {
|
} else {
|
||||||
printf("poll exchange 16-bit test success!\r\n");
|
printf("poll exchange 16-bit test success!\r\n");
|
||||||
}
|
}
|
||||||
|
#if (SPI_CASE_SELECT == SPI_MASTER_CASE)
|
||||||
|
bflb_mtimer_delay_ms(1000); /* delay for slave device prepare ok */
|
||||||
|
#endif
|
||||||
printf("\r\n************** spi poll exchange 24-bit test **************\r\n");
|
printf("\r\n************** spi poll exchange 24-bit test **************\r\n");
|
||||||
if (bflb_spi_poll_exchange_test(SPI_DATA_WIDTH_24BIT) < 0) {
|
if (bflb_spi_poll_exchange_test(SPI_DATA_WIDTH_24BIT) < 0) {
|
||||||
printf("poll exchange 24-bit test error!!!\r\n");
|
printf("poll exchange 24-bit test error!!!\r\n");
|
||||||
} else {
|
} else {
|
||||||
printf("poll exchange 24-bit test success!\r\n");
|
printf("poll exchange 24-bit test success!\r\n");
|
||||||
}
|
}
|
||||||
|
#if (SPI_CASE_SELECT == SPI_MASTER_CASE)
|
||||||
|
bflb_mtimer_delay_ms(1000); /* delay for slave device prepare ok */
|
||||||
|
#endif
|
||||||
printf("\r\n************** spi poll exchange 32-bit test **************\r\n");
|
printf("\r\n************** spi poll exchange 32-bit test **************\r\n");
|
||||||
if (bflb_spi_poll_exchange_test(SPI_DATA_WIDTH_32BIT) < 0) {
|
if (bflb_spi_poll_exchange_test(SPI_DATA_WIDTH_32BIT) < 0) {
|
||||||
printf("poll exchange 32-bit test error!!!\r\n");
|
printf("poll exchange 32-bit test error!!!\r\n");
|
||||||
@ -222,16 +245,22 @@ int main(void)
|
|||||||
printf("poll exchange 32-bit test success!\r\n");
|
printf("poll exchange 32-bit test success!\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
bflb_mtimer_delay_ms(10);
|
#if (SPI_CASE_SELECT == SPI_MASTER_CASE)
|
||||||
|
bflb_mtimer_delay_ms(1000); /* delay for slave device prepare ok */
|
||||||
|
#endif
|
||||||
|
|
||||||
printf("\r\n************** spi poll exchange only send 32-bit test **************\r\n");
|
printf("\r\n************** spi poll exchange only send 32-bit test **************\r\n");
|
||||||
bflb_spi_poll_exchange(spi0, tx_buff, NULL, BUFF_LEN);
|
bflb_spi_poll_exchange(spi0, tx_buff, NULL, BUFF_LEN);
|
||||||
printf("poll exchange 32-bit only send test end!\r\n");
|
printf("poll exchange 32-bit only send test end!\r\n");
|
||||||
|
#if (SPI_CASE_SELECT == SPI_MASTER_CASE)
|
||||||
|
bflb_mtimer_delay_ms(1000); /* delay for slave device prepare ok */
|
||||||
|
#endif
|
||||||
printf("\r\n************** spi poll exchange only receive 32-bit test **************\r\n");
|
printf("\r\n************** spi poll exchange only receive 32-bit test **************\r\n");
|
||||||
bflb_spi_poll_exchange(spi0, NULL, rx_buff, BUFF_LEN);
|
bflb_spi_poll_exchange(spi0, NULL, rx_buff, BUFF_LEN);
|
||||||
printf("poll exchange 32-bit only receive test end!\r\n");
|
printf("poll exchange 32-bit only receive test end!\r\n");
|
||||||
|
#if (SPI_CASE_SELECT == SPI_MASTER_CASE)
|
||||||
|
bflb_mtimer_delay_ms(1000); /* delay for slave device prepare ok */
|
||||||
|
#endif
|
||||||
printf("\r\n************** spi poll exchange spare time clock 32-bit test **************\r\n");
|
printf("\r\n************** spi poll exchange spare time clock 32-bit test **************\r\n");
|
||||||
bflb_spi_poll_exchange(spi0, NULL, NULL, BUFF_LEN);
|
bflb_spi_poll_exchange(spi0, NULL, NULL, BUFF_LEN);
|
||||||
printf("poll exchange 32-bit spare time clock test end!\r\n");
|
printf("poll exchange 32-bit spare time clock test end!\r\n");
|
||||||
|
@ -12,7 +12,7 @@ int main(void)
|
|||||||
board_init();
|
board_init();
|
||||||
board_uartx_gpio_init();
|
board_uartx_gpio_init();
|
||||||
|
|
||||||
uartx = bflb_device_get_by_name("uartx");
|
uartx = bflb_device_get_by_name(DEFAULT_TEST_UART);
|
||||||
|
|
||||||
for (uint8_t i = 0; i < 128; i++) {
|
for (uint8_t i = 0; i < 128; i++) {
|
||||||
uart_txbuf[i] = i;
|
uart_txbuf[i] = i;
|
||||||
|
Reference in New Issue
Block a user