diff --git a/examples/adc/adc_continuous_differential/cdk/adc_continuous_differential.cdkproj b/examples/adc/adc_continuous_differential/cdk/adc_continuous_differential.cdkproj index 007dc93b..8d44bf41 100644 --- a/examples/adc/adc_continuous_differential/cdk/adc_continuous_differential.cdkproj +++ b/examples/adc/adc_continuous_differential/cdk/adc_continuous_differential.cdkproj @@ -32,9 +32,6 @@ Board: bl70x_iot - - - @@ -71,6 +68,10 @@ Board: bl70x_iot + + + + diff --git a/examples/adc/adc_continuous_differential/main.c b/examples/adc/adc_continuous_differential/main.c index d4bbd8c2..7a6142e2 100644 --- a/examples/adc/adc_continuous_differential/main.c +++ b/examples/adc/adc_continuous_differential/main.c @@ -25,11 +25,10 @@ #define ADC_SCAN_NUM (50) -uint8_t PinList[] = {GPIO_PIN_11, GPIO_PIN_12}; adc_channel_t posChList[] = {ADC_CHANNEL3}; adc_channel_t negChList[] = {ADC_CHANNEL4}; -adc_res_val_t result_val; +adc_channel_val_t result_val; struct device* adc_test; @@ -37,31 +36,29 @@ int main(void) { bflb_platform_init(0); - adc_user_cfg_t adc_user_cfg; + adc_channel_cfg_t adc_channel_cfg; - adc_user_cfg.dma_en = DISABLE; // disable dma - adc_user_cfg.conv_mode = ADC_CON_CONV; // continuous conversion - adc_user_cfg.in_mode = ADC_DIFFERENTIAL_IN; // differential input mode - - adc_user_cfg.pinList = PinList; - adc_user_cfg.posChList = posChList; - adc_user_cfg.negChList = negChList; - adc_user_cfg.num = sizeof(posChList)/sizeof(adc_channel_t); + adc_channel_cfg.pos_channel = posChList; + adc_channel_cfg.neg_channel = negChList; + adc_channel_cfg.num = 1; MSG("adc one-shot differential test case \r\n"); - adc_register(ADC0_INDEX, "adc_one_diff", DEVICE_OFLAG_STREAM_RX, &adc_user_cfg); + adc_register(ADC0_INDEX, "adc_one_diff", DEVICE_OFLAG_STREAM_RX); adc_test = device_find("adc_one_diff"); if(adc_test) { + ADC_DEV(adc_test)->differential_mode = ENABLE; + ADC_DEV(adc_test)->continuous_conv_mode = ENABLE; device_open(adc_test, DEVICE_OFLAG_STREAM_RX); + device_control(adc_test,DEVICE_CTRL_ADC_CHANNEL_CONFIG,&adc_channel_cfg); MSG("adc device find success\r\n"); } - device_control(adc_test,DEVICE_CTRL_RESUME,0); + adc_channel_start(adc_test); while (1) { - device_read(adc_test, 0, (void *)&result_val,sizeof(result_val)/sizeof(adc_res_val_t)); + device_read(adc_test, 0, (void *)&result_val,sizeof(result_val)/sizeof(adc_channel_val_t)); if(result_val.volt <= 0) { result_val.volt = -result_val.volt; diff --git a/examples/adc/adc_continuous_single_ended/cdk/adc_continuous_single_ended.cdkproj b/examples/adc/adc_continuous_single_ended/cdk/adc_continuous_single_ended.cdkproj index 991732af..e639234b 100644 --- a/examples/adc/adc_continuous_single_ended/cdk/adc_continuous_single_ended.cdkproj +++ b/examples/adc/adc_continuous_single_ended/cdk/adc_continuous_single_ended.cdkproj @@ -32,9 +32,6 @@ Board: bl70x_iot - - - @@ -71,6 +68,10 @@ Board: bl70x_iot + + + + diff --git a/examples/adc/adc_continuous_single_ended/main.c b/examples/adc/adc_continuous_single_ended/main.c index 32eda428..2818d56c 100644 --- a/examples/adc/adc_continuous_single_ended/main.c +++ b/examples/adc/adc_continuous_single_ended/main.c @@ -23,11 +23,10 @@ #include "hal_adc.h" #include "hal_gpio.h" -uint8_t PinList[] = {GPIO_PIN_12}; adc_channel_t posChList[] = {ADC_CHANNEL4}; adc_channel_t negChList[] = {ADC_CHANNEL_GND}; -adc_res_val_t result_val; +adc_channel_val_t result_val; struct device* adc_test; @@ -35,34 +34,31 @@ int main(void) { bflb_platform_init(0); - adc_user_cfg_t adc_user_cfg; + adc_channel_cfg_t adc_channel_cfg; - adc_user_cfg.dma_en = DISABLE; // disable dma - adc_user_cfg.conv_mode = ADC_CON_CONV; // continuous conversion - adc_user_cfg.in_mode = ADC_SINGLE_ENDED_IN; // single-ended input mode - - adc_user_cfg.pinList = PinList; - adc_user_cfg.posChList = posChList; - adc_user_cfg.negChList = negChList; - adc_user_cfg.num = sizeof(posChList)/sizeof(adc_channel_t); + adc_channel_cfg.pos_channel = posChList; + adc_channel_cfg.neg_channel = negChList; + adc_channel_cfg.num = 1; MSG("adc continue single ended test case \r\n"); - adc_register(ADC0_INDEX, "adc_continue_single", DEVICE_OFLAG_STREAM_RX, &adc_user_cfg); + adc_register(ADC0_INDEX, "adc_continue_single", DEVICE_OFLAG_STREAM_RX); adc_test = device_find("adc_continue_single"); if(adc_test) { + ADC_DEV(adc_test)->continuous_conv_mode = ENABLE; device_open(adc_test, DEVICE_OFLAG_STREAM_RX); + device_control(adc_test,DEVICE_CTRL_ADC_CHANNEL_CONFIG,&adc_channel_cfg); MSG("adc device find success\r\n"); } - device_control(adc_test,DEVICE_CTRL_RESUME,0); + adc_channel_start(adc_test); while (1) { - device_read(adc_test, 0, (void *)&result_val,sizeof(result_val)/sizeof(adc_res_val_t)); + device_read(adc_test, 0, (void *)&result_val,sizeof(result_val)/sizeof(adc_channel_val_t)); MSG("PosId = %d NegId = %d V= %d mV \r\n",result_val.posChan,result_val.negChan,(uint32_t)(result_val.volt * 1000)); - // bflb_platform_delay_ms(500); + bflb_platform_delay_ms(500); } } \ No newline at end of file diff --git a/examples/adc/adc_key/cdk/adc_key.cdkproj b/examples/adc/adc_key/cdk/adc_key.cdkproj index b9fc2cc9..0c8eb0b5 100644 --- a/examples/adc/adc_key/cdk/adc_key.cdkproj +++ b/examples/adc/adc_key/cdk/adc_key.cdkproj @@ -32,9 +32,6 @@ Board: bl70x_iot - - - @@ -71,6 +68,10 @@ Board: bl70x_iot + + + + diff --git a/examples/adc/adc_key/main.c b/examples/adc/adc_key/main.c index 41c5a546..c3c9009d 100644 --- a/examples/adc/adc_key/main.c +++ b/examples/adc/adc_key/main.c @@ -38,10 +38,9 @@ typedef struct { uint16_t keyValue[KEY_FILTER_NUM]; }adc_keys_status; -uint8_t PinList[] = {GPIO_PIN_18}; adc_channel_t posChList[] = {ADC_CHANNEL8}; adc_channel_t negChList[] = {ADC_CHANNEL_GND}; -adc_res_val_t result_val; +adc_channel_val_t result_val; adc_keys_status key_machine; @@ -92,7 +91,7 @@ static int get_adc_key_value(uint32_t Vmv){ volatile uint16_t key_num[5] = {0}; uint8_t bigger = 0, i = 0, j = 0; - if(Vmv > KEY0_ADC_VALUE && Vmv < KEY4_ADC_VALUE + KEY_MEASURE_OFFSET){ + if(Vmv >= KEY0_ADC_VALUE && Vmv <= KEY4_ADC_VALUE + KEY_MEASURE_OFFSET){ key_machine.keyValue[key_machine.vaildKeyNum] = get_adc_value_range(Vmv); key_machine.vaildKeyNum++; @@ -150,31 +149,29 @@ int main(void) bflb_platform_init(0); uint16_t keyValue=0; - adc_user_cfg_t adc_user_cfg; + adc_channel_cfg_t adc_channel_cfg; - adc_user_cfg.dma_en = DISABLE; - adc_user_cfg.conv_mode = ADC_CON_CONV; - adc_user_cfg.in_mode = ADC_SINGLE_ENDED_IN; - - adc_user_cfg.pinList = PinList; - adc_user_cfg.posChList = posChList; - adc_user_cfg.negChList = negChList; - adc_user_cfg.num = sizeof(posChList)/sizeof(adc_channel_t); + adc_channel_cfg.pos_channel = posChList; + adc_channel_cfg.neg_channel = negChList; + adc_channel_cfg.num = 1; - adc_register(ADC0_INDEX, "adc_key", DEVICE_OFLAG_STREAM_RX, &adc_user_cfg); + adc_register(ADC0_INDEX, "adc_key", DEVICE_OFLAG_STREAM_RX); adc_key = device_find("adc_key"); if(adc_key) { + ADC_DEV(adc_key)->continuous_conv_mode = ENABLE; device_open(adc_key, DEVICE_OFLAG_STREAM_RX); + device_control(adc_key,DEVICE_CTRL_ADC_CHANNEL_CONFIG,&adc_channel_cfg); + }else{ MSG("device open failed\r\n"); } - device_control(adc_key,DEVICE_CTRL_RESUME,0); - key_machine_init(); + + adc_channel_start(adc_key); while (1) { diff --git a/examples/adc/adc_one_shot_differential/cdk/adc_one_shot_differential.cdkproj b/examples/adc/adc_one_shot_differential/cdk/adc_one_shot_differential.cdkproj index 75bcbb06..49d935ea 100644 --- a/examples/adc/adc_one_shot_differential/cdk/adc_one_shot_differential.cdkproj +++ b/examples/adc/adc_one_shot_differential/cdk/adc_one_shot_differential.cdkproj @@ -32,9 +32,6 @@ Board: bl70x_iot - - - @@ -71,6 +68,10 @@ Board: bl70x_iot + + + + diff --git a/examples/adc/adc_one_shot_differential/main.c b/examples/adc/adc_one_shot_differential/main.c index 131c7151..10c6372e 100644 --- a/examples/adc/adc_one_shot_differential/main.c +++ b/examples/adc/adc_one_shot_differential/main.c @@ -25,11 +25,10 @@ #define ADC_SCAN_NUM (50) -uint8_t PinList[] = {GPIO_PIN_11, GPIO_PIN_12}; adc_channel_t posChList[] = {ADC_CHANNEL3}; adc_channel_t negChList[] = {ADC_CHANNEL4}; -adc_res_val_t result_val; +adc_channel_val_t result_val; struct device* adc_test; @@ -37,31 +36,28 @@ int main(void) { bflb_platform_init(0); - adc_user_cfg_t adc_user_cfg; + adc_channel_cfg_t adc_channel_cfg; - adc_user_cfg.dma_en = DISABLE; // disable dma - adc_user_cfg.conv_mode = ADC_ONE_CONV; // single conversion - adc_user_cfg.in_mode = ADC_DIFFERENTIAL_IN; // differential input mode - - adc_user_cfg.pinList = PinList; - adc_user_cfg.posChList = posChList; - adc_user_cfg.negChList = negChList; - adc_user_cfg.num = sizeof(posChList)/sizeof(adc_channel_t); + adc_channel_cfg.pos_channel = posChList; + adc_channel_cfg.neg_channel = negChList; + adc_channel_cfg.num = 1; MSG("adc one-shot differential test case \r\n"); - adc_register(ADC0_INDEX, "adc_one_diff", DEVICE_OFLAG_STREAM_RX, &adc_user_cfg); + adc_register(ADC0_INDEX, "adc_one_diff", DEVICE_OFLAG_STREAM_RX); adc_test = device_find("adc_one_diff"); if(adc_test) { + ADC_DEV(adc_test)->differential_mode = ENABLE; device_open(adc_test, DEVICE_OFLAG_STREAM_RX); + device_control(adc_test,DEVICE_CTRL_ADC_CHANNEL_CONFIG,&adc_channel_cfg); MSG("adc device find success\r\n"); } for(uint32_t i = 0; i < ADC_SCAN_NUM; i++ ) { - device_control(adc_test,DEVICE_CTRL_RESUME,0); - device_read(adc_test, 0, (void *)&result_val,sizeof(result_val)/sizeof(adc_res_val_t)); + adc_channel_start(adc_test); + device_read(adc_test, 0, (void *)&result_val,sizeof(result_val)/sizeof(adc_channel_val_t)); if(result_val.volt <= 0) { result_val.volt = -result_val.volt; diff --git a/examples/adc/adc_one_shot_single_ended/cdk/adc_one_shot_single_ended.cdkproj b/examples/adc/adc_one_shot_single_ended/cdk/adc_one_shot_single_ended.cdkproj index eb9b51f1..6e55ba88 100644 --- a/examples/adc/adc_one_shot_single_ended/cdk/adc_one_shot_single_ended.cdkproj +++ b/examples/adc/adc_one_shot_single_ended/cdk/adc_one_shot_single_ended.cdkproj @@ -32,9 +32,6 @@ Board: bl70x_iot - - - @@ -71,6 +68,10 @@ Board: bl70x_iot + + + + diff --git a/examples/adc/adc_one_shot_single_ended/main.c b/examples/adc/adc_one_shot_single_ended/main.c index 55000933..1be2736f 100644 --- a/examples/adc/adc_one_shot_single_ended/main.c +++ b/examples/adc/adc_one_shot_single_ended/main.c @@ -25,11 +25,10 @@ #define ADC_SCAN_NUM (100) -uint8_t PinList[] = {GPIO_PIN_11}; adc_channel_t posChList[] = {ADC_CHANNEL3}; adc_channel_t negChList[] = {ADC_CHANNEL_GND}; -adc_res_val_t result_val; +adc_channel_val_t result_val; struct device* adc_test; @@ -37,31 +36,27 @@ int main(void) { bflb_platform_init(0); - adc_user_cfg_t adc_user_cfg; + adc_channel_cfg_t adc_channel_cfg; - adc_user_cfg.dma_en = DISABLE; // disable dma - adc_user_cfg.conv_mode = ADC_ONE_CONV; // single conversion - adc_user_cfg.in_mode = ADC_SINGLE_ENDED_IN; // single-ended input mode - - adc_user_cfg.pinList = PinList; - adc_user_cfg.posChList = posChList; - adc_user_cfg.negChList = negChList; - adc_user_cfg.num = sizeof(posChList)/sizeof(adc_channel_t); + adc_channel_cfg.pos_channel = posChList; + adc_channel_cfg.neg_channel = negChList; + adc_channel_cfg.num = 1; MSG("adc one-shot single ended test case \r\n"); - adc_register(ADC0_INDEX, "adc_one_single", DEVICE_OFLAG_STREAM_RX, &adc_user_cfg); + adc_register(ADC0_INDEX, "adc_one_single", DEVICE_OFLAG_STREAM_RX); adc_test = device_find("adc_one_single"); if(adc_test) { device_open(adc_test, DEVICE_OFLAG_STREAM_RX); + device_control(adc_test,DEVICE_CTRL_ADC_CHANNEL_CONFIG,&adc_channel_cfg); MSG("adc device find success\r\n"); } for(uint32_t i = 0; i < ADC_SCAN_NUM; i++ ) { - device_control(adc_test,DEVICE_CTRL_RESUME,0); - device_read(adc_test, 0, (void *)&result_val,sizeof(result_val)/sizeof(adc_res_val_t)); + adc_channel_start(adc_test); + device_read(adc_test, 0, (void *)&result_val,sizeof(result_val)/sizeof(adc_channel_val_t)); MSG("PosId = %d NegId = %d V= %d mV \r\n",result_val.posChan,result_val.negChan,(uint32_t)(result_val.volt * 1000)); bflb_platform_delay_ms(500); } diff --git a/examples/adc/adc_scan_single_ended/cdk/adc_scan_single_ended.cdkproj b/examples/adc/adc_scan_single_ended/cdk/adc_scan_single_ended.cdkproj index f4f05b49..14e475af 100644 --- a/examples/adc/adc_scan_single_ended/cdk/adc_scan_single_ended.cdkproj +++ b/examples/adc/adc_scan_single_ended/cdk/adc_scan_single_ended.cdkproj @@ -32,9 +32,6 @@ Board: bl70x_iot - - - @@ -71,6 +68,10 @@ Board: bl70x_iot + + + + diff --git a/examples/adc/adc_scan_single_ended/main.c b/examples/adc/adc_scan_single_ended/main.c index ed90b6e4..f4f15a65 100644 --- a/examples/adc/adc_scan_single_ended/main.c +++ b/examples/adc/adc_scan_single_ended/main.c @@ -25,11 +25,10 @@ #define ADC_SCAN_NUM (50) -uint8_t PinList[] = {GPIO_PIN_11,GPIO_PIN_12}; adc_channel_t posChList[] = {ADC_CHANNEL3,ADC_CHANNEL4}; adc_channel_t negChList[] = {ADC_CHANNEL_GND,ADC_CHANNEL_GND}; -adc_res_val_t result_val; +adc_channel_val_t result_val; struct device* adc_test; @@ -37,31 +36,28 @@ int main(void) { bflb_platform_init(0); - adc_user_cfg_t adc_user_cfg; + adc_channel_cfg_t adc_channel_cfg; - adc_user_cfg.dma_en = DISABLE; // disable dma - adc_user_cfg.conv_mode = ADC_CON_CONV; // single conversion - adc_user_cfg.in_mode = ADC_SINGLE_ENDED_IN; // single-ended input mode - - adc_user_cfg.pinList = PinList; - adc_user_cfg.posChList = posChList; - adc_user_cfg.negChList = negChList; - adc_user_cfg.num = sizeof(posChList)/sizeof(adc_channel_t); + adc_channel_cfg.pos_channel = posChList; + adc_channel_cfg.neg_channel = negChList; + adc_channel_cfg.num = 2; MSG("adc one-shot single ended test case \r\n"); - adc_register(ADC0_INDEX, "adc_one_single", DEVICE_OFLAG_STREAM_RX, &adc_user_cfg); + adc_register(ADC0_INDEX, "adc_one_single", DEVICE_OFLAG_STREAM_RX); adc_test = device_find("adc_one_single"); if(adc_test) { + ADC_DEV(adc_test)->continuous_conv_mode = ENABLE; device_open(adc_test, DEVICE_OFLAG_STREAM_RX); + device_control(adc_test,DEVICE_CTRL_ADC_CHANNEL_CONFIG,&adc_channel_cfg); MSG("adc device find success\r\n"); } for(uint32_t i = 0; i < ADC_SCAN_NUM; i++ ) { - device_control(adc_test,DEVICE_CTRL_RESUME,0); - device_read(adc_test, 0, (void *)&result_val,sizeof(result_val)/sizeof(adc_res_val_t)); + adc_channel_start(adc_test); + device_read(adc_test, 0, (void *)&result_val,sizeof(result_val)/sizeof(adc_channel_val_t)); MSG("PosId = %d NegId = %d V= %d mV \r\n",result_val.posChan,result_val.negChan,(uint32_t)(result_val.volt * 1000)); // bflb_platform_delay_ms(10); } diff --git a/examples/adc/adc_vbat_poll/cdk/adc_vbat_poll.cdkproj b/examples/adc/adc_vbat_poll/cdk/adc_vbat_poll.cdkproj index 984597b1..a7c0f74c 100644 --- a/examples/adc/adc_vbat_poll/cdk/adc_vbat_poll.cdkproj +++ b/examples/adc/adc_vbat_poll/cdk/adc_vbat_poll.cdkproj @@ -32,9 +32,6 @@ Board: bl70x_iot - - - @@ -71,6 +68,10 @@ Board: bl70x_iot + + + + diff --git a/examples/adc/adc_vbat_poll/main.c b/examples/adc/adc_vbat_poll/main.c index aded3cef..83b621e7 100644 --- a/examples/adc/adc_vbat_poll/main.c +++ b/examples/adc/adc_vbat_poll/main.c @@ -23,36 +23,32 @@ #include "hal_adc.h" #include "hal_gpio.h" -uint8_t PinList[] = {GPIO_PIN_18}; // ADC Pin list setting adc_channel_t posChList[] = {ADC_CHANNEL_VABT_HALF}; // ADC Positive channel list setting adc_channel_t negChList[] = {ADC_CHANNEL_GND}; // ADC Negative channel list setting struct device* vbat_test; -adc_res_val_t result; +adc_channel_val_t result; int main(void) { bflb_platform_init(0); - adc_user_cfg_t adc_user_cfg; + adc_channel_cfg_t adc_channel_cfg; - adc_user_cfg.dma_en = DISABLE; // disable dma - adc_user_cfg.conv_mode = ADC_ONE_CONV; // single conversion - adc_user_cfg.in_mode = ADC_SINGLE_ENDED_IN; // single-ended input mode - - adc_user_cfg.pinList = PinList; - adc_user_cfg.posChList = posChList; - adc_user_cfg.negChList = negChList; - adc_user_cfg.num = sizeof(posChList)/sizeof(adc_channel_t); + adc_channel_cfg.pos_channel = posChList; + adc_channel_cfg.neg_channel = negChList; + adc_channel_cfg.num = 1; - adc_register(ADC0_INDEX, "adc_vbat_test", DEVICE_OFLAG_STREAM_RX, &adc_user_cfg); + adc_register(ADC0_INDEX, "adc_vbat_test", DEVICE_OFLAG_STREAM_RX); vbat_test = device_find("adc_vbat_test"); if(vbat_test) { MSG("adc vbat test device find success\r\n"); device_open(vbat_test,DEVICE_OFLAG_STREAM_RX); + device_control(vbat_test,DEVICE_CTRL_ADC_VBAT_ON,NULL); + device_control(vbat_test,DEVICE_CTRL_ADC_CHANNEL_CONFIG,&adc_channel_cfg); } while(1){ @@ -60,7 +56,7 @@ int main(void) MSG("adc vbat test case\r\n"); for(uint8_t i=0;i<10;i++) { - device_control(vbat_test,DEVICE_CTRL_RESUME,NULL); + adc_channel_start(vbat_test); device_read(vbat_test,0,&result,1); MSG("vBat = %d mV\n",(uint32_t)(result.volt * 2000)); diff --git a/examples/bl_mcu_sdk.cdkws b/examples/bl_mcu_sdk.cdkws index 5ef9327f..23719ad5 100644 --- a/examples/bl_mcu_sdk.cdkws +++ b/examples/bl_mcu_sdk.cdkws @@ -7,23 +7,30 @@ + + + - + + + + + @@ -34,24 +41,31 @@ + + + - - + + + + + + diff --git a/examples/dac/dac_dma/cdk/dac_dma.cdkproj b/examples/dac/dac_dma/cdk/dac_dma.cdkproj index 7cc5dc8d..92158c05 100644 --- a/examples/dac/dac_dma/cdk/dac_dma.cdkproj +++ b/examples/dac/dac_dma/cdk/dac_dma.cdkproj @@ -32,9 +32,6 @@ Board: bl70x_iot - - - @@ -71,6 +68,10 @@ Board: bl70x_iot + + + + diff --git a/examples/dac/dac_poll/cdk/dac_poll.cdkproj b/examples/dac/dac_poll/cdk/dac_poll.cdkproj index cc1ed3cd..486e894e 100644 --- a/examples/dac/dac_poll/cdk/dac_poll.cdkproj +++ b/examples/dac/dac_poll/cdk/dac_poll.cdkproj @@ -32,9 +32,6 @@ Board: bl70x_iot - - - @@ -71,6 +68,10 @@ Board: bl70x_iot + + + + diff --git a/examples/dma/dma_m2m/cdk/dma_m2m.cdkproj b/examples/dma/dma_m2m/cdk/dma_m2m.cdkproj index b708de39..467a6586 100644 --- a/examples/dma/dma_m2m/cdk/dma_m2m.cdkproj +++ b/examples/dma/dma_m2m/cdk/dma_m2m.cdkproj @@ -32,9 +32,6 @@ Board: bl70x_iot - - - @@ -71,6 +68,10 @@ Board: bl70x_iot + + + + diff --git a/examples/gpio/gpio_blink/cdk/gpio_blink.cdkproj b/examples/gpio/gpio_blink/cdk/gpio_blink.cdkproj index 2d183c79..9fb43283 100644 --- a/examples/gpio/gpio_blink/cdk/gpio_blink.cdkproj +++ b/examples/gpio/gpio_blink/cdk/gpio_blink.cdkproj @@ -32,9 +32,6 @@ Board: bl70x_iot - - - @@ -71,6 +68,12 @@ Board: bl70x_iot + + + + + + @@ -455,7 +458,7 @@ Board: bl70x_iot - 154 + 80 104 @@ -504,32 +507,6 @@ Board: bl70x_iot - - - ;;; - ;;MHZ; - - glb - uart - - 1 - 1 - - 100:8;100:8;100:8;100:8; - - - - ;;; - ;;MHZ; - - glb - uart - - 1 - 1 - - 100:8;100:8;100:8;100:8; - @@ -620,8 +597,8 @@ Board: bl70x_iot - no - $(ProjectPath)../../../../tools/bflb_flash_tool/bflb_mcu_tool.exe --chipname=bl702 --firmware="D:/BouffaloLabWS/cdk_ws/bl_mcu_sdk/examples/hellowd/Obj/helloworld.bin" + yes + $(ProjectPath)../../../../tools/bflb_flash_tool/bflb_mcu_tool.exe --chipname=bl702 --interface=openocd --firmware="$(ProjectPath)/Obj/$(ProjectName).bin" @@ -661,7 +638,7 @@ Board: bl70x_iot yes - ICE + OpenOCD yes main @@ -700,18 +677,18 @@ Board: bl70x_iot no - openocd-bl702 + openocd-mingw32 no 4444 no 6666 - -f openocd_bl702_evb.cfg + -f ../../../../tools/openocd/if_702_hack.cfg -f ../../../../tools/openocd/tgt_702.cfg Erase Sectors - bl702_flasher.elf + bl70x_flasher.elf yes yes no @@ -723,4 +700,30 @@ Board: bl70x_iot + + + ;;; + ;;MHZ; + + glb + uart + + 1 + 1 + + 100:8;100:8;100:8;100:8; + + + + ;;; + ;;MHZ; + + glb + uart + + 1 + 1 + + 100:8;100:8;100:8;100:8; + diff --git a/examples/hellowd/helloworld/CMakeLists.txt b/examples/hellowd/helloworld/CMakeLists.txt index bb7ef18d..bfd0e557 100644 --- a/examples/hellowd/helloworld/CMakeLists.txt +++ b/examples/hellowd/helloworld/CMakeLists.txt @@ -1,5 +1,4 @@ set(mains main.c) -#set(TARGET_REQUIRED_SRCS apple.c) generate_bin() diff --git a/examples/hellowd/helloworld/bl702_flash2.ld b/examples/hellowd/helloworld/bl702_flash2.ld deleted file mode 100644 index 14ced469..00000000 --- a/examples/hellowd/helloworld/bl702_flash2.ld +++ /dev/null @@ -1,227 +0,0 @@ -/**************************************************************************************** -* @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 = 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( *bl602_glb.o \ - *bl602_pds.o \ - *bl602_common.o \ - *bl602_sf_cfg.o \ - *bl602_sf_ctrl.o \ - *bl602_sflash.o \ - *bl602_xip_sflash.o \ - *bl602_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) - - *bl602_glb.o*(.rodata*) - *bl602_pds.o*(.rodata*) - *bl602_common.o*(.rodata*) - *bl602_sf_cfg.o*(.rodata*) - *bl602_sf_ctrl.o*(.rodata*) - *bl602_sflash.o*(.rodata*) - *bl602_xip_sflash.o*(.rodata*) - *bl602_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); - -} - diff --git a/examples/hellowd/helloworld/cdk/helloworld.cdkproj b/examples/hellowd/helloworld/cdk/helloworld.cdkproj index da7c9d0c..bc0e8c37 100644 --- a/examples/hellowd/helloworld/cdk/helloworld.cdkproj +++ b/examples/hellowd/helloworld/cdk/helloworld.cdkproj @@ -32,9 +32,6 @@ Board: bl70x_iot - - - @@ -71,6 +68,12 @@ Board: bl70x_iot + + + + + + @@ -645,7 +648,7 @@ Board: bl70x_iot - $(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);$(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 gdwarf2 @@ -711,7 +714,7 @@ Board: bl70x_iot Erase Sectors - bl702_flasher.elf + bl70x_flasher.elf yes yes no diff --git a/examples/hellowd/helloworld/main.c b/examples/hellowd/helloworld/main.c index 68c550a9..8689e19c 100644 --- a/examples/hellowd/helloworld/main.c +++ b/examples/hellowd/helloworld/main.c @@ -20,14 +20,17 @@ * under the License. * */ + #include "hal_uart.h" + int main(void) { bflb_platform_init(0); - MSG("hello world!\r\n"); + while(1) { - + MSG("hello world!\r\n"); + bflb_platform_delay_ms(1000); } } diff --git a/examples/i2c/i2c_at24cxx/cdk/i2c_at24cxx.cdkproj b/examples/i2c/i2c_at24cxx/cdk/i2c_at24cxx.cdkproj index 3080e914..c0238980 100644 --- a/examples/i2c/i2c_at24cxx/cdk/i2c_at24cxx.cdkproj +++ b/examples/i2c/i2c_at24cxx/cdk/i2c_at24cxx.cdkproj @@ -32,9 +32,6 @@ Board: bl70x_iot - - - @@ -71,6 +68,10 @@ Board: bl70x_iot + + + + diff --git a/examples/i2c/i2c_at24cxx/main.c b/examples/i2c/i2c_at24cxx/main.c index 25544f2f..fa5424c9 100644 --- a/examples/i2c/i2c_at24cxx/main.c +++ b/examples/i2c/i2c_at24cxx/main.c @@ -56,6 +56,5 @@ int main(void) { MSG("\r\n i2c case\r\n"); bflb_platform_delay_ms(1000); - // DEBUG("GPIO_PIN_RESET\r\n"); } } \ No newline at end of file diff --git a/examples/i2c/i2c_bmp180/cdk/i2c_bmp180.cdkproj b/examples/i2c/i2c_bmp180/cdk/i2c_bmp180.cdkproj index af4f47f4..8053a7ac 100644 --- a/examples/i2c/i2c_bmp180/cdk/i2c_bmp180.cdkproj +++ b/examples/i2c/i2c_bmp180/cdk/i2c_bmp180.cdkproj @@ -32,9 +32,6 @@ Board: bl70x_iot - - - @@ -71,6 +68,10 @@ Board: bl70x_iot + + + + diff --git a/examples/i2c/i2c_bmp180/main.c b/examples/i2c/i2c_bmp180/main.c index 98ed6571..97d50999 100644 --- a/examples/i2c/i2c_bmp180/main.c +++ b/examples/i2c/i2c_bmp180/main.c @@ -49,6 +49,5 @@ int main(void) { MSG("\r\n i2c case\r\n"); bflb_platform_delay_ms(1000); - // DEBUG("GPIO_PIN_RESET\r\n"); } } \ No newline at end of file diff --git a/examples/i2s/i2s_play_form_flash/cdk/i2s_play_form_flash.cdkproj b/examples/i2s/i2s_play_form_flash/cdk/i2s_play_form_flash.cdkproj index ede0f239..0f36bd24 100644 --- a/examples/i2s/i2s_play_form_flash/cdk/i2s_play_form_flash.cdkproj +++ b/examples/i2s/i2s_play_form_flash/cdk/i2s_play_form_flash.cdkproj @@ -32,9 +32,6 @@ Board: bl70x_iot - - - @@ -71,6 +68,10 @@ Board: bl70x_iot + + + + diff --git a/examples/i2s/i2s_play_form_flash/main.c b/examples/i2s/i2s_play_form_flash/main.c index 2f3f1fb8..caaa2c02 100644 --- a/examples/i2s/i2s_play_form_flash/main.c +++ b/examples/i2s/i2s_play_form_flash/main.c @@ -20,19 +20,24 @@ * License for the specific language governing permissions and limitations * under the License. * + * Note: + * + * This Case is currently based on BL706_AVB development board with ili9341 controller screen. + * If you use other hardware platforms, please modify the pin Settings by yourself. + * + * This routine audio playback requires transcoding the audio into PCM encoding and exporting it as an audio array. + * See fhm_onechannel_16k_20.h for audio array examples , and i2s/script for transcoding scripts. + * + * Your should Short connect func1 and func2 jump cap on 706_AVB Board,and Plug the Audio Codec Board(ES8388) whit speaker into the HD11 interface. + * Audio default configuration is + * + * bitwith= 16 + * datarate = 16khz , + * channel number= 1 , + * + * if you want to play different wav format source , pleases modify this case . + * */ -/*************************************************************************** - * 此例程当前基于 bl706_avb 开发板开发,若使用其他硬件平台,请自行修改管脚设置 - * 此例程音频播放需要将音频转码为 pcm 编码,并导出为音频数组 - * 可参考 fhm_onechannel_16k_20.h 和 i2s/script 目录下转码脚本 - * - * 如使用 bl706_avb 开发板测试此例程: - * 1. 需要将开发板上的 func1 和 func2 分别用跳帽短接 - * 2. 同时还需将音频 Decode 子板插入 HD11 接口上(Decode 芯片型号为 ES8388) - * 3. 子板上需要连接相应的扬声器即可 - * 4. 如需播放自定义的音频,注意需要修改为正确的采样率,默认采样率为:16kHz “sampl_freq_hz = 16*1000” - * - * *************************************************************************/ #include "hal_i2s.h" #include "hal_gpio.h" #include "hal_dma.h" diff --git a/examples/i2s/i2s_play_form_sd/CMakeLists.txt b/examples/i2s/i2s_play_form_sd/CMakeLists.txt index 16f87448..93352b16 100644 --- a/examples/i2s/i2s_play_form_sd/CMakeLists.txt +++ b/examples/i2s/i2s_play_form_sd/CMakeLists.txt @@ -1,7 +1,7 @@ set(BSP_COMMON_DIR ${CMAKE_SOURCE_DIR}/bsp/bsp_common) set(TARGET_REQUIRED_LIBS fatfs) -set(TARGET_REQUIRED_PRIVATE_INCLUDE ${BSP_COMMON_DIR}/es8388 ${BSP_COMMON_DIR}/spi_sd) -set(TARGET_REQUIRED_SRCS ${BSP_COMMON_DIR}/es8388/bsp_es8388.c ${BSP_COMMON_DIR}/fatfs/fatfs_spi_sd.c ${BSP_COMMON_DIR}/spi_sd/bsp_spi_sd.c ./wav_play_form_sd_card.c) +set(TARGET_REQUIRED_PRIVATE_INCLUDE ${BSP_COMMON_DIR}/es8388 ${BSP_COMMON_DIR}/spi_sd ) +set(TARGET_REQUIRED_SRCS ${BSP_COMMON_DIR}/es8388/bsp_es8388.c ${BSP_COMMON_DIR}/fatfs/fatfs_spi_sd.c ${BSP_COMMON_DIR}/spi_sd/bsp_spi_sd.c ./wav_play_form_sd_card.c ./shell.c) set(mains main.c) generate_bin() diff --git a/examples/i2s/i2s_play_form_sd/main.c b/examples/i2s/i2s_play_form_sd/main.c index 0bdca61a..6ed2958a 100644 --- a/examples/i2s/i2s_play_form_sd/main.c +++ b/examples/i2s/i2s_play_form_sd/main.c @@ -19,19 +19,20 @@ * License for the specific language governing permissions and limitations * under the License. * + * Note: + * + * This Case is currently based on BL706_AVB development board with ili9341 controller screen. + * If you use other hardware platforms, please modify the pin Settings by yourself. + * + * This routine audio playback requires transcoding the audio into PCM encoding and exporting it as an audio array. + * See fhm_onechannel_16k_20.h for audio array examples , and i2s/script for transcoding scripts. + * + * Your should Short connect func1 and func2 jump cap on 706_AVB Board,and Plug the Audio Codec Board(ES8388) whit speaker into the HD11 interface , and connect SD Card with SPI ports. + * + * You need to fill in the correct audio file path which in SD Card file systems in audio_init(), please refer to line 58 of this code, this version only support Engilsh path. + * + * This case use shell module to complete human-computer interaction. */ -/*************************************************************************** - * 此例程当前基于 bl706_avb 开发板开发,若使用其他硬件平台,请自行修改管脚设置 - * 当前例程音频播放仅适配了 WAV 格式 - * - * 如使用 bl706_avb 开发板测试此例程: - * 1. 需要将开发板上的 func1 和 func2 分别用跳帽短接 - * 2. 需要将 SD 卡通过杜邦线连接到 HD13 接口中的 SPI 管脚,详情参考 bl706_avb pinout 图 - * 2. 同时还需将音频 Decode 子板插入 HD11 接口上(Decode 芯片型号为 ES8388) - * 3. 子板上需要连接相应的扬声器即可 - * 4. 需要将正确的文件路径填入 audio_init() 中,请参考本文件第 54 行,当前仅支持英文路径 - * - * *************************************************************************/ #include "ff.h" #include "wav_play_form_sd_card.h" @@ -49,10 +50,13 @@ int main(void) fatfs_sd_driver_register(); sd_wav_play_register(&Audio_Dev); - res = f_mount(&Fs_1,"1:",1); + res = f_mount(&Fs_1,"sd:",1); + f_chdrive("sd:"); + f_chdir("./wav_test"); + if(res==FR_OK) { - if(Audio_Dev.audio_init(&Audio_Dev,"1:wav_test/test9_44100_stereo_s32(24bit).wav") == 0) + if(Audio_Dev.audio_init(&Audio_Dev,"sd:/wav_test/test9_44100_stereo_s32(24bit).wav") == 0) { MSG("Audio Init success\r\n"); }else{ @@ -66,13 +70,16 @@ int main(void) /* start/stop test */ Audio_Dev.audio_control(&Audio_Dev,AUDIO_CMD_START,NULL); + /* bflb_platform_delay_ms(10000); Audio_Dev.audio_control(&Audio_Dev,AUDIO_CMD_STOP,NULL); bflb_platform_delay_ms(5000); Audio_Dev.audio_control(&Audio_Dev,AUDIO_CMD_START,NULL); bflb_platform_delay_ms(5000); + */ /* volume test */ + /* for(uint32_t vol=0; vol<80; vol++) { Audio_Dev.audio_control(&Audio_Dev,AUDIO_CMD_VOLUME,(void *)vol); @@ -83,6 +90,7 @@ int main(void) Audio_Dev.audio_control(&Audio_Dev,AUDIO_CMD_VOLUME,(void *)vol); bflb_platform_delay_ms(100); } + */ Audio_Dev.audio_control(&Audio_Dev,AUDIO_CMD_VOLUME,(void *)30); diff --git a/examples/i2s/i2s_play_form_sd/wav_play_form_sd_card.c b/examples/i2s/i2s_play_form_sd/wav_play_form_sd_card.c index a1df5f62..8352a41f 100644 --- a/examples/i2s/i2s_play_form_sd/wav_play_form_sd_card.c +++ b/examples/i2s/i2s_play_form_sd/wav_play_form_sd_card.c @@ -1,3 +1,26 @@ +/** + * @file wav_play_form_sd_card.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 "bsp_es8388.h" #include "hal_i2s.h" #include "hal_dma.h" @@ -108,6 +131,7 @@ static int sd_wav_play_init(audio_dev_t *audio_dev, const TCHAR* path) audio_dev->buff_using = 1; audio_dev->device = (struct device*)NULL; + audio_dev->audio_state = 0; f_close(&Wav_Fp); res = f_open(&Wav_Fp, path, FA_READ); @@ -119,6 +143,7 @@ static int sd_wav_play_init(audio_dev_t *audio_dev, const TCHAR* path) MSG("wav file open error\r\n"); return 1; } + /* Parse the WAV file */ res = wav_data_parser(buff, &Wav_Information); if (res == 0) { @@ -136,11 +161,27 @@ static int sd_wav_play_init(audio_dev_t *audio_dev, const TCHAR* path) return 1; } - i2s_register(I2S0_INDEX,"I2S",DEVICE_OFLAG_RDWR); audio_dev->device = device_find("I2S"); + if(audio_dev->device) + { + device_close(audio_dev->device); + } + else + { + i2s_register(I2S0_INDEX,"I2S",DEVICE_OFLAG_RDWR); + audio_dev->device = device_find("I2S"); + } - dma_register(DMA0_CH2_INDEX, "i2s_ch2", DEVICE_OFLAG_RDWR); struct device *dma_ch2 = device_find("i2s_ch2"); + if(dma_ch2) + { + device_close(dma_ch2); + } + else + { + dma_register(DMA0_CH2_INDEX, "i2s_ch2", DEVICE_OFLAG_RDWR); + dma_ch2 = device_find("i2s_ch2"); + } if((audio_dev->device) && dma_ch2) { @@ -223,6 +264,7 @@ static int sd_wav_play_init(audio_dev_t *audio_dev, const TCHAR* path) f_read(&Wav_Fp,audio_dev->buff[1], audio_dev->buff_size_max, &num); audio_dev->buff_data_size[1] = num; } + audio_dev->audio_state = 1; } else{ return 1; @@ -236,15 +278,26 @@ static int sd_wav_play_control(struct audio_dev *audio_dev, AUDIO_CMD_t cmd, voi switch (cmd) { case AUDIO_CMD_START: - res = device_write(audio_dev->device,0,audio_dev->buff[!audio_dev->buff_using],audio_dev->buff_data_size[!audio_dev->buff_using]); - audio_dev->audio_state = 1; + if(audio_dev->audio_state) + { + res = device_write(audio_dev->device,0,audio_dev->buff[!audio_dev->buff_using],audio_dev->buff_data_size[!audio_dev->buff_using]); + audio_dev->audio_state = 2; + res = 0; + } break; case AUDIO_CMD_STOP: - audio_dev->audio_state = 0; - res=0; + if(audio_dev->audio_state) + { + audio_dev->audio_state = 1; + res=0; + } break; - case AUDIO_CMD_VOLUME: - res = ES8388_Set_Voice_Volume((uint32_t)args); + case AUDIO_CMD_VOLUME: + if(audio_dev->audio_state) + { + res = ES8388_Set_Voice_Volume((uint32_t)args); + res=0; + } break; default: break; @@ -258,12 +311,13 @@ static int sd_wav_play_callback(audio_dev_t *audio_dev) uint8_t buff_using = audio_dev->buff_using; if(audio_dev->buff_data_size[!buff_using] ) { - if(audio_dev->audio_state) + /* start i2s-dma */ + if(audio_dev->audio_state == 2 && audio_dev->buff[!buff_using]) { device_write(audio_dev->device, 0, audio_dev->buff[!buff_using], audio_dev->buff_data_size[!buff_using]); audio_dev->buff_using = !buff_using; } - + /* fill data */ if (audio_dev->wav_information->chunk_format.bits_per_sample / 8 == 3) { f_read(&Wav_Fp, audio_dev->buff[buff_using], audio_dev->buff_size_max / 4 * 3, &num); @@ -275,9 +329,25 @@ static int sd_wav_play_callback(audio_dev_t *audio_dev) } audio_dev->buff_data_size[buff_using] = num; } - - if(num==0 && audio_dev->buff_data_size[0]==0 && audio_dev->buff_data_size[1]==0) + /* play end, refill the buff for next time*/ + if(num==0 && audio_dev->buff_data_size[!buff_using]==0 ) { + f_lseek(&Wav_Fp, audio_dev->wav_information->chunk_data_offset+sizeof(chunk_data_t)); + if(audio_dev->wav_information->chunk_format.bits_per_sample/8 == 3) + { + f_read(&Wav_Fp,audio_dev->buff[0], audio_dev->buff_size_max/4*3, &num); + audio_dev->buff_data_size[0] = pcm_24bit_to_32bit(audio_dev->buff[0],num); + f_read(&Wav_Fp,audio_dev->buff[1], audio_dev->buff_size_max/4*3, &num); + audio_dev->buff_data_size[1] = pcm_24bit_to_32bit(audio_dev->buff[1],num); + } + else + { + f_read(&Wav_Fp,audio_dev->buff[0], audio_dev->buff_size_max, &num); + audio_dev->buff_data_size[0] = num; + f_read(&Wav_Fp,audio_dev->buff[1], audio_dev->buff_size_max, &num); + audio_dev->buff_data_size[1] = num; + } + audio_dev->audio_state = 1; MSG("End of the play\r\n"); } return 0; @@ -294,6 +364,7 @@ int sd_wav_play_register(audio_dev_t *audio_dev) audio_dev->buff[1] = Data_Buff1; audio_dev->buff_data_size[0] = 0; audio_dev->buff_data_size[1] = 0; + audio_dev->audio_state = 0; audio_dev->buff_size_max = sizeof(Data_Buff1); return 0; } diff --git a/examples/i2s/i2s_play_form_sd/wav_play_form_sd_card.h b/examples/i2s/i2s_play_form_sd/wav_play_form_sd_card.h index 4ab7841c..cf29385a 100644 --- a/examples/i2s/i2s_play_form_sd/wav_play_form_sd_card.h +++ b/examples/i2s/i2s_play_form_sd/wav_play_form_sd_card.h @@ -1,3 +1,26 @@ +/** + * @file wav_play_form_sd_card.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 __MAV_PLAY_H__ #define __MAV_PLAY_H__ diff --git a/examples/lvgl/CMakeLists.txt b/examples/lvgl/CMakeLists.txt index 9a342c04..36b9c0cf 100644 --- a/examples/lvgl/CMakeLists.txt +++ b/examples/lvgl/CMakeLists.txt @@ -1,9 +1,10 @@ set(BSP_COMMON_DIR ${CMAKE_SOURCE_DIR}/bsp/bsp_common) set(TARGET_REQUIRED_LIBS fatfs lvgl) set(LINKER_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/lvgl_flash.ld) -set(TARGET_REQUIRED_PRIVATE_INCLUDE ${BSP_COMMON_DIR}/il9341 ${BSP_COMMON_DIR}/lvgl) +set(TARGET_REQUIRED_PRIVATE_INCLUDE ${BSP_COMMON_DIR}/il9341 ${BSP_COMMON_DIR}/lvgl ${BSP_COMMON_DIR}/touch ${BSP_COMMON_DIR}/spi_sd) file(GLOB_RECURSE sources "${CMAKE_CURRENT_SOURCE_DIR}/demo/*.c") -set(TARGET_REQUIRED_SRCS ${sources} ${BSP_COMMON_DIR}/il9341/bsp_il9341.c ${BSP_COMMON_DIR}/lvgl/lv_port_disp.c) +set(TARGET_REQUIRED_SRCS ${sources} ${BSP_COMMON_DIR}/il9341/bsp_il9341.c ${BSP_COMMON_DIR}/lvgl/lv_port_disp.c ${BSP_COMMON_DIR}/lvgl/lv_port_indev.c ${BSP_COMMON_DIR}/lvgl/lv_port_fs.c +${BSP_COMMON_DIR}/touch/xpt2046.c ${BSP_COMMON_DIR}/touch/touch.c ${BSP_COMMON_DIR}/fatfs/fatfs_spi_sd.c ${BSP_COMMON_DIR}/spi_sd/bsp_spi_sd.c) set(mains main.c) generate_bin() diff --git a/examples/lvgl/demo/lv_demo_printer/lv_demo_printer.c b/examples/lvgl/demo/lv_demo_printer/lv_demo_printer.c index 8cab7597..56a9c78e 100644 --- a/examples/lvgl/demo/lv_demo_printer/lv_demo_printer.c +++ b/examples/lvgl/demo/lv_demo_printer/lv_demo_printer.c @@ -110,8 +110,8 @@ void lv_demo_printer(void) bg_color_act = LV_DEMO_PRINTER_BLUE; lv_theme_t * th = lv_demo_printer_theme_init(LV_COLOR_BLACK, LV_COLOR_BLACK, - 0, &lv_font_montserrat_8, &lv_font_montserrat_8, - &lv_font_montserrat_8, &lv_font_montserrat_8); + 0, &lv_font_montserrat_12, &lv_font_montserrat_12, + &lv_font_montserrat_12, &lv_font_montserrat_12); lv_theme_set_act(th); lv_obj_t * scr = lv_obj_create(NULL, NULL); diff --git a/examples/lvgl/main.c b/examples/lvgl/main.c index 61386ca6..5607ac5b 100644 --- a/examples/lvgl/main.c +++ b/examples/lvgl/main.c @@ -19,32 +19,41 @@ * License for the specific language governing permissions and limitations * under the License. * + * Note: + * + * This Case is currently based on BL706_AVB development board with ili9341 controller screen. + * If you use other hardware platforms, please modify the pin Settings by yourself + * + * Your should Short connect func1 and func2 jump cap on 706_AVB Board,and Plug the screen into the HD13 interface + * Then the hardware for lvgl case testing is available. + * + * */ -/*************************************************************************** - * 此例程当前基于 bl706_avb 开发板开发,若使用其他硬件平台,请自行修改管脚设置 - * 当前例程仅适配 ili9341 屏幕 - * - * 如使用 bl706_avb 开发板测试此例程: - * 1. 需要将开发板上的 func1 和 func2 分别用跳帽短接 - * 2. 需要将 SPI 屏插入 HD13 接口即可 - * - * *************************************************************************/ -// #include "drv_shell.h" + #include "hal_spi.h" #include "hal_gpio.h" #include "hal_dma.h" -#include "lv_port_disp.h" + #include "bsp_il9341.h" +#include "xpt2046.h" +#include "lv_port_disp.h" +#include "lv_port_indev.h" #include "lvgl.h" #include "lv_examples.h" - /* lvgl log cb */ void lv_log_print_g_cb(lv_log_level_t level, const char *path, uint32_t line, const char *name, const char *str) { - MSG("L:%d,",level); - MSG("N:%s,",name); - MSG("D:%s\r\n,",str); + switch (level) + { + case LV_LOG_LEVEL_ERROR: MSG("ERROR: "); break; + case LV_LOG_LEVEL_WARN: MSG("WARNING: "); break; + case LV_LOG_LEVEL_INFO: MSG("INFO: "); break; + case LV_LOG_LEVEL_TRACE: MSG("TRACE: "); break; + default: break; + } + MSG("%s- ",name); + MSG(" %s\r\n,",str); } int main(void) @@ -52,9 +61,10 @@ int main(void) bflb_platform_init(0); lv_log_register_print_cb(lv_log_print_g_cb); - + lv_init(); lv_port_disp_init(); + lv_port_indev_init(); lv_demo_benchmark(); diff --git a/examples/memheap/cdk/memheap.cdkproj b/examples/memheap/cdk/memheap.cdkproj index 36ed8bac..a0a654d9 100644 --- a/examples/memheap/cdk/memheap.cdkproj +++ b/examples/memheap/cdk/memheap.cdkproj @@ -32,9 +32,6 @@ Board: bl70x_iot - - - diff --git a/examples/pwm/pwm_breath_led/cdk/pwm_breath_led.cdkproj b/examples/pwm/pwm_breath_led/cdk/pwm_breath_led.cdkproj index 36c67ba5..26d232e2 100644 --- a/examples/pwm/pwm_breath_led/cdk/pwm_breath_led.cdkproj +++ b/examples/pwm/pwm_breath_led/cdk/pwm_breath_led.cdkproj @@ -32,9 +32,6 @@ Board: bl70x_iot - - - @@ -71,6 +68,12 @@ Board: bl70x_iot + + + + + + @@ -450,10 +453,12 @@ Board: bl70x_iot - + + + - 154 + 155 104 @@ -683,7 +688,7 @@ Board: bl70x_iot Erase Sectors - bl702_flasher.elf + bl70x_flasher.elf yes yes no diff --git a/examples/pwm/pwm_breath_led/main.c b/examples/pwm/pwm_breath_led/main.c index 82d9b2a6..2c0063e9 100644 --- a/examples/pwm/pwm_breath_led/main.c +++ b/examples/pwm/pwm_breath_led/main.c @@ -46,17 +46,18 @@ int main(void) if (led_breath) { - device_open(led_breath, 0); + device_open(led_breath, DEVICE_OFLAG_STREAM_TX); + pwm_channel_start(led_breath); } while (1) { - for (pwm_cfg.dutyCycle = 0; pwm_cfg.dutyCycle < 100; pwm_cfg.dutyCycle++) + for (pwm_cfg.dutycycle = 0; pwm_cfg.dutycycle < 100; pwm_cfg.dutycycle++) { device_control(led_breath, DEVICE_CTRL_CONFIG, &pwm_cfg); bflb_platform_delay_ms(10); } - for (pwm_cfg.dutyCycle = 100; pwm_cfg.dutyCycle > 0; pwm_cfg.dutyCycle--) + for (pwm_cfg.dutycycle = 100; pwm_cfg.dutycycle > 0; pwm_cfg.dutycycle--) { device_control(led_breath, DEVICE_CTRL_CONFIG, &pwm_cfg); bflb_platform_delay_ms(10); diff --git a/examples/spi/spi_dma_sd/cdk/spi_dma_sd.cdkproj b/examples/spi/spi_dma_sd/cdk/spi_dma_sd.cdkproj index 1d155cdf..a62e7d3b 100644 --- a/examples/spi/spi_dma_sd/cdk/spi_dma_sd.cdkproj +++ b/examples/spi/spi_dma_sd/cdk/spi_dma_sd.cdkproj @@ -32,9 +32,6 @@ Board: bl70x_iot - - - @@ -71,6 +68,10 @@ Board: bl70x_iot + + + + diff --git a/examples/spi/spi_lcd/cdk/spi_lcd.cdkproj b/examples/spi/spi_lcd/cdk/spi_lcd.cdkproj index 4e1a7c0c..4e7a4477 100644 --- a/examples/spi/spi_lcd/cdk/spi_lcd.cdkproj +++ b/examples/spi/spi_lcd/cdk/spi_lcd.cdkproj @@ -32,9 +32,6 @@ Board: bl70x_iot - - - @@ -71,6 +68,10 @@ Board: bl70x_iot + + + + @@ -195,7 +196,9 @@ Board: bl70x_iot - + + + @@ -630,7 +633,7 @@ Board: bl70x_iot Optimize more (-O2) Default (-g) - $(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)../../../../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);$(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)../../../../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 -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 no no @@ -646,7 +649,7 @@ Board: bl70x_iot - $(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)../../../../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);$(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)../../../../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 gdwarf2 diff --git a/examples/spi/spi_loopback/cdk/spi_loopback.cdkproj b/examples/spi/spi_loopback/cdk/spi_loopback.cdkproj index 690a2ea7..dafc1a43 100644 --- a/examples/spi/spi_loopback/cdk/spi_loopback.cdkproj +++ b/examples/spi/spi_loopback/cdk/spi_loopback.cdkproj @@ -32,9 +32,6 @@ Board: bl70x_iot - - - @@ -71,6 +68,10 @@ Board: bl70x_iot + + + + diff --git a/examples/uart/uart_dma/cdk/uart_dma.cdkproj b/examples/uart/uart_dma/cdk/uart_dma.cdkproj index 8ed5ba02..47ac682f 100644 --- a/examples/uart/uart_dma/cdk/uart_dma.cdkproj +++ b/examples/uart/uart_dma/cdk/uart_dma.cdkproj @@ -32,9 +32,6 @@ Board: bl70x_iot - - - @@ -71,6 +68,10 @@ Board: bl70x_iot + + + + diff --git a/examples/uart/uart_dma/main.c b/examples/uart/uart_dma/main.c index 3f09fa99..f2200aff 100644 --- a/examples/uart/uart_dma/main.c +++ b/examples/uart/uart_dma/main.c @@ -24,13 +24,8 @@ #include "hal_uart.h" #include "hal_dma.h" -struct device *dma_ch2; - -uint8_t src_buffer[4100] __attribute__((section(".system_ram"))); -uint8_t mmheap_default_pool[2048] __attribute__((section(".system_ram"))); - -uint8_t dma_tc_flag0 = 0; -uint8_t dma_tc_flag1 = 0; +static uint8_t src_buffer[4100] __attribute__((section(".system_ram"))); +static uint8_t dma_tc_flag0 = 0; void dma_ch2_irq_callback(struct device *dev, void *args, uint32_t size, uint32_t state) { @@ -64,7 +59,7 @@ int main(void) } dma_register(DMA0_CH2_INDEX, "ch2", DEVICE_OFLAG_RDWR); - dma_ch2 = device_find("ch2"); + struct device* dma_ch2 = device_find("ch2"); if (dma_ch2) { device_open(dma_ch2, 0); diff --git a/examples/uart/uart_echo/cdk/uart_echo.cdkproj b/examples/uart/uart_echo/cdk/uart_echo.cdkproj index d9333204..89e22c50 100644 --- a/examples/uart/uart_echo/cdk/uart_echo.cdkproj +++ b/examples/uart/uart_echo/cdk/uart_echo.cdkproj @@ -32,9 +32,6 @@ Board: bl70x_iot - - - @@ -71,6 +68,10 @@ Board: bl70x_iot + + + + diff --git a/examples/uart/uart_poll/cdk/uart_poll.cdkproj b/examples/uart/uart_poll/cdk/uart_poll.cdkproj index d7cc5a35..167dd61d 100644 --- a/examples/uart/uart_poll/cdk/uart_poll.cdkproj +++ b/examples/uart/uart_poll/cdk/uart_poll.cdkproj @@ -32,9 +32,6 @@ Board: bl70x_iot - - - @@ -71,6 +68,10 @@ Board: bl70x_iot + + + + diff --git a/examples/uart/uart_poll/main.c b/examples/uart/uart_poll/main.c index e5fbdbc8..6eb9685f 100644 --- a/examples/uart/uart_poll/main.c +++ b/examples/uart/uart_poll/main.c @@ -30,7 +30,7 @@ int main(void) if (uart1) { - device_open(uart1, DEVICE_OFLAG_STREAM_TX); //uart0 tx dma mode + device_open(uart1, DEVICE_OFLAG_STREAM_TX); MSG("device find success\r\n"); } device_write(uart1,0,buffer,10); diff --git a/examples/uart/uart_rx_it/cdk/uart_rx_it.cdkproj b/examples/uart/uart_rx_it/cdk/uart_rx_it.cdkproj index 522df99c..c5e6326a 100644 --- a/examples/uart/uart_rx_it/cdk/uart_rx_it.cdkproj +++ b/examples/uart/uart_rx_it/cdk/uart_rx_it.cdkproj @@ -32,9 +32,6 @@ Board: bl70x_iot - - - @@ -71,6 +68,10 @@ Board: bl70x_iot + + + + diff --git a/examples/uart/uart_rx_it/main.c b/examples/uart/uart_rx_it/main.c index 2c503f3d..72668b1e 100644 --- a/examples/uart/uart_rx_it/main.c +++ b/examples/uart/uart_rx_it/main.c @@ -54,19 +54,19 @@ int main(void) bflb_platform_init(0); uart_register(UART1_INDEX, "uart1", DEVICE_OFLAG_RDWR); - struct device *uart = device_find("uart1"); + struct device *uart1 = device_find("uart1"); - if (uart) + if (uart1) { - device_open(uart, DEVICE_OFLAG_STREAM_TX | DEVICE_OFLAG_INT_RX); //uart0 tx dma mode - device_set_callback(uart, uart_irq_callback); - device_control(uart, DEVICE_CTRL_SET_INT, (void *)(UART_RX_FIFO_IT|UART_RTO_IT)); + device_open(uart1, DEVICE_OFLAG_STREAM_TX | DEVICE_OFLAG_INT_RX); + device_set_callback(uart1, uart_irq_callback); + device_control(uart1, DEVICE_CTRL_SET_INT, (void *)(UART_RX_FIFO_IT|UART_RTO_IT)); } while (1) { - device_write(uart,0,string,strlen(string)); + device_write(uart1,0,string,strlen(string)); bflb_platform_delay_ms(1000); } } \ No newline at end of file diff --git a/examples/usb/usb2uart/main.c b/examples/usb/usb2uart/main.c index 1bec02f4..9c6da20f 100644 --- a/examples/usb/usb2uart/main.c +++ b/examples/usb/usb2uart/main.c @@ -25,6 +25,8 @@ #include "usbd_cdc.h" #include "uart_interface.h" #include "bl702_ef_ctrl.h" +#include "bl702_glb.h" +#include "hal_gpio.h" #define CDC_IN_EP 0x82 #define CDC_OUT_EP 0x01 @@ -154,19 +156,19 @@ uint32_t usbd_cdc_filter_callback(uint8_t* data, uint32_t len) uart1_rts_init(); if(data[pattern_len]=='0'||data[pattern_len]==0){ - usbd_cdc_acm_set_dtr(0); + dtr_pin_set(1); MSG("DTR0\r\n"); } if(data[pattern_len]=='1'||data[pattern_len]==1){ - usbd_cdc_acm_set_dtr(1); + dtr_pin_set(0); MSG("DTR1\r\n"); } if(data[pattern_len+1]=='0'||data[pattern_len+1]==0){ - usbd_cdc_acm_set_rts(0); + rts_pin_set(1); MSG("RTS0\r\n"); } if(data[pattern_len+1]=='1'||data[pattern_len+1]==1){ - usbd_cdc_acm_set_rts(1); + rts_pin_set(0); MSG("RTS1\r\n"); } //delay=atoi(( char *)&data[pattern_len+1]); @@ -175,11 +177,11 @@ uint32_t usbd_cdc_filter_callback(uint8_t* data, uint32_t len) } bflb_platform_delay_ms(delay); if(data[pattern_len+1]=='0'||data[pattern_len+1]==0){ - usbd_cdc_acm_set_rts(1); + rts_pin_set(0); MSG("RTS1\r\n"); } if(data[pattern_len+1]=='1'||data[pattern_len+1]==1){ - usbd_cdc_acm_set_rts(0); + rts_pin_set(1); MSG("RTS0\r\n"); } bflb_platform_delay_ms(delay); @@ -220,12 +222,12 @@ void usbd_cdc_acm_set_line_coding(uint32_t baudrate, uint8_t databits, uint8_t p void usbd_cdc_acm_set_dtr(bool dtr) { - dtr_pin_set(!dtr); + //dtr_pin_set(!dtr); } void usbd_cdc_acm_set_rts(bool rts) { - rts_pin_set(!rts); + //rts_pin_set(!rts); } usbd_class_t cdc_class; @@ -246,14 +248,27 @@ usbd_endpoint_t cdc_in_ep = extern struct device* usb_dc_init(void); +// #define BL702 + +#ifdef BL702 +#define UART_DTR_PIN GPIO_PIN_37 +#define UART_RTS_PIN GPIO_PIN_33 +#else +#define UART_DTR_PIN GPIO_PIN_22 +#define UART_RTS_PIN GPIO_PIN_21 +#endif + int main(void) { uint8_t chipid[8]; uint8_t chipid2[6]; - +#ifdef BL702 + GLB_Select_Internal_Flash(); +#endif bflb_platform_init(0); uart_ringbuffer_init(); uart1_init(); + uart1_set_dtr_rts(UART_DTR_PIN,UART_RTS_PIN); uart1_dtr_deinit(); uart1_rts_deinit(); @@ -281,6 +296,7 @@ int main(void) device_control(usb_fs, DEVICE_CTRL_SET_INT, (void *)(USB_EP1_DATA_OUT_IT | USB_EP2_DATA_IN_IT)); } while(!usb_device_is_configured()); + while (1) { uart_send_from_ringbuffer(); diff --git a/examples/usb/usb_cdc_loopback/cdk/usb_cdc_loopback.cdkproj b/examples/usb/usb_cdc_loopback/cdk/usb_cdc_loopback.cdkproj index e83cdec5..74875afa 100644 --- a/examples/usb/usb_cdc_loopback/cdk/usb_cdc_loopback.cdkproj +++ b/examples/usb/usb_cdc_loopback/cdk/usb_cdc_loopback.cdkproj @@ -32,9 +32,6 @@ Board: bl70x_iot - - - @@ -71,6 +68,10 @@ Board: bl70x_iot + + + + diff --git a/examples/usb/usb_cdc_msc/CMakeLists.txt b/examples/usb/usb_cdc_msc/CMakeLists.txt index 2c7cc5fd..0c2da92b 100644 --- a/examples/usb/usb_cdc_msc/CMakeLists.txt +++ b/examples/usb/usb_cdc_msc/CMakeLists.txt @@ -1,5 +1,6 @@ set(BSP_COMMON_DIR ${CMAKE_SOURCE_DIR}/bsp/bsp_common) set(TARGET_REQUIRED_LIBS usb_stack) +set(LINKER_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/usb_cdc_msc.ld) set(TARGET_REQUIRED_PRIVATE_INCLUDE ${BSP_COMMON_DIR}/usb ${BSP_COMMON_DIR}/spi_sd) set(TARGET_REQUIRED_SRCS ${BSP_COMMON_DIR}/usb/usb_dc.c ${BSP_COMMON_DIR}/usb/uart_interface.c ${BSP_COMMON_DIR}/spi_sd/bsp_spi_sd.c) set(mains main.c) diff --git a/examples/usb/usb_cdc_msc/cdk/usb_cdc_msc.cdkproj b/examples/usb/usb_cdc_msc/cdk/usb_cdc_msc.cdkproj index 284ad284..1ad0c623 100644 --- a/examples/usb/usb_cdc_msc/cdk/usb_cdc_msc.cdkproj +++ b/examples/usb/usb_cdc_msc/cdk/usb_cdc_msc.cdkproj @@ -32,9 +32,6 @@ Board: bl70x_iot - - - @@ -71,6 +68,10 @@ Board: bl70x_iot + + + + diff --git a/examples/usb/usb_cdc_msc/main.c b/examples/usb/usb_cdc_msc/main.c index 03d87772..c88f1aa9 100644 --- a/examples/usb/usb_cdc_msc/main.c +++ b/examples/usb/usb_cdc_msc/main.c @@ -128,7 +128,7 @@ USB_DESC_SECTION const uint8_t cdc_msc_descriptor[] = }; #define BLOCK_SIZE 512 -#define BLOCK_COUNT 48 +#define BLOCK_COUNT 32 typedef struct { diff --git a/examples/usb/usb_msc_ram/CMakeLists.txt b/examples/usb/usb_msc_ram/CMakeLists.txt index 2c7cc5fd..17a56ffb 100644 --- a/examples/usb/usb_msc_ram/CMakeLists.txt +++ b/examples/usb/usb_msc_ram/CMakeLists.txt @@ -1,5 +1,6 @@ set(BSP_COMMON_DIR ${CMAKE_SOURCE_DIR}/bsp/bsp_common) set(TARGET_REQUIRED_LIBS usb_stack) +set(LINKER_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/usb_msc_ram.ld) set(TARGET_REQUIRED_PRIVATE_INCLUDE ${BSP_COMMON_DIR}/usb ${BSP_COMMON_DIR}/spi_sd) set(TARGET_REQUIRED_SRCS ${BSP_COMMON_DIR}/usb/usb_dc.c ${BSP_COMMON_DIR}/usb/uart_interface.c ${BSP_COMMON_DIR}/spi_sd/bsp_spi_sd.c) set(mains main.c) diff --git a/examples/usb/usb_msc_ram/cdk/usb_msc_ram.cdkproj b/examples/usb/usb_msc_ram/cdk/usb_msc_ram.cdkproj index 31e7204a..60f8e8fd 100644 --- a/examples/usb/usb_msc_ram/cdk/usb_msc_ram.cdkproj +++ b/examples/usb/usb_msc_ram/cdk/usb_msc_ram.cdkproj @@ -32,9 +32,6 @@ Board: bl70x_iot - - - @@ -71,6 +68,10 @@ Board: bl70x_iot + + + + diff --git a/examples/usb/usb_msc_sd/cdk/usb_msc_sd.cdkproj b/examples/usb/usb_msc_sd/cdk/usb_msc_sd.cdkproj index 169dd96d..bb8285b2 100644 --- a/examples/usb/usb_msc_sd/cdk/usb_msc_sd.cdkproj +++ b/examples/usb/usb_msc_sd/cdk/usb_msc_sd.cdkproj @@ -32,9 +32,6 @@ Board: bl70x_iot - - - @@ -71,6 +68,10 @@ Board: bl70x_iot + + + +