From bc4ba155eeacd50674baad20ab3d6c692cd43bfb Mon Sep 17 00:00:00 2001 From: SEEKFREE_Kang Date: Tue, 16 Nov 2021 12:32:52 +0800 Subject: [PATCH] =?UTF-8?q?V1.2.0=20=20=20=20=20=E5=A2=9E=E5=8A=A0CH9141?= =?UTF-8?q?=E8=93=9D=E7=89=99=E8=BD=AC=E4=B8=B2=E5=8F=A3=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E7=9A=84=E9=A9=B1=E5=8A=A8=20=20=20=20=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=97=A0=E7=BA=BF=E7=B1=BB=E5=9E=8B=E7=9A=84=E6=9E=9A=E4=B8=BE?= =?UTF-8?q?=E5=8F=98=E9=87=8F=20=20=20=20=20=E4=BF=AE=E6=94=B9=20=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E4=B8=B4=E6=97=B6=E6=96=87=E4=BB=B6.bat=20=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=E5=AE=8C=E6=93=8D=E4=BD=9C=E5=90=8E=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=85=B3=E9=97=AD=E7=AA=97=E5=8F=A3=20=20=20=20=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=20=E5=88=A0=E9=99=A4=E4=B8=B4=E6=97=B6=E6=96=87?= =?UTF-8?q?=E4=BB=B6.bat=20=E9=81=BF=E5=85=8D=E5=88=A0=E9=99=A4=E6=96=B0?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E6=89=80=E9=9C=80=E6=96=87=E4=BB=B6=20=20=20?= =?UTF-8?q?=20=20=E4=BF=AE=E6=94=B9=E5=B7=A5=E7=A8=8B=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E6=96=87=E4=BB=B6=EF=BC=8C=E4=BB=A5=E6=94=AF=E6=8C=81=E6=96=B0?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E7=BC=96=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Example/ADC_Demo/.cproject | 2046 +++++++++++++++- Example/ADC_Demo/.project | 12 + .../com.infineon.aurix.buildsystem.prefs | 10 + Example/ADC_Demo/Libraries/doc/version.txt | 10 + .../seekfree_libraries/common/common.c | 2 + .../seekfree_libraries/common/common.h | 8 + .../Libraries/seekfree_libraries/headfile.h | 1 + .../SEEKFREE_BLUETOOTH_CH9141.c | 509 ++++ .../SEEKFREE_BLUETOOTH_CH9141.h | 99 + .../seekfree_peripheral/SEEKFREE_WIRELESS.c | 96 +- .../seekfree_peripheral/SEEKFREE_WIRELESS.h | 20 +- Example/ADC_Demo/USER/isr.c | 15 +- Example/ADC_Demo/删除临时文件.bat | 3 - .../Cpu1_Handles_Interrupts_Demo/.cproject | 2054 ++++++++++++++++- Example/Cpu1_Handles_Interrupts_Demo/.project | 12 + .../com.infineon.aurix.buildsystem.prefs | 10 + .../Libraries/doc/version.txt | 10 + .../seekfree_libraries/common/common.c | 2 + .../seekfree_libraries/common/common.h | 8 + .../Libraries/seekfree_libraries/headfile.h | 1 + .../SEEKFREE_BLUETOOTH_CH9141.c | 509 ++++ .../SEEKFREE_BLUETOOTH_CH9141.h | 99 + .../seekfree_peripheral/SEEKFREE_WIRELESS.c | 96 +- .../seekfree_peripheral/SEEKFREE_WIRELESS.h | 20 +- .../Cpu1_Handles_Interrupts_Demo/USER/isr.c | 15 +- .../删除临时文件.bat | 3 - Example/Dual_Core_Demo/.cproject | 2054 ++++++++++++++++- Example/Dual_Core_Demo/.project | 12 + .../com.infineon.aurix.buildsystem.prefs | 10 + .../Dual_Core_Demo/Libraries/doc/version.txt | 10 + .../seekfree_libraries/common/common.c | 2 + .../seekfree_libraries/common/common.h | 8 + .../Libraries/seekfree_libraries/headfile.h | 1 + .../SEEKFREE_BLUETOOTH_CH9141.c | 509 ++++ .../SEEKFREE_BLUETOOTH_CH9141.h | 99 + .../seekfree_peripheral/SEEKFREE_WIRELESS.c | 96 +- .../seekfree_peripheral/SEEKFREE_WIRELESS.h | 20 +- Example/Dual_Core_Demo/USER/isr.c | 15 +- Example/Dual_Core_Demo/删除临时文件.bat | 3 - Example/EEPROM_Demo/.cproject | 2048 +++++++++++++++- Example/EEPROM_Demo/.project | 12 + .../com.infineon.aurix.buildsystem.prefs | 10 + Example/EEPROM_Demo/Libraries/doc/version.txt | 10 + .../seekfree_libraries/common/common.c | 2 + .../seekfree_libraries/common/common.h | 8 + .../Libraries/seekfree_libraries/headfile.h | 1 + .../SEEKFREE_BLUETOOTH_CH9141.c | 509 ++++ .../SEEKFREE_BLUETOOTH_CH9141.h | 99 + .../seekfree_peripheral/SEEKFREE_WIRELESS.c | 96 +- .../seekfree_peripheral/SEEKFREE_WIRELESS.h | 20 +- Example/EEPROM_Demo/USER/isr.c | 15 +- Example/EEPROM_Demo/删除临时文件.bat | 3 - Example/Encoder_Demo/.cproject | 2054 ++++++++++++++++- Example/Encoder_Demo/.project | 12 + .../com.infineon.aurix.buildsystem.prefs | 10 + .../Encoder_Demo/Libraries/doc/version.txt | 10 + .../seekfree_libraries/common/common.c | 2 + .../seekfree_libraries/common/common.h | 8 + .../Libraries/seekfree_libraries/headfile.h | 1 + .../SEEKFREE_BLUETOOTH_CH9141.c | 509 ++++ .../SEEKFREE_BLUETOOTH_CH9141.h | 99 + .../seekfree_peripheral/SEEKFREE_WIRELESS.c | 96 +- .../seekfree_peripheral/SEEKFREE_WIRELESS.h | 20 +- Example/Encoder_Demo/USER/isr.c | 15 +- Example/Encoder_Demo/删除临时文件.bat | 3 - Example/FFT_Demo/.cproject | 2054 ++++++++++++++++- Example/FFT_Demo/.project | 12 + .../com.infineon.aurix.buildsystem.prefs | 10 + Example/FFT_Demo/Libraries/doc/version.txt | 10 + .../seekfree_libraries/common/common.c | 2 + .../seekfree_libraries/common/common.h | 8 + .../Libraries/seekfree_libraries/headfile.h | 1 + .../SEEKFREE_BLUETOOTH_CH9141.c | 509 ++++ .../SEEKFREE_BLUETOOTH_CH9141.h | 99 + .../seekfree_peripheral/SEEKFREE_WIRELESS.c | 96 +- .../seekfree_peripheral/SEEKFREE_WIRELESS.h | 20 +- Example/FFT_Demo/USER/isr.c | 15 +- Example/FFT_Demo/删除临时文件.bat | 3 - Example/GPIO_Interrupt_Demo/.cproject | 2054 ++++++++++++++++- Example/GPIO_Interrupt_Demo/.project | 12 + .../com.infineon.aurix.buildsystem.prefs | 10 + .../Libraries/doc/version.txt | 10 + .../seekfree_libraries/common/common.c | 2 + .../seekfree_libraries/common/common.h | 8 + .../Libraries/seekfree_libraries/headfile.h | 1 + .../SEEKFREE_BLUETOOTH_CH9141.c | 509 ++++ .../SEEKFREE_BLUETOOTH_CH9141.h | 99 + .../seekfree_peripheral/SEEKFREE_WIRELESS.c | 96 +- .../seekfree_peripheral/SEEKFREE_WIRELESS.h | 20 +- Example/GPIO_Interrupt_Demo/USER/isr.c | 15 +- Example/GPIO_Interrupt_Demo/删除临时文件.bat | 3 - Example/Interrupt_Priority_Set_Demo/.cproject | 2054 ++++++++++++++++- Example/Interrupt_Priority_Set_Demo/.project | 12 + .../com.infineon.aurix.buildsystem.prefs | 10 + .../Libraries/doc/version.txt | 10 + .../seekfree_libraries/common/common.c | 2 + .../seekfree_libraries/common/common.h | 8 + .../Libraries/seekfree_libraries/headfile.h | 1 + .../SEEKFREE_BLUETOOTH_CH9141.c | 509 ++++ .../SEEKFREE_BLUETOOTH_CH9141.h | 99 + .../seekfree_peripheral/SEEKFREE_WIRELESS.c | 96 +- .../seekfree_peripheral/SEEKFREE_WIRELESS.h | 20 +- .../Interrupt_Priority_Set_Demo/USER/isr.c | 15 +- .../删除临时文件.bat | 3 - Example/LED_Blink_Demo/.cproject | 2054 ++++++++++++++++- Example/LED_Blink_Demo/.project | 12 + .../com.infineon.aurix.buildsystem.prefs | 10 + .../LED_Blink_Demo/Libraries/doc/version.txt | 10 + .../seekfree_libraries/common/common.c | 2 + .../seekfree_libraries/common/common.h | 8 + .../Libraries/seekfree_libraries/headfile.h | 1 + .../SEEKFREE_BLUETOOTH_CH9141.c | 509 ++++ .../SEEKFREE_BLUETOOTH_CH9141.h | 99 + .../seekfree_peripheral/SEEKFREE_WIRELESS.c | 96 +- .../seekfree_peripheral/SEEKFREE_WIRELESS.h | 20 +- Example/LED_Blink_Demo/USER/isr.c | 15 +- Example/LED_Blink_Demo/删除临时文件.bat | 3 - Example/PIT_Demo/.cproject | 2054 ++++++++++++++++- Example/PIT_Demo/.project | 12 + .../com.infineon.aurix.buildsystem.prefs | 10 + Example/PIT_Demo/Libraries/doc/version.txt | 10 + .../seekfree_libraries/common/common.c | 2 + .../seekfree_libraries/common/common.h | 8 + .../Libraries/seekfree_libraries/headfile.h | 1 + .../SEEKFREE_BLUETOOTH_CH9141.c | 509 ++++ .../SEEKFREE_BLUETOOTH_CH9141.h | 99 + .../seekfree_peripheral/SEEKFREE_WIRELESS.c | 96 +- .../seekfree_peripheral/SEEKFREE_WIRELESS.h | 20 +- Example/PIT_Demo/USER/isr.c | 15 +- Example/PIT_Demo/删除临时文件.bat | 3 - Example/PWM_Demo/.cproject | 2054 ++++++++++++++++- Example/PWM_Demo/.project | 12 + .../com.infineon.aurix.buildsystem.prefs | 10 + Example/PWM_Demo/Libraries/doc/version.txt | 10 + .../seekfree_libraries/common/common.c | 2 + .../seekfree_libraries/common/common.h | 8 + .../Libraries/seekfree_libraries/headfile.h | 1 + .../SEEKFREE_BLUETOOTH_CH9141.c | 509 ++++ .../SEEKFREE_BLUETOOTH_CH9141.h | 99 + .../seekfree_peripheral/SEEKFREE_WIRELESS.c | 96 +- .../seekfree_peripheral/SEEKFREE_WIRELESS.h | 20 +- Example/PWM_Demo/USER/isr.c | 15 +- Example/PWM_Demo/删除临时文件.bat | 3 - Example/Printf_Demo/.cproject | 2054 ++++++++++++++++- Example/Printf_Demo/.project | 12 + .../com.infineon.aurix.buildsystem.prefs | 10 + Example/Printf_Demo/Libraries/doc/version.txt | 10 + .../seekfree_libraries/common/common.c | 2 + .../seekfree_libraries/common/common.h | 8 + .../Libraries/seekfree_libraries/headfile.h | 1 + .../SEEKFREE_BLUETOOTH_CH9141.c | 509 ++++ .../SEEKFREE_BLUETOOTH_CH9141.h | 99 + .../seekfree_peripheral/SEEKFREE_WIRELESS.c | 96 +- .../seekfree_peripheral/SEEKFREE_WIRELESS.h | 20 +- Example/Printf_Demo/USER/isr.c | 15 +- Example/Printf_Demo/删除临时文件.bat | 3 - .../.cproject | 2054 ++++++++++++++++- .../.project | 12 + .../com.infineon.aurix.buildsystem.prefs | 10 + .../Libraries/doc/version.txt | 10 + .../seekfree_libraries/common/common.c | 2 + .../seekfree_libraries/common/common.h | 8 + .../Libraries/seekfree_libraries/headfile.h | 1 + .../SEEKFREE_BLUETOOTH_CH9141.c | 509 ++++ .../SEEKFREE_BLUETOOTH_CH9141.h | 99 + .../seekfree_peripheral/SEEKFREE_WIRELESS.c | 96 +- .../seekfree_peripheral/SEEKFREE_WIRELESS.h | 20 +- .../USER/isr.c | 15 +- .../删除临时文件.bat | 3 - Example/Systick_Demo/.cproject | 2054 ++++++++++++++++- Example/Systick_Demo/.project | 12 + .../com.infineon.aurix.buildsystem.prefs | 10 + .../Systick_Demo/Libraries/doc/version.txt | 10 + .../seekfree_libraries/common/common.c | 2 + .../seekfree_libraries/common/common.h | 8 + .../Libraries/seekfree_libraries/headfile.h | 1 + .../SEEKFREE_BLUETOOTH_CH9141.c | 509 ++++ .../SEEKFREE_BLUETOOTH_CH9141.h | 99 + .../seekfree_peripheral/SEEKFREE_WIRELESS.c | 96 +- .../seekfree_peripheral/SEEKFREE_WIRELESS.h | 20 +- Example/Systick_Demo/USER/isr.c | 15 +- Example/Systick_Demo/删除临时文件.bat | 3 - Example/UART_Demo/.cproject | 2054 ++++++++++++++++- Example/UART_Demo/.project | 12 + .../com.infineon.aurix.buildsystem.prefs | 10 + Example/UART_Demo/Libraries/doc/version.txt | 10 + .../seekfree_libraries/common/common.c | 2 + .../seekfree_libraries/common/common.h | 8 + .../Libraries/seekfree_libraries/headfile.h | 1 + .../SEEKFREE_BLUETOOTH_CH9141.c | 509 ++++ .../SEEKFREE_BLUETOOTH_CH9141.h | 99 + .../seekfree_peripheral/SEEKFREE_WIRELESS.c | 96 +- .../seekfree_peripheral/SEEKFREE_WIRELESS.h | 20 +- Example/UART_Demo/USER/isr.c | 15 +- Example/UART_Demo/删除临时文件.bat | 3 - Seekfree_TC264_Opensource_Library/.cproject | 2048 +++++++++++++++- Seekfree_TC264_Opensource_Library/.project | 12 + .../com.infineon.aurix.buildsystem.prefs | 10 + .../Libraries/doc/version.txt | 7 + .../seekfree_libraries/common/common.c | 2 + .../seekfree_libraries/common/common.h | 8 + .../Libraries/seekfree_libraries/headfile.h | 1 + .../SEEKFREE_BLUETOOTH_CH9141.c | 509 ++++ .../SEEKFREE_BLUETOOTH_CH9141.h | 99 + .../seekfree_peripheral/SEEKFREE_WIRELESS.c | 96 +- .../seekfree_peripheral/SEEKFREE_WIRELESS.h | 20 +- Seekfree_TC264_Opensource_Library/USER/isr.c | 15 +- .../删除临时文件.bat | 3 - .../尽量不要使用的引脚.txt | 6 +- 209 files changed, 43716 insertions(+), 1691 deletions(-) create mode 100644 Example/ADC_Demo/.settings/com.infineon.aurix.buildsystem.prefs create mode 100644 Example/ADC_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.c create mode 100644 Example/ADC_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.h create mode 100644 Example/Cpu1_Handles_Interrupts_Demo/.settings/com.infineon.aurix.buildsystem.prefs create mode 100644 Example/Cpu1_Handles_Interrupts_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.c create mode 100644 Example/Cpu1_Handles_Interrupts_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.h create mode 100644 Example/Dual_Core_Demo/.settings/com.infineon.aurix.buildsystem.prefs create mode 100644 Example/Dual_Core_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.c create mode 100644 Example/Dual_Core_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.h create mode 100644 Example/EEPROM_Demo/.settings/com.infineon.aurix.buildsystem.prefs create mode 100644 Example/EEPROM_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.c create mode 100644 Example/EEPROM_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.h create mode 100644 Example/Encoder_Demo/.settings/com.infineon.aurix.buildsystem.prefs create mode 100644 Example/Encoder_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.c create mode 100644 Example/Encoder_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.h create mode 100644 Example/FFT_Demo/.settings/com.infineon.aurix.buildsystem.prefs create mode 100644 Example/FFT_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.c create mode 100644 Example/FFT_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.h create mode 100644 Example/GPIO_Interrupt_Demo/.settings/com.infineon.aurix.buildsystem.prefs create mode 100644 Example/GPIO_Interrupt_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.c create mode 100644 Example/GPIO_Interrupt_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.h create mode 100644 Example/Interrupt_Priority_Set_Demo/.settings/com.infineon.aurix.buildsystem.prefs create mode 100644 Example/Interrupt_Priority_Set_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.c create mode 100644 Example/Interrupt_Priority_Set_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.h create mode 100644 Example/LED_Blink_Demo/.settings/com.infineon.aurix.buildsystem.prefs create mode 100644 Example/LED_Blink_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.c create mode 100644 Example/LED_Blink_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.h create mode 100644 Example/PIT_Demo/.settings/com.infineon.aurix.buildsystem.prefs create mode 100644 Example/PIT_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.c create mode 100644 Example/PIT_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.h create mode 100644 Example/PWM_Demo/.settings/com.infineon.aurix.buildsystem.prefs create mode 100644 Example/PWM_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.c create mode 100644 Example/PWM_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.h create mode 100644 Example/Printf_Demo/.settings/com.infineon.aurix.buildsystem.prefs create mode 100644 Example/Printf_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.c create mode 100644 Example/Printf_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.h create mode 100644 Example/Specifies_Variable_Or_Code_Location_Demo/.settings/com.infineon.aurix.buildsystem.prefs create mode 100644 Example/Specifies_Variable_Or_Code_Location_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.c create mode 100644 Example/Specifies_Variable_Or_Code_Location_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.h create mode 100644 Example/Systick_Demo/.settings/com.infineon.aurix.buildsystem.prefs create mode 100644 Example/Systick_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.c create mode 100644 Example/Systick_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.h create mode 100644 Example/UART_Demo/.settings/com.infineon.aurix.buildsystem.prefs create mode 100644 Example/UART_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.c create mode 100644 Example/UART_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.h create mode 100644 Seekfree_TC264_Opensource_Library/.settings/com.infineon.aurix.buildsystem.prefs create mode 100644 Seekfree_TC264_Opensource_Library/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.c create mode 100644 Seekfree_TC264_Opensource_Library/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.h diff --git a/Example/ADC_Demo/.cproject b/Example/ADC_Demo/.cproject index 8c5b642..6059a91 100644 --- a/Example/ADC_Demo/.cproject +++ b/Example/ADC_Demo/.cproject @@ -3,9 +3,9 @@ - + - + @@ -25,50 +25,76 @@ - + - + - + - @@ -352,12 +362,14 @@ + + - + - + @@ -377,43 +389,1895 @@ - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -431,13 +2295,37 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + @@ -461,6 +2349,18 @@ + + + + + + + + + + + + diff --git a/Example/ADC_Demo/.project b/Example/ADC_Demo/.project index b1bd2f8..bfec189 100644 --- a/Example/ADC_Demo/.project +++ b/Example/ADC_Demo/.project @@ -5,6 +5,18 @@ + + com.infineon.aurix.buildsystem.builders.booster + full,incremental, + + + + + com.infineon.aurix.buildsystem.builders.autodiscovery + full,incremental, + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder clean,full,incremental, diff --git a/Example/ADC_Demo/.settings/com.infineon.aurix.buildsystem.prefs b/Example/ADC_Demo/.settings/com.infineon.aurix.buildsystem.prefs new file mode 100644 index 0000000..be61bc1 --- /dev/null +++ b/Example/ADC_Demo/.settings/com.infineon.aurix.buildsystem.prefs @@ -0,0 +1,10 @@ +AURIX-LIBRARY-PATH=Libraries/iLLD\#Libraries/Infra\#Libraries/Service +DEVICE-ID=TC26B +DEVICE-ID-FULL=TC26xD_B-Step +ILLD-SET=full +IncludesAutodiscovery=true +LIBRARIES-ROOT-PATH=Libraries +NEVER-EXCLUDE-FROM-BUILD=/Libraries/iLLD/TC26B/Tricore/Cpu/CStart\#/Libraries/iLLD/TC26B/Tricore/Cpu/Trap\#/Configurations\#/Configurations/Debug +PROJECT-VERSION=1.0 +aurixDevice=TC26xD_B-Step +eclipse.preferences.version=1 diff --git a/Example/ADC_Demo/Libraries/doc/version.txt b/Example/ADC_Demo/Libraries/doc/version.txt index ab79909..11ab82e 100644 --- a/Example/ADC_Demo/Libraries/doc/version.txt +++ b/Example/ADC_Demo/Libraries/doc/version.txt @@ -1,3 +1,13 @@ +V1.2.0 + CH9141תģ + ͵öٱ + ޸ ɾʱļ.bat ִԶرմ + ޸ ɾʱļ.bat ɾ°汾ļ + ޸ĹĿļ֧°汾 + +V1.1.10 + ޸ͨ#pragma section all "cpux_dsram"ָλʧЧ + V1.1.9 ڵķbuffӵ128ֽ diff --git a/Example/ADC_Demo/Libraries/seekfree_libraries/common/common.c b/Example/ADC_Demo/Libraries/seekfree_libraries/common/common.c index 0b9931e..7620ce6 100644 --- a/Example/ADC_Demo/Libraries/seekfree_libraries/common/common.c +++ b/Example/ADC_Demo/Libraries/seekfree_libraries/common/common.c @@ -27,6 +27,8 @@ CAMERA_TYPE_enum camera_type; //ͷͺ uint8 *camera_buffer_addr; //ͷַ +WIRELESS_TYPE_enum wireless_type;//ת + IFX_ALIGN(4) IfxCpu_syncEvent g_cpuSyncEvent = 0;//¼ͬ App_Cpu0 g_AppCpu0; //ƵϢ diff --git a/Example/ADC_Demo/Libraries/seekfree_libraries/common/common.h b/Example/ADC_Demo/Libraries/seekfree_libraries/common/common.h index 84c43ee..5b741c0 100644 --- a/Example/ADC_Demo/Libraries/seekfree_libraries/common/common.h +++ b/Example/ADC_Demo/Libraries/seekfree_libraries/common/common.h @@ -113,6 +113,12 @@ typedef enum //ö CAMERA_COLOR, //ͫ }CAMERA_TYPE_enum; +typedef enum //ģ +{ + WIRELESS_SI24R1 = 1, //ת + WIRELESS_CH9141, //ת +}WIRELESS_TYPE_enum; + #include #include #include "IfxCpu.h" @@ -120,6 +126,8 @@ typedef enum //ö extern CAMERA_TYPE_enum camera_type; //ͷͺ extern uint8 *camera_buffer_addr; //ͷַ +extern WIRELESS_TYPE_enum wireless_type; + extern IfxCpu_syncEvent g_cpuSyncEvent; void get_clk(void); diff --git a/Example/ADC_Demo/Libraries/seekfree_libraries/headfile.h b/Example/ADC_Demo/Libraries/seekfree_libraries/headfile.h index 404ee0a..b745302 100644 --- a/Example/ADC_Demo/Libraries/seekfree_libraries/headfile.h +++ b/Example/ADC_Demo/Libraries/seekfree_libraries/headfile.h @@ -65,6 +65,7 @@ #include "SEEKFREE_7725.h" #include "SEEKFREE_RDA5807.h" #include "SEEKFREE_7725_UART.h" +#include "SEEKFREE_BLUETOOTH_CH9141.h" #endif diff --git a/Example/ADC_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.c b/Example/ADC_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.c new file mode 100644 index 0000000..b4ec2df --- /dev/null +++ b/Example/ADC_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.c @@ -0,0 +1,509 @@ +/********************************************************************************************************************* + * COPYRIGHT NOTICE + * Copyright (c) 2021,ɿƼ + * All rights reserved. + * QQȺһȺ179029047() Ⱥ244861897 + * + * ݰȨɿƼУδҵ; + * ӭλʹò޸ʱ뱣ɿƼİȨ + * + * @file ɿƼתģ + * @company ɶɿƼ޹˾ + * @author ɿƼ(QQ3184284598) + * @version 鿴docversionļ 汾˵ + * @Software IAR 8.3 or MDK 5.33 + * @Taobao https://seekfree.taobao.com/ + * @date 2021-08-27 + * @note + ߶壺 + ------------------------------------ + ת Ƭ + RX 鿴SEEKFREE_BLUETOOTH_CH9141.hļеBLUETOOTH_CH9141_UART_TX궨 + TX 鿴SEEKFREE_BLUETOOTH_CH9141.hļеBLUETOOTH_CH9141_UART_RX궨 + RTS 鿴SEEKFREE_BLUETOOTH_CH9141.hļеBLUETOOTH_CH9141_RTS_PIN궨 + CTS + CMD ջ + ------------------------------------ + ********************************************************************************************************************/ +#include "zf_stm_systick.h" +#include "zf_gpio.h" +#include "zf_uart.h" +#include "zf_assert.h" +#include "SEEKFREE_BLUETOOTH_CH9141.h" + +uint8 uart_flag; +uint8 uart_data; + +vuint8 at_mode = 0; //0:͸ģʽ 1:ATģʽ 2:ģ鸴λ +vuint8 at_mode_num; //atģʽʱָʾݽյ +vuint8 at_mode_data[30]; //atĻ +vuint8 at_mode_cmd_flag; //OKӦճɹı־λ + +uint8 mac_address[17]; //macַ + + +uint8 bluetooth_ch9141_rx_buffer; + + +void bluetooth_ch9141_check_response(void); + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ жϻص +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note úISRļ 8жϳ򱻵 +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_uart_callback() +{ + while(uart_query(BLUETOOTH_CH9141_UART, &bluetooth_ch9141_rx_buffer)) + { + if(1 == at_mode) + { + //ATģʽ Ӧź ˴ifڴûҪĶ + at_mode_data[at_mode_num++] = bluetooth_ch9141_rx_buffer; + bluetooth_ch9141_check_response(); + } + else if(2 == at_mode) + { + //ģڸλ ˴ifڴûҪĶ + at_mode_num++; + } + else + { + //͸ģʽ ûڴ˴Ե͹Ķ + //ӵһֽںƬ˴ͨڴ˴ȡbluetooth_ch9141_rx_bufferȡ + + // ȡߴڵ λձ־ + uart_flag = 1; + uart_data = bluetooth_ch9141_rx_buffer; + } + + } +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģOKӦź +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note û +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_check_response(void) +{ + if(4 <= at_mode_num) + { + if(0 == strncmp("OK\r\n", (int8 *)&at_mode_data[at_mode_num-4], 4)) + { + at_mode_cmd_flag = 1; + } + } +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ鷢һûвȴӦź +// @param *str Ҫ͵ ַ +// @return void +// @since v1.0 +// Sample usage: +// @note û +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_send_at_command(const int8 *str) +{ + at_mode_num = 0; // + uart_putstr(BLUETOOTH_CH9141_UART, str); + uart_putstr(BLUETOOTH_CH9141_UART, "\r\n"); + + //ȴյӦź + while(!at_mode_cmd_flag); + at_mode_cmd_flag = 0; +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ鷢һвȴӦź +// @param *cmd Ҫ͵ +// @param *data Ҫ͵ +// @return void +// @since v1.0 +// Sample usage: +// @note û +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_send_at_command_parameter(const int8 *cmd, const int8 *data) +{ + at_mode_num = 0; // + uart_putstr(BLUETOOTH_CH9141_UART, "AT+"); + uart_putstr(BLUETOOTH_CH9141_UART, cmd); + uart_putstr(BLUETOOTH_CH9141_UART, "="); + uart_putstr(BLUETOOTH_CH9141_UART, data); + uart_putstr(BLUETOOTH_CH9141_UART, "\r\n"); + + //ȴյӦź + while(!at_mode_cmd_flag); + at_mode_cmd_flag = 0; +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģATģʽ +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_enter_at_mode(void) +{ + systick_delay_ms(STM0, 550); //ͽATģʽǰҪ֤ģ550msûнչκ + at_mode = 1; //ATģʽ + bluetooth_ch9141_send_at_command("AT..."); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ˳ATģʽ +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_exit_at_mode(void) +{ + bluetooth_ch9141_send_at_command("AT+EXIT"); + at_mode = 0; //͸ģʽ + systick_delay_ms(STM0, 300); //ȴɹATģʽ +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ鸴λ +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_reset(void) +{ + bluetooth_ch9141_send_at_command("AT+RESET"); + at_mode = 2; //ɹ + at_mode_num = 0; + while(7 > at_mode_num); //ȴģɸλ + at_mode = 0; //λ֮ģԶ͸ģʽ +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģȡMACַ +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note ô˺Ҫȵbluetooth_ch9141_enter_at_modeCMD ATģʽ +// Ҫرעbluetooth_ch9141_enter_at_modeڲ500msʱ +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_get_mac_address(void) +{ + bluetooth_ch9141_send_at_command("AT+MAC?"); + + //macַΪСθʽmac_address[0]macַλ + memcpy(mac_address, (uint8 *)at_mode_data, 17); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ÷͹ +// @param tx_power ÷͹ʣѡ鿴CH9141_TX_POWEER_enumöٳԱ +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_set_tx_power(CH9141_TX_POWEER_enum tx_power) +{ + int8 tx_power_data; + + tx_power_data = (uint8)tx_power + '0'; + bluetooth_ch9141_send_at_command_parameter("TPL", &tx_power_data); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģģʽ +// @param mode ģʽãѡ鿴CH9141_MODE_enumöٳԱ +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_set_mode(CH9141_MODE_enum mode) +{ + int8 mode_data; + + mode_data = (uint8)mode + '0'; + bluetooth_ch9141_send_at_command_parameter("BLEMODE", &mode_data); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģȡ״̬ +// @param mode ģʽãѡ鿴CH9141_MODE_enumöٳԱ +// @return CH9141_STATUS_enum ״̬Ϣ +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +CH9141_STATUS_enum bluetooth_ch9141_get_status(CH9141_MODE_enum mode) +{ + CH9141_STATUS_enum ch9141_status; + int8 mode_data; + + mode_data = (uint8)mode + '0'; + bluetooth_ch9141_send_at_command_parameter("BLEMODE", &mode_data); + + bluetooth_ch9141_send_at_command("AT+BLESTA?"); + + ch9141_status = (at_mode_data[0] - '0') * 10 + (at_mode_data[1] - '0'); + if(SLAVE_MODE == mode) + { + ch9141_status += SLAVE_NO_INIT; + } + + return ch9141_status; +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ豸 +// @param *str +// @return void +// @since v1.0 +// Sample usage: +// @note ƳȲܳ18ַ ֻΪӢ +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_set_name(const int8 *str) +{ + bluetooth_ch9141_send_at_command_parameter("NAME", str); + bluetooth_ch9141_send_at_command_parameter("PNAME", str); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ +// @param enable ʹ 0ʹ룬1ʹӱ豸 +// @param *password ַ Ϊ6ַ +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_set_password(uint8 enable, const int8 *password) +{ + if(0 == enable) + { + //ر + bluetooth_ch9141_send_at_command_parameter("PASEN", "OFF"); + } + else + { + //벢ʹ + bluetooth_ch9141_send_at_command_parameter("PASEN", "ON"); + bluetooth_ch9141_send_at_command_parameter("PASS", password); + } +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģָMACַ +// @param *mac_and_password Ҫӵ豸macַ +// @return void +// @since v1.0 +// Sample usage: +// @note bluetooth_ch9141_connect("58:B7:33:E4:C2:84,000000"); +// 58:B7:33:E4:C2:84Ϊmacַ ,Ϊָ 000000Ϊӻ +// ===================رע================== +// ʹֻ鿴macַʹñӵʱ뽫macһ +// ֻ鿴macַΪ61:62:63:64:65:66ʹñӵʱӦд +// bluetooth_ch9141_connect("66:65:64:63:62:61,000000"); +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_connect(const int8 *mac_and_password) +{ + bluetooth_ch9141_send_at_command_parameter("CONN", mac_and_password); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģĬӲãúúÿοԶ豸 +// @param *mac_and_password Ҫӵ豸macַ +// @return void +// @since v1.0 +// Sample usage: +// @note bluetooth_ch9141_default_connect("58:B7:33:E4:C2:84,000000"); +// 58:B7:33:E4:C2:84Ϊmacַ ,Ϊָ 000000Ϊӻ +// ===================رע================== +// ʹֻ鿴CH9141macַCH9141Ϊӻʹֻ +// ʹñӵʱ뽫macһ +// ֻ鿴macַΪ61:62:63:64:65:67ʹñӵʱӦд +// bluetooth_ch9141_default_connect("67:65:64:63:62:61,000000"); +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_default_connect(const int8 *mac_and_password) +{ + bluetooth_ch9141_send_at_command_parameter("CONADD", mac_and_password); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģȡrssi(źǿ) +// @param void +// @return int8 źǿ0-127 +// @since v1.0 +// Sample usage: +// @note ô˺Ҫȵbluetooth_ch9141_enter_at_modeCMD ATģʽ +// Ҫرעbluetooth_ch9141_enter_at_modeڲ500msʱ +//------------------------------------------------------------------------------------------------------------------- +int16 bluetooth_ch9141_get_rssi(void) +{ + uint8 i; + size_t length; + int16 rssi; + bluetooth_ch9141_send_at_command_parameter("RSSI", "ON,0"); + length = strlen((int8 *)at_mode_data); + length -= 12;//RSSI жλ + + rssi = 0; + for(i=0; i30) { - if(gpio_get(RTS_PIN)) - { - return len;//ģæ,ǰʹwhileȴ ʹúע͵whileȴ滻if - } - //while(gpio_get(RTS_PIN)); //RTSΪ͵ƽ +// if(gpio_get(RTS_PIN)) +// { +// return len;//ģæ,ǰʹwhileȴ ʹúע͵whileȴ滻if +// } + while(gpio_get(RTS_PIN)); //RTSΪ͵ƽ uart_putbuff(WIRELESS_UART,buff,30); buff += 30; //ַƫ len -= 30;// } - if(gpio_get(RTS_PIN)) - { - return len;//ģæ,ǰʹwhileȴ ʹúע͵whileȴ滻if - } - //while(gpio_get(RTS_PIN)); //RTSΪ͵ƽ +// if(gpio_get(RTS_PIN)) +// { +// return len;//ģæ,ǰʹwhileȴ ʹúע͵whileȴ滻if +// } + while(gpio_get(RTS_PIN)); //RTSΪ͵ƽ uart_putbuff(WIRELESS_UART,buff,len);// return 0; diff --git a/Example/ADC_Demo/Libraries/seekfree_peripheral/SEEKFREE_WIRELESS.h b/Example/ADC_Demo/Libraries/seekfree_peripheral/SEEKFREE_WIRELESS.h index 42c0832..d80339d 100644 --- a/Example/ADC_Demo/Libraries/seekfree_peripheral/SEEKFREE_WIRELESS.h +++ b/Example/ADC_Demo/Libraries/seekfree_peripheral/SEEKFREE_WIRELESS.h @@ -38,8 +38,26 @@ #define WIRELESS_UART_RX UART2_RX_P10_6 #define WIRELESS_UART_BAUD 115200 -#define RTS_PIN P10_2 //λ ָʾǰģǷԽ 0Լ 1Լ +// ------------------------------------ Զ ------------------------------------ +// ע1תģ汾V2.0µ޷Զʵġ +// ע2ԶRTSţῪʧܡ +// ע3ģԶʧܵĻԳԶϵ +// ԶĶ ע +// ԶĶ ע +// ԶĶ ע + +// 0رԶ +// 1Զ Զʵ޸WIRELESS_UART_BAUD֮ҪģãģԶΪӦIJ + +#define WIRELESS_AUTO_UART_BAUD 0 +// ------------------------------------ Զ ------------------------------------ + +#define RTS_PIN P10_2 //λ ָʾǰģǷԽ 0Լ 1Լ +#define WIRELESS_BUFFER_SIZE 16 + +extern uint8 wireless_send_buffer[WIRELESS_BUFFER_SIZE]; +extern uint32 wireless_rx_index; void wireless_uart_callback(void); void seekfree_wireless_init(void); diff --git a/Example/ADC_Demo/USER/isr.c b/Example/ADC_Demo/USER/isr.c index c55a012..16bff98 100644 --- a/Example/ADC_Demo/USER/isr.c +++ b/Example/ADC_Demo/USER/isr.c @@ -179,7 +179,20 @@ IFX_INTERRUPT(uart2_rx_isr, 0, UART2_RX_INT_PRIO) { enableInterrupts();//жǶ IfxAsclin_Asc_isrReceive(&uart2_handle); - wireless_uart_callback(); + switch(wireless_type) + { + case WIRELESS_SI24R1: + { + wireless_uart_callback(); + }break; + + case WIRELESS_CH9141: + { + bluetooth_ch9141_uart_callback(); + }break; + default:break; + } + } IFX_INTERRUPT(uart2_er_isr, 0, UART2_ER_INT_PRIO) { diff --git a/Example/ADC_Demo/删除临时文件.bat b/Example/ADC_Demo/删除临时文件.bat index 5323dd9..fa499b1 100644 --- a/Example/ADC_Demo/删除临时文件.bat +++ b/Example/ADC_Demo/删除临时文件.bat @@ -1,9 +1,6 @@ -rmdir .settings /s /q rmdir Debug /s /q del *.launch /s - -pause exit diff --git a/Example/Cpu1_Handles_Interrupts_Demo/.cproject b/Example/Cpu1_Handles_Interrupts_Demo/.cproject index cd881a9..a61c5fc 100644 --- a/Example/Cpu1_Handles_Interrupts_Demo/.cproject +++ b/Example/Cpu1_Handles_Interrupts_Demo/.cproject @@ -3,9 +3,9 @@ - + - + @@ -25,50 +25,76 @@ - + - + - + - + + + + + + @@ -355,9 +371,9 @@ - + - + @@ -377,43 +393,1895 @@ - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -431,13 +2299,37 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + @@ -458,21 +2350,5 @@ - - - - - - - - - - - - - - - - diff --git a/Example/Cpu1_Handles_Interrupts_Demo/.project b/Example/Cpu1_Handles_Interrupts_Demo/.project index fd3a5ef..e482dad 100644 --- a/Example/Cpu1_Handles_Interrupts_Demo/.project +++ b/Example/Cpu1_Handles_Interrupts_Demo/.project @@ -5,6 +5,18 @@ + + com.infineon.aurix.buildsystem.builders.booster + full,incremental, + + + + + com.infineon.aurix.buildsystem.builders.autodiscovery + full,incremental, + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder clean,full,incremental, diff --git a/Example/Cpu1_Handles_Interrupts_Demo/.settings/com.infineon.aurix.buildsystem.prefs b/Example/Cpu1_Handles_Interrupts_Demo/.settings/com.infineon.aurix.buildsystem.prefs new file mode 100644 index 0000000..be61bc1 --- /dev/null +++ b/Example/Cpu1_Handles_Interrupts_Demo/.settings/com.infineon.aurix.buildsystem.prefs @@ -0,0 +1,10 @@ +AURIX-LIBRARY-PATH=Libraries/iLLD\#Libraries/Infra\#Libraries/Service +DEVICE-ID=TC26B +DEVICE-ID-FULL=TC26xD_B-Step +ILLD-SET=full +IncludesAutodiscovery=true +LIBRARIES-ROOT-PATH=Libraries +NEVER-EXCLUDE-FROM-BUILD=/Libraries/iLLD/TC26B/Tricore/Cpu/CStart\#/Libraries/iLLD/TC26B/Tricore/Cpu/Trap\#/Configurations\#/Configurations/Debug +PROJECT-VERSION=1.0 +aurixDevice=TC26xD_B-Step +eclipse.preferences.version=1 diff --git a/Example/Cpu1_Handles_Interrupts_Demo/Libraries/doc/version.txt b/Example/Cpu1_Handles_Interrupts_Demo/Libraries/doc/version.txt index ab79909..11ab82e 100644 --- a/Example/Cpu1_Handles_Interrupts_Demo/Libraries/doc/version.txt +++ b/Example/Cpu1_Handles_Interrupts_Demo/Libraries/doc/version.txt @@ -1,3 +1,13 @@ +V1.2.0 + CH9141תģ + ͵öٱ + ޸ ɾʱļ.bat ִԶرմ + ޸ ɾʱļ.bat ɾ°汾ļ + ޸ĹĿļ֧°汾 + +V1.1.10 + ޸ͨ#pragma section all "cpux_dsram"ָλʧЧ + V1.1.9 ڵķbuffӵ128ֽ diff --git a/Example/Cpu1_Handles_Interrupts_Demo/Libraries/seekfree_libraries/common/common.c b/Example/Cpu1_Handles_Interrupts_Demo/Libraries/seekfree_libraries/common/common.c index 0b9931e..7620ce6 100644 --- a/Example/Cpu1_Handles_Interrupts_Demo/Libraries/seekfree_libraries/common/common.c +++ b/Example/Cpu1_Handles_Interrupts_Demo/Libraries/seekfree_libraries/common/common.c @@ -27,6 +27,8 @@ CAMERA_TYPE_enum camera_type; //ͷͺ uint8 *camera_buffer_addr; //ͷַ +WIRELESS_TYPE_enum wireless_type;//ת + IFX_ALIGN(4) IfxCpu_syncEvent g_cpuSyncEvent = 0;//¼ͬ App_Cpu0 g_AppCpu0; //ƵϢ diff --git a/Example/Cpu1_Handles_Interrupts_Demo/Libraries/seekfree_libraries/common/common.h b/Example/Cpu1_Handles_Interrupts_Demo/Libraries/seekfree_libraries/common/common.h index 84c43ee..5b741c0 100644 --- a/Example/Cpu1_Handles_Interrupts_Demo/Libraries/seekfree_libraries/common/common.h +++ b/Example/Cpu1_Handles_Interrupts_Demo/Libraries/seekfree_libraries/common/common.h @@ -113,6 +113,12 @@ typedef enum //ö CAMERA_COLOR, //ͫ }CAMERA_TYPE_enum; +typedef enum //ģ +{ + WIRELESS_SI24R1 = 1, //ת + WIRELESS_CH9141, //ת +}WIRELESS_TYPE_enum; + #include #include #include "IfxCpu.h" @@ -120,6 +126,8 @@ typedef enum //ö extern CAMERA_TYPE_enum camera_type; //ͷͺ extern uint8 *camera_buffer_addr; //ͷַ +extern WIRELESS_TYPE_enum wireless_type; + extern IfxCpu_syncEvent g_cpuSyncEvent; void get_clk(void); diff --git a/Example/Cpu1_Handles_Interrupts_Demo/Libraries/seekfree_libraries/headfile.h b/Example/Cpu1_Handles_Interrupts_Demo/Libraries/seekfree_libraries/headfile.h index 404ee0a..b745302 100644 --- a/Example/Cpu1_Handles_Interrupts_Demo/Libraries/seekfree_libraries/headfile.h +++ b/Example/Cpu1_Handles_Interrupts_Demo/Libraries/seekfree_libraries/headfile.h @@ -65,6 +65,7 @@ #include "SEEKFREE_7725.h" #include "SEEKFREE_RDA5807.h" #include "SEEKFREE_7725_UART.h" +#include "SEEKFREE_BLUETOOTH_CH9141.h" #endif diff --git a/Example/Cpu1_Handles_Interrupts_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.c b/Example/Cpu1_Handles_Interrupts_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.c new file mode 100644 index 0000000..b4ec2df --- /dev/null +++ b/Example/Cpu1_Handles_Interrupts_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.c @@ -0,0 +1,509 @@ +/********************************************************************************************************************* + * COPYRIGHT NOTICE + * Copyright (c) 2021,ɿƼ + * All rights reserved. + * QQȺһȺ179029047() Ⱥ244861897 + * + * ݰȨɿƼУδҵ; + * ӭλʹò޸ʱ뱣ɿƼİȨ + * + * @file ɿƼתģ + * @company ɶɿƼ޹˾ + * @author ɿƼ(QQ3184284598) + * @version 鿴docversionļ 汾˵ + * @Software IAR 8.3 or MDK 5.33 + * @Taobao https://seekfree.taobao.com/ + * @date 2021-08-27 + * @note + ߶壺 + ------------------------------------ + ת Ƭ + RX 鿴SEEKFREE_BLUETOOTH_CH9141.hļеBLUETOOTH_CH9141_UART_TX궨 + TX 鿴SEEKFREE_BLUETOOTH_CH9141.hļеBLUETOOTH_CH9141_UART_RX궨 + RTS 鿴SEEKFREE_BLUETOOTH_CH9141.hļеBLUETOOTH_CH9141_RTS_PIN궨 + CTS + CMD ջ + ------------------------------------ + ********************************************************************************************************************/ +#include "zf_stm_systick.h" +#include "zf_gpio.h" +#include "zf_uart.h" +#include "zf_assert.h" +#include "SEEKFREE_BLUETOOTH_CH9141.h" + +uint8 uart_flag; +uint8 uart_data; + +vuint8 at_mode = 0; //0:͸ģʽ 1:ATģʽ 2:ģ鸴λ +vuint8 at_mode_num; //atģʽʱָʾݽյ +vuint8 at_mode_data[30]; //atĻ +vuint8 at_mode_cmd_flag; //OKӦճɹı־λ + +uint8 mac_address[17]; //macַ + + +uint8 bluetooth_ch9141_rx_buffer; + + +void bluetooth_ch9141_check_response(void); + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ жϻص +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note úISRļ 8жϳ򱻵 +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_uart_callback() +{ + while(uart_query(BLUETOOTH_CH9141_UART, &bluetooth_ch9141_rx_buffer)) + { + if(1 == at_mode) + { + //ATģʽ Ӧź ˴ifڴûҪĶ + at_mode_data[at_mode_num++] = bluetooth_ch9141_rx_buffer; + bluetooth_ch9141_check_response(); + } + else if(2 == at_mode) + { + //ģڸλ ˴ifڴûҪĶ + at_mode_num++; + } + else + { + //͸ģʽ ûڴ˴Ե͹Ķ + //ӵһֽںƬ˴ͨڴ˴ȡbluetooth_ch9141_rx_bufferȡ + + // ȡߴڵ λձ־ + uart_flag = 1; + uart_data = bluetooth_ch9141_rx_buffer; + } + + } +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģOKӦź +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note û +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_check_response(void) +{ + if(4 <= at_mode_num) + { + if(0 == strncmp("OK\r\n", (int8 *)&at_mode_data[at_mode_num-4], 4)) + { + at_mode_cmd_flag = 1; + } + } +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ鷢һûвȴӦź +// @param *str Ҫ͵ ַ +// @return void +// @since v1.0 +// Sample usage: +// @note û +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_send_at_command(const int8 *str) +{ + at_mode_num = 0; // + uart_putstr(BLUETOOTH_CH9141_UART, str); + uart_putstr(BLUETOOTH_CH9141_UART, "\r\n"); + + //ȴյӦź + while(!at_mode_cmd_flag); + at_mode_cmd_flag = 0; +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ鷢һвȴӦź +// @param *cmd Ҫ͵ +// @param *data Ҫ͵ +// @return void +// @since v1.0 +// Sample usage: +// @note û +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_send_at_command_parameter(const int8 *cmd, const int8 *data) +{ + at_mode_num = 0; // + uart_putstr(BLUETOOTH_CH9141_UART, "AT+"); + uart_putstr(BLUETOOTH_CH9141_UART, cmd); + uart_putstr(BLUETOOTH_CH9141_UART, "="); + uart_putstr(BLUETOOTH_CH9141_UART, data); + uart_putstr(BLUETOOTH_CH9141_UART, "\r\n"); + + //ȴյӦź + while(!at_mode_cmd_flag); + at_mode_cmd_flag = 0; +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģATģʽ +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_enter_at_mode(void) +{ + systick_delay_ms(STM0, 550); //ͽATģʽǰҪ֤ģ550msûнչκ + at_mode = 1; //ATģʽ + bluetooth_ch9141_send_at_command("AT..."); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ˳ATģʽ +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_exit_at_mode(void) +{ + bluetooth_ch9141_send_at_command("AT+EXIT"); + at_mode = 0; //͸ģʽ + systick_delay_ms(STM0, 300); //ȴɹATģʽ +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ鸴λ +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_reset(void) +{ + bluetooth_ch9141_send_at_command("AT+RESET"); + at_mode = 2; //ɹ + at_mode_num = 0; + while(7 > at_mode_num); //ȴģɸλ + at_mode = 0; //λ֮ģԶ͸ģʽ +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģȡMACַ +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note ô˺Ҫȵbluetooth_ch9141_enter_at_modeCMD ATģʽ +// Ҫرעbluetooth_ch9141_enter_at_modeڲ500msʱ +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_get_mac_address(void) +{ + bluetooth_ch9141_send_at_command("AT+MAC?"); + + //macַΪСθʽmac_address[0]macַλ + memcpy(mac_address, (uint8 *)at_mode_data, 17); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ÷͹ +// @param tx_power ÷͹ʣѡ鿴CH9141_TX_POWEER_enumöٳԱ +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_set_tx_power(CH9141_TX_POWEER_enum tx_power) +{ + int8 tx_power_data; + + tx_power_data = (uint8)tx_power + '0'; + bluetooth_ch9141_send_at_command_parameter("TPL", &tx_power_data); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģģʽ +// @param mode ģʽãѡ鿴CH9141_MODE_enumöٳԱ +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_set_mode(CH9141_MODE_enum mode) +{ + int8 mode_data; + + mode_data = (uint8)mode + '0'; + bluetooth_ch9141_send_at_command_parameter("BLEMODE", &mode_data); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģȡ״̬ +// @param mode ģʽãѡ鿴CH9141_MODE_enumöٳԱ +// @return CH9141_STATUS_enum ״̬Ϣ +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +CH9141_STATUS_enum bluetooth_ch9141_get_status(CH9141_MODE_enum mode) +{ + CH9141_STATUS_enum ch9141_status; + int8 mode_data; + + mode_data = (uint8)mode + '0'; + bluetooth_ch9141_send_at_command_parameter("BLEMODE", &mode_data); + + bluetooth_ch9141_send_at_command("AT+BLESTA?"); + + ch9141_status = (at_mode_data[0] - '0') * 10 + (at_mode_data[1] - '0'); + if(SLAVE_MODE == mode) + { + ch9141_status += SLAVE_NO_INIT; + } + + return ch9141_status; +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ豸 +// @param *str +// @return void +// @since v1.0 +// Sample usage: +// @note ƳȲܳ18ַ ֻΪӢ +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_set_name(const int8 *str) +{ + bluetooth_ch9141_send_at_command_parameter("NAME", str); + bluetooth_ch9141_send_at_command_parameter("PNAME", str); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ +// @param enable ʹ 0ʹ룬1ʹӱ豸 +// @param *password ַ Ϊ6ַ +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_set_password(uint8 enable, const int8 *password) +{ + if(0 == enable) + { + //ر + bluetooth_ch9141_send_at_command_parameter("PASEN", "OFF"); + } + else + { + //벢ʹ + bluetooth_ch9141_send_at_command_parameter("PASEN", "ON"); + bluetooth_ch9141_send_at_command_parameter("PASS", password); + } +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģָMACַ +// @param *mac_and_password Ҫӵ豸macַ +// @return void +// @since v1.0 +// Sample usage: +// @note bluetooth_ch9141_connect("58:B7:33:E4:C2:84,000000"); +// 58:B7:33:E4:C2:84Ϊmacַ ,Ϊָ 000000Ϊӻ +// ===================رע================== +// ʹֻ鿴macַʹñӵʱ뽫macһ +// ֻ鿴macַΪ61:62:63:64:65:66ʹñӵʱӦд +// bluetooth_ch9141_connect("66:65:64:63:62:61,000000"); +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_connect(const int8 *mac_and_password) +{ + bluetooth_ch9141_send_at_command_parameter("CONN", mac_and_password); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģĬӲãúúÿοԶ豸 +// @param *mac_and_password Ҫӵ豸macַ +// @return void +// @since v1.0 +// Sample usage: +// @note bluetooth_ch9141_default_connect("58:B7:33:E4:C2:84,000000"); +// 58:B7:33:E4:C2:84Ϊmacַ ,Ϊָ 000000Ϊӻ +// ===================رע================== +// ʹֻ鿴CH9141macַCH9141Ϊӻʹֻ +// ʹñӵʱ뽫macһ +// ֻ鿴macַΪ61:62:63:64:65:67ʹñӵʱӦд +// bluetooth_ch9141_default_connect("67:65:64:63:62:61,000000"); +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_default_connect(const int8 *mac_and_password) +{ + bluetooth_ch9141_send_at_command_parameter("CONADD", mac_and_password); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģȡrssi(źǿ) +// @param void +// @return int8 źǿ0-127 +// @since v1.0 +// Sample usage: +// @note ô˺Ҫȵbluetooth_ch9141_enter_at_modeCMD ATģʽ +// Ҫرעbluetooth_ch9141_enter_at_modeڲ500msʱ +//------------------------------------------------------------------------------------------------------------------- +int16 bluetooth_ch9141_get_rssi(void) +{ + uint8 i; + size_t length; + int16 rssi; + bluetooth_ch9141_send_at_command_parameter("RSSI", "ON,0"); + length = strlen((int8 *)at_mode_data); + length -= 12;//RSSI жλ + + rssi = 0; + for(i=0; i30) { - if(gpio_get(RTS_PIN)) - { - return len;//ģæ,ǰʹwhileȴ ʹúע͵whileȴ滻if - } - //while(gpio_get(RTS_PIN)); //RTSΪ͵ƽ +// if(gpio_get(RTS_PIN)) +// { +// return len;//ģæ,ǰʹwhileȴ ʹúע͵whileȴ滻if +// } + while(gpio_get(RTS_PIN)); //RTSΪ͵ƽ uart_putbuff(WIRELESS_UART,buff,30); buff += 30; //ַƫ len -= 30;// } - if(gpio_get(RTS_PIN)) - { - return len;//ģæ,ǰʹwhileȴ ʹúע͵whileȴ滻if - } - //while(gpio_get(RTS_PIN)); //RTSΪ͵ƽ +// if(gpio_get(RTS_PIN)) +// { +// return len;//ģæ,ǰʹwhileȴ ʹúע͵whileȴ滻if +// } + while(gpio_get(RTS_PIN)); //RTSΪ͵ƽ uart_putbuff(WIRELESS_UART,buff,len);// return 0; diff --git a/Example/Cpu1_Handles_Interrupts_Demo/Libraries/seekfree_peripheral/SEEKFREE_WIRELESS.h b/Example/Cpu1_Handles_Interrupts_Demo/Libraries/seekfree_peripheral/SEEKFREE_WIRELESS.h index 42c0832..d80339d 100644 --- a/Example/Cpu1_Handles_Interrupts_Demo/Libraries/seekfree_peripheral/SEEKFREE_WIRELESS.h +++ b/Example/Cpu1_Handles_Interrupts_Demo/Libraries/seekfree_peripheral/SEEKFREE_WIRELESS.h @@ -38,8 +38,26 @@ #define WIRELESS_UART_RX UART2_RX_P10_6 #define WIRELESS_UART_BAUD 115200 -#define RTS_PIN P10_2 //λ ָʾǰģǷԽ 0Լ 1Լ +// ------------------------------------ Զ ------------------------------------ +// ע1תģ汾V2.0µ޷Զʵġ +// ע2ԶRTSţῪʧܡ +// ע3ģԶʧܵĻԳԶϵ +// ԶĶ ע +// ԶĶ ע +// ԶĶ ע + +// 0رԶ +// 1Զ Զʵ޸WIRELESS_UART_BAUD֮ҪģãģԶΪӦIJ + +#define WIRELESS_AUTO_UART_BAUD 0 +// ------------------------------------ Զ ------------------------------------ + +#define RTS_PIN P10_2 //λ ָʾǰģǷԽ 0Լ 1Լ +#define WIRELESS_BUFFER_SIZE 16 + +extern uint8 wireless_send_buffer[WIRELESS_BUFFER_SIZE]; +extern uint32 wireless_rx_index; void wireless_uart_callback(void); void seekfree_wireless_init(void); diff --git a/Example/Cpu1_Handles_Interrupts_Demo/USER/isr.c b/Example/Cpu1_Handles_Interrupts_Demo/USER/isr.c index 50acc67..42c2fc7 100644 --- a/Example/Cpu1_Handles_Interrupts_Demo/USER/isr.c +++ b/Example/Cpu1_Handles_Interrupts_Demo/USER/isr.c @@ -191,7 +191,20 @@ IFX_INTERRUPT(uart2_rx_isr, 0, UART2_RX_INT_PRIO) { enableInterrupts();//жǶ IfxAsclin_Asc_isrReceive(&uart2_handle); - wireless_uart_callback(); + switch(wireless_type) + { + case WIRELESS_SI24R1: + { + wireless_uart_callback(); + }break; + + case WIRELESS_CH9141: + { + bluetooth_ch9141_uart_callback(); + }break; + default:break; + } + } IFX_INTERRUPT(uart2_er_isr, 0, UART2_ER_INT_PRIO) { diff --git a/Example/Cpu1_Handles_Interrupts_Demo/删除临时文件.bat b/Example/Cpu1_Handles_Interrupts_Demo/删除临时文件.bat index 5323dd9..fa499b1 100644 --- a/Example/Cpu1_Handles_Interrupts_Demo/删除临时文件.bat +++ b/Example/Cpu1_Handles_Interrupts_Demo/删除临时文件.bat @@ -1,9 +1,6 @@ -rmdir .settings /s /q rmdir Debug /s /q del *.launch /s - -pause exit diff --git a/Example/Dual_Core_Demo/.cproject b/Example/Dual_Core_Demo/.cproject index 095dede..95670fd 100644 --- a/Example/Dual_Core_Demo/.cproject +++ b/Example/Dual_Core_Demo/.cproject @@ -3,9 +3,9 @@ - + - + @@ -25,50 +25,76 @@ - + - + - + - + + + + + + @@ -355,9 +371,9 @@ - + - + @@ -377,43 +393,1895 @@ - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -431,13 +2299,37 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + @@ -458,21 +2350,5 @@ - - - - - - - - - - - - - - - - diff --git a/Example/Dual_Core_Demo/.project b/Example/Dual_Core_Demo/.project index 794dc2b..f5a2144 100644 --- a/Example/Dual_Core_Demo/.project +++ b/Example/Dual_Core_Demo/.project @@ -5,6 +5,18 @@ + + com.infineon.aurix.buildsystem.builders.booster + full,incremental, + + + + + com.infineon.aurix.buildsystem.builders.autodiscovery + full,incremental, + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder clean,full,incremental, diff --git a/Example/Dual_Core_Demo/.settings/com.infineon.aurix.buildsystem.prefs b/Example/Dual_Core_Demo/.settings/com.infineon.aurix.buildsystem.prefs new file mode 100644 index 0000000..be61bc1 --- /dev/null +++ b/Example/Dual_Core_Demo/.settings/com.infineon.aurix.buildsystem.prefs @@ -0,0 +1,10 @@ +AURIX-LIBRARY-PATH=Libraries/iLLD\#Libraries/Infra\#Libraries/Service +DEVICE-ID=TC26B +DEVICE-ID-FULL=TC26xD_B-Step +ILLD-SET=full +IncludesAutodiscovery=true +LIBRARIES-ROOT-PATH=Libraries +NEVER-EXCLUDE-FROM-BUILD=/Libraries/iLLD/TC26B/Tricore/Cpu/CStart\#/Libraries/iLLD/TC26B/Tricore/Cpu/Trap\#/Configurations\#/Configurations/Debug +PROJECT-VERSION=1.0 +aurixDevice=TC26xD_B-Step +eclipse.preferences.version=1 diff --git a/Example/Dual_Core_Demo/Libraries/doc/version.txt b/Example/Dual_Core_Demo/Libraries/doc/version.txt index ab79909..11ab82e 100644 --- a/Example/Dual_Core_Demo/Libraries/doc/version.txt +++ b/Example/Dual_Core_Demo/Libraries/doc/version.txt @@ -1,3 +1,13 @@ +V1.2.0 + CH9141תģ + ͵öٱ + ޸ ɾʱļ.bat ִԶرմ + ޸ ɾʱļ.bat ɾ°汾ļ + ޸ĹĿļ֧°汾 + +V1.1.10 + ޸ͨ#pragma section all "cpux_dsram"ָλʧЧ + V1.1.9 ڵķbuffӵ128ֽ diff --git a/Example/Dual_Core_Demo/Libraries/seekfree_libraries/common/common.c b/Example/Dual_Core_Demo/Libraries/seekfree_libraries/common/common.c index 0b9931e..7620ce6 100644 --- a/Example/Dual_Core_Demo/Libraries/seekfree_libraries/common/common.c +++ b/Example/Dual_Core_Demo/Libraries/seekfree_libraries/common/common.c @@ -27,6 +27,8 @@ CAMERA_TYPE_enum camera_type; //ͷͺ uint8 *camera_buffer_addr; //ͷַ +WIRELESS_TYPE_enum wireless_type;//ת + IFX_ALIGN(4) IfxCpu_syncEvent g_cpuSyncEvent = 0;//¼ͬ App_Cpu0 g_AppCpu0; //ƵϢ diff --git a/Example/Dual_Core_Demo/Libraries/seekfree_libraries/common/common.h b/Example/Dual_Core_Demo/Libraries/seekfree_libraries/common/common.h index 84c43ee..5b741c0 100644 --- a/Example/Dual_Core_Demo/Libraries/seekfree_libraries/common/common.h +++ b/Example/Dual_Core_Demo/Libraries/seekfree_libraries/common/common.h @@ -113,6 +113,12 @@ typedef enum //ö CAMERA_COLOR, //ͫ }CAMERA_TYPE_enum; +typedef enum //ģ +{ + WIRELESS_SI24R1 = 1, //ת + WIRELESS_CH9141, //ת +}WIRELESS_TYPE_enum; + #include #include #include "IfxCpu.h" @@ -120,6 +126,8 @@ typedef enum //ö extern CAMERA_TYPE_enum camera_type; //ͷͺ extern uint8 *camera_buffer_addr; //ͷַ +extern WIRELESS_TYPE_enum wireless_type; + extern IfxCpu_syncEvent g_cpuSyncEvent; void get_clk(void); diff --git a/Example/Dual_Core_Demo/Libraries/seekfree_libraries/headfile.h b/Example/Dual_Core_Demo/Libraries/seekfree_libraries/headfile.h index 404ee0a..b745302 100644 --- a/Example/Dual_Core_Demo/Libraries/seekfree_libraries/headfile.h +++ b/Example/Dual_Core_Demo/Libraries/seekfree_libraries/headfile.h @@ -65,6 +65,7 @@ #include "SEEKFREE_7725.h" #include "SEEKFREE_RDA5807.h" #include "SEEKFREE_7725_UART.h" +#include "SEEKFREE_BLUETOOTH_CH9141.h" #endif diff --git a/Example/Dual_Core_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.c b/Example/Dual_Core_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.c new file mode 100644 index 0000000..b4ec2df --- /dev/null +++ b/Example/Dual_Core_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.c @@ -0,0 +1,509 @@ +/********************************************************************************************************************* + * COPYRIGHT NOTICE + * Copyright (c) 2021,ɿƼ + * All rights reserved. + * QQȺһȺ179029047() Ⱥ244861897 + * + * ݰȨɿƼУδҵ; + * ӭλʹò޸ʱ뱣ɿƼİȨ + * + * @file ɿƼתģ + * @company ɶɿƼ޹˾ + * @author ɿƼ(QQ3184284598) + * @version 鿴docversionļ 汾˵ + * @Software IAR 8.3 or MDK 5.33 + * @Taobao https://seekfree.taobao.com/ + * @date 2021-08-27 + * @note + ߶壺 + ------------------------------------ + ת Ƭ + RX 鿴SEEKFREE_BLUETOOTH_CH9141.hļеBLUETOOTH_CH9141_UART_TX궨 + TX 鿴SEEKFREE_BLUETOOTH_CH9141.hļеBLUETOOTH_CH9141_UART_RX궨 + RTS 鿴SEEKFREE_BLUETOOTH_CH9141.hļеBLUETOOTH_CH9141_RTS_PIN궨 + CTS + CMD ջ + ------------------------------------ + ********************************************************************************************************************/ +#include "zf_stm_systick.h" +#include "zf_gpio.h" +#include "zf_uart.h" +#include "zf_assert.h" +#include "SEEKFREE_BLUETOOTH_CH9141.h" + +uint8 uart_flag; +uint8 uart_data; + +vuint8 at_mode = 0; //0:͸ģʽ 1:ATģʽ 2:ģ鸴λ +vuint8 at_mode_num; //atģʽʱָʾݽյ +vuint8 at_mode_data[30]; //atĻ +vuint8 at_mode_cmd_flag; //OKӦճɹı־λ + +uint8 mac_address[17]; //macַ + + +uint8 bluetooth_ch9141_rx_buffer; + + +void bluetooth_ch9141_check_response(void); + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ жϻص +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note úISRļ 8жϳ򱻵 +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_uart_callback() +{ + while(uart_query(BLUETOOTH_CH9141_UART, &bluetooth_ch9141_rx_buffer)) + { + if(1 == at_mode) + { + //ATģʽ Ӧź ˴ifڴûҪĶ + at_mode_data[at_mode_num++] = bluetooth_ch9141_rx_buffer; + bluetooth_ch9141_check_response(); + } + else if(2 == at_mode) + { + //ģڸλ ˴ifڴûҪĶ + at_mode_num++; + } + else + { + //͸ģʽ ûڴ˴Ե͹Ķ + //ӵһֽںƬ˴ͨڴ˴ȡbluetooth_ch9141_rx_bufferȡ + + // ȡߴڵ λձ־ + uart_flag = 1; + uart_data = bluetooth_ch9141_rx_buffer; + } + + } +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģOKӦź +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note û +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_check_response(void) +{ + if(4 <= at_mode_num) + { + if(0 == strncmp("OK\r\n", (int8 *)&at_mode_data[at_mode_num-4], 4)) + { + at_mode_cmd_flag = 1; + } + } +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ鷢һûвȴӦź +// @param *str Ҫ͵ ַ +// @return void +// @since v1.0 +// Sample usage: +// @note û +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_send_at_command(const int8 *str) +{ + at_mode_num = 0; // + uart_putstr(BLUETOOTH_CH9141_UART, str); + uart_putstr(BLUETOOTH_CH9141_UART, "\r\n"); + + //ȴյӦź + while(!at_mode_cmd_flag); + at_mode_cmd_flag = 0; +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ鷢һвȴӦź +// @param *cmd Ҫ͵ +// @param *data Ҫ͵ +// @return void +// @since v1.0 +// Sample usage: +// @note û +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_send_at_command_parameter(const int8 *cmd, const int8 *data) +{ + at_mode_num = 0; // + uart_putstr(BLUETOOTH_CH9141_UART, "AT+"); + uart_putstr(BLUETOOTH_CH9141_UART, cmd); + uart_putstr(BLUETOOTH_CH9141_UART, "="); + uart_putstr(BLUETOOTH_CH9141_UART, data); + uart_putstr(BLUETOOTH_CH9141_UART, "\r\n"); + + //ȴյӦź + while(!at_mode_cmd_flag); + at_mode_cmd_flag = 0; +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģATģʽ +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_enter_at_mode(void) +{ + systick_delay_ms(STM0, 550); //ͽATģʽǰҪ֤ģ550msûнչκ + at_mode = 1; //ATģʽ + bluetooth_ch9141_send_at_command("AT..."); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ˳ATģʽ +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_exit_at_mode(void) +{ + bluetooth_ch9141_send_at_command("AT+EXIT"); + at_mode = 0; //͸ģʽ + systick_delay_ms(STM0, 300); //ȴɹATģʽ +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ鸴λ +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_reset(void) +{ + bluetooth_ch9141_send_at_command("AT+RESET"); + at_mode = 2; //ɹ + at_mode_num = 0; + while(7 > at_mode_num); //ȴģɸλ + at_mode = 0; //λ֮ģԶ͸ģʽ +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģȡMACַ +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note ô˺Ҫȵbluetooth_ch9141_enter_at_modeCMD ATģʽ +// Ҫرעbluetooth_ch9141_enter_at_modeڲ500msʱ +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_get_mac_address(void) +{ + bluetooth_ch9141_send_at_command("AT+MAC?"); + + //macַΪСθʽmac_address[0]macַλ + memcpy(mac_address, (uint8 *)at_mode_data, 17); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ÷͹ +// @param tx_power ÷͹ʣѡ鿴CH9141_TX_POWEER_enumöٳԱ +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_set_tx_power(CH9141_TX_POWEER_enum tx_power) +{ + int8 tx_power_data; + + tx_power_data = (uint8)tx_power + '0'; + bluetooth_ch9141_send_at_command_parameter("TPL", &tx_power_data); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģģʽ +// @param mode ģʽãѡ鿴CH9141_MODE_enumöٳԱ +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_set_mode(CH9141_MODE_enum mode) +{ + int8 mode_data; + + mode_data = (uint8)mode + '0'; + bluetooth_ch9141_send_at_command_parameter("BLEMODE", &mode_data); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģȡ״̬ +// @param mode ģʽãѡ鿴CH9141_MODE_enumöٳԱ +// @return CH9141_STATUS_enum ״̬Ϣ +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +CH9141_STATUS_enum bluetooth_ch9141_get_status(CH9141_MODE_enum mode) +{ + CH9141_STATUS_enum ch9141_status; + int8 mode_data; + + mode_data = (uint8)mode + '0'; + bluetooth_ch9141_send_at_command_parameter("BLEMODE", &mode_data); + + bluetooth_ch9141_send_at_command("AT+BLESTA?"); + + ch9141_status = (at_mode_data[0] - '0') * 10 + (at_mode_data[1] - '0'); + if(SLAVE_MODE == mode) + { + ch9141_status += SLAVE_NO_INIT; + } + + return ch9141_status; +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ豸 +// @param *str +// @return void +// @since v1.0 +// Sample usage: +// @note ƳȲܳ18ַ ֻΪӢ +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_set_name(const int8 *str) +{ + bluetooth_ch9141_send_at_command_parameter("NAME", str); + bluetooth_ch9141_send_at_command_parameter("PNAME", str); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ +// @param enable ʹ 0ʹ룬1ʹӱ豸 +// @param *password ַ Ϊ6ַ +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_set_password(uint8 enable, const int8 *password) +{ + if(0 == enable) + { + //ر + bluetooth_ch9141_send_at_command_parameter("PASEN", "OFF"); + } + else + { + //벢ʹ + bluetooth_ch9141_send_at_command_parameter("PASEN", "ON"); + bluetooth_ch9141_send_at_command_parameter("PASS", password); + } +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģָMACַ +// @param *mac_and_password Ҫӵ豸macַ +// @return void +// @since v1.0 +// Sample usage: +// @note bluetooth_ch9141_connect("58:B7:33:E4:C2:84,000000"); +// 58:B7:33:E4:C2:84Ϊmacַ ,Ϊָ 000000Ϊӻ +// ===================رע================== +// ʹֻ鿴macַʹñӵʱ뽫macһ +// ֻ鿴macַΪ61:62:63:64:65:66ʹñӵʱӦд +// bluetooth_ch9141_connect("66:65:64:63:62:61,000000"); +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_connect(const int8 *mac_and_password) +{ + bluetooth_ch9141_send_at_command_parameter("CONN", mac_and_password); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģĬӲãúúÿοԶ豸 +// @param *mac_and_password Ҫӵ豸macַ +// @return void +// @since v1.0 +// Sample usage: +// @note bluetooth_ch9141_default_connect("58:B7:33:E4:C2:84,000000"); +// 58:B7:33:E4:C2:84Ϊmacַ ,Ϊָ 000000Ϊӻ +// ===================رע================== +// ʹֻ鿴CH9141macַCH9141Ϊӻʹֻ +// ʹñӵʱ뽫macһ +// ֻ鿴macַΪ61:62:63:64:65:67ʹñӵʱӦд +// bluetooth_ch9141_default_connect("67:65:64:63:62:61,000000"); +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_default_connect(const int8 *mac_and_password) +{ + bluetooth_ch9141_send_at_command_parameter("CONADD", mac_and_password); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģȡrssi(źǿ) +// @param void +// @return int8 źǿ0-127 +// @since v1.0 +// Sample usage: +// @note ô˺Ҫȵbluetooth_ch9141_enter_at_modeCMD ATģʽ +// Ҫرעbluetooth_ch9141_enter_at_modeڲ500msʱ +//------------------------------------------------------------------------------------------------------------------- +int16 bluetooth_ch9141_get_rssi(void) +{ + uint8 i; + size_t length; + int16 rssi; + bluetooth_ch9141_send_at_command_parameter("RSSI", "ON,0"); + length = strlen((int8 *)at_mode_data); + length -= 12;//RSSI жλ + + rssi = 0; + for(i=0; i30) { - if(gpio_get(RTS_PIN)) - { - return len;//ģæ,ǰʹwhileȴ ʹúע͵whileȴ滻if - } - //while(gpio_get(RTS_PIN)); //RTSΪ͵ƽ +// if(gpio_get(RTS_PIN)) +// { +// return len;//ģæ,ǰʹwhileȴ ʹúע͵whileȴ滻if +// } + while(gpio_get(RTS_PIN)); //RTSΪ͵ƽ uart_putbuff(WIRELESS_UART,buff,30); buff += 30; //ַƫ len -= 30;// } - if(gpio_get(RTS_PIN)) - { - return len;//ģæ,ǰʹwhileȴ ʹúע͵whileȴ滻if - } - //while(gpio_get(RTS_PIN)); //RTSΪ͵ƽ +// if(gpio_get(RTS_PIN)) +// { +// return len;//ģæ,ǰʹwhileȴ ʹúע͵whileȴ滻if +// } + while(gpio_get(RTS_PIN)); //RTSΪ͵ƽ uart_putbuff(WIRELESS_UART,buff,len);// return 0; diff --git a/Example/Dual_Core_Demo/Libraries/seekfree_peripheral/SEEKFREE_WIRELESS.h b/Example/Dual_Core_Demo/Libraries/seekfree_peripheral/SEEKFREE_WIRELESS.h index 42c0832..d80339d 100644 --- a/Example/Dual_Core_Demo/Libraries/seekfree_peripheral/SEEKFREE_WIRELESS.h +++ b/Example/Dual_Core_Demo/Libraries/seekfree_peripheral/SEEKFREE_WIRELESS.h @@ -38,8 +38,26 @@ #define WIRELESS_UART_RX UART2_RX_P10_6 #define WIRELESS_UART_BAUD 115200 -#define RTS_PIN P10_2 //λ ָʾǰģǷԽ 0Լ 1Լ +// ------------------------------------ Զ ------------------------------------ +// ע1תģ汾V2.0µ޷Զʵġ +// ע2ԶRTSţῪʧܡ +// ע3ģԶʧܵĻԳԶϵ +// ԶĶ ע +// ԶĶ ע +// ԶĶ ע + +// 0رԶ +// 1Զ Զʵ޸WIRELESS_UART_BAUD֮ҪģãģԶΪӦIJ + +#define WIRELESS_AUTO_UART_BAUD 0 +// ------------------------------------ Զ ------------------------------------ + +#define RTS_PIN P10_2 //λ ָʾǰģǷԽ 0Լ 1Լ +#define WIRELESS_BUFFER_SIZE 16 + +extern uint8 wireless_send_buffer[WIRELESS_BUFFER_SIZE]; +extern uint32 wireless_rx_index; void wireless_uart_callback(void); void seekfree_wireless_init(void); diff --git a/Example/Dual_Core_Demo/USER/isr.c b/Example/Dual_Core_Demo/USER/isr.c index c55a012..16bff98 100644 --- a/Example/Dual_Core_Demo/USER/isr.c +++ b/Example/Dual_Core_Demo/USER/isr.c @@ -179,7 +179,20 @@ IFX_INTERRUPT(uart2_rx_isr, 0, UART2_RX_INT_PRIO) { enableInterrupts();//жǶ IfxAsclin_Asc_isrReceive(&uart2_handle); - wireless_uart_callback(); + switch(wireless_type) + { + case WIRELESS_SI24R1: + { + wireless_uart_callback(); + }break; + + case WIRELESS_CH9141: + { + bluetooth_ch9141_uart_callback(); + }break; + default:break; + } + } IFX_INTERRUPT(uart2_er_isr, 0, UART2_ER_INT_PRIO) { diff --git a/Example/Dual_Core_Demo/删除临时文件.bat b/Example/Dual_Core_Demo/删除临时文件.bat index 5323dd9..fa499b1 100644 --- a/Example/Dual_Core_Demo/删除临时文件.bat +++ b/Example/Dual_Core_Demo/删除临时文件.bat @@ -1,9 +1,6 @@ -rmdir .settings /s /q rmdir Debug /s /q del *.launch /s - -pause exit diff --git a/Example/EEPROM_Demo/.cproject b/Example/EEPROM_Demo/.cproject index dfa511c..719d825 100644 --- a/Example/EEPROM_Demo/.cproject +++ b/Example/EEPROM_Demo/.cproject @@ -3,9 +3,9 @@ - + - + @@ -25,50 +25,76 @@ - + - + - + - + + + + + + @@ -355,9 +371,9 @@ - + - + @@ -377,43 +393,1895 @@ - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -431,13 +2299,37 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + @@ -459,14 +2351,6 @@ - - - - - - - - - + diff --git a/Example/EEPROM_Demo/.project b/Example/EEPROM_Demo/.project index 7d949cd..0f2fe7e 100644 --- a/Example/EEPROM_Demo/.project +++ b/Example/EEPROM_Demo/.project @@ -5,6 +5,18 @@ + + com.infineon.aurix.buildsystem.builders.booster + full,incremental, + + + + + com.infineon.aurix.buildsystem.builders.autodiscovery + full,incremental, + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder clean,full,incremental, diff --git a/Example/EEPROM_Demo/.settings/com.infineon.aurix.buildsystem.prefs b/Example/EEPROM_Demo/.settings/com.infineon.aurix.buildsystem.prefs new file mode 100644 index 0000000..be61bc1 --- /dev/null +++ b/Example/EEPROM_Demo/.settings/com.infineon.aurix.buildsystem.prefs @@ -0,0 +1,10 @@ +AURIX-LIBRARY-PATH=Libraries/iLLD\#Libraries/Infra\#Libraries/Service +DEVICE-ID=TC26B +DEVICE-ID-FULL=TC26xD_B-Step +ILLD-SET=full +IncludesAutodiscovery=true +LIBRARIES-ROOT-PATH=Libraries +NEVER-EXCLUDE-FROM-BUILD=/Libraries/iLLD/TC26B/Tricore/Cpu/CStart\#/Libraries/iLLD/TC26B/Tricore/Cpu/Trap\#/Configurations\#/Configurations/Debug +PROJECT-VERSION=1.0 +aurixDevice=TC26xD_B-Step +eclipse.preferences.version=1 diff --git a/Example/EEPROM_Demo/Libraries/doc/version.txt b/Example/EEPROM_Demo/Libraries/doc/version.txt index ab79909..11ab82e 100644 --- a/Example/EEPROM_Demo/Libraries/doc/version.txt +++ b/Example/EEPROM_Demo/Libraries/doc/version.txt @@ -1,3 +1,13 @@ +V1.2.0 + CH9141תģ + ͵öٱ + ޸ ɾʱļ.bat ִԶرմ + ޸ ɾʱļ.bat ɾ°汾ļ + ޸ĹĿļ֧°汾 + +V1.1.10 + ޸ͨ#pragma section all "cpux_dsram"ָλʧЧ + V1.1.9 ڵķbuffӵ128ֽ diff --git a/Example/EEPROM_Demo/Libraries/seekfree_libraries/common/common.c b/Example/EEPROM_Demo/Libraries/seekfree_libraries/common/common.c index 0b9931e..7620ce6 100644 --- a/Example/EEPROM_Demo/Libraries/seekfree_libraries/common/common.c +++ b/Example/EEPROM_Demo/Libraries/seekfree_libraries/common/common.c @@ -27,6 +27,8 @@ CAMERA_TYPE_enum camera_type; //ͷͺ uint8 *camera_buffer_addr; //ͷַ +WIRELESS_TYPE_enum wireless_type;//ת + IFX_ALIGN(4) IfxCpu_syncEvent g_cpuSyncEvent = 0;//¼ͬ App_Cpu0 g_AppCpu0; //ƵϢ diff --git a/Example/EEPROM_Demo/Libraries/seekfree_libraries/common/common.h b/Example/EEPROM_Demo/Libraries/seekfree_libraries/common/common.h index 84c43ee..5b741c0 100644 --- a/Example/EEPROM_Demo/Libraries/seekfree_libraries/common/common.h +++ b/Example/EEPROM_Demo/Libraries/seekfree_libraries/common/common.h @@ -113,6 +113,12 @@ typedef enum //ö CAMERA_COLOR, //ͫ }CAMERA_TYPE_enum; +typedef enum //ģ +{ + WIRELESS_SI24R1 = 1, //ת + WIRELESS_CH9141, //ת +}WIRELESS_TYPE_enum; + #include #include #include "IfxCpu.h" @@ -120,6 +126,8 @@ typedef enum //ö extern CAMERA_TYPE_enum camera_type; //ͷͺ extern uint8 *camera_buffer_addr; //ͷַ +extern WIRELESS_TYPE_enum wireless_type; + extern IfxCpu_syncEvent g_cpuSyncEvent; void get_clk(void); diff --git a/Example/EEPROM_Demo/Libraries/seekfree_libraries/headfile.h b/Example/EEPROM_Demo/Libraries/seekfree_libraries/headfile.h index 404ee0a..b745302 100644 --- a/Example/EEPROM_Demo/Libraries/seekfree_libraries/headfile.h +++ b/Example/EEPROM_Demo/Libraries/seekfree_libraries/headfile.h @@ -65,6 +65,7 @@ #include "SEEKFREE_7725.h" #include "SEEKFREE_RDA5807.h" #include "SEEKFREE_7725_UART.h" +#include "SEEKFREE_BLUETOOTH_CH9141.h" #endif diff --git a/Example/EEPROM_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.c b/Example/EEPROM_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.c new file mode 100644 index 0000000..b4ec2df --- /dev/null +++ b/Example/EEPROM_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.c @@ -0,0 +1,509 @@ +/********************************************************************************************************************* + * COPYRIGHT NOTICE + * Copyright (c) 2021,ɿƼ + * All rights reserved. + * QQȺһȺ179029047() Ⱥ244861897 + * + * ݰȨɿƼУδҵ; + * ӭλʹò޸ʱ뱣ɿƼİȨ + * + * @file ɿƼתģ + * @company ɶɿƼ޹˾ + * @author ɿƼ(QQ3184284598) + * @version 鿴docversionļ 汾˵ + * @Software IAR 8.3 or MDK 5.33 + * @Taobao https://seekfree.taobao.com/ + * @date 2021-08-27 + * @note + ߶壺 + ------------------------------------ + ת Ƭ + RX 鿴SEEKFREE_BLUETOOTH_CH9141.hļеBLUETOOTH_CH9141_UART_TX궨 + TX 鿴SEEKFREE_BLUETOOTH_CH9141.hļеBLUETOOTH_CH9141_UART_RX궨 + RTS 鿴SEEKFREE_BLUETOOTH_CH9141.hļеBLUETOOTH_CH9141_RTS_PIN궨 + CTS + CMD ջ + ------------------------------------ + ********************************************************************************************************************/ +#include "zf_stm_systick.h" +#include "zf_gpio.h" +#include "zf_uart.h" +#include "zf_assert.h" +#include "SEEKFREE_BLUETOOTH_CH9141.h" + +uint8 uart_flag; +uint8 uart_data; + +vuint8 at_mode = 0; //0:͸ģʽ 1:ATģʽ 2:ģ鸴λ +vuint8 at_mode_num; //atģʽʱָʾݽյ +vuint8 at_mode_data[30]; //atĻ +vuint8 at_mode_cmd_flag; //OKӦճɹı־λ + +uint8 mac_address[17]; //macַ + + +uint8 bluetooth_ch9141_rx_buffer; + + +void bluetooth_ch9141_check_response(void); + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ жϻص +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note úISRļ 8жϳ򱻵 +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_uart_callback() +{ + while(uart_query(BLUETOOTH_CH9141_UART, &bluetooth_ch9141_rx_buffer)) + { + if(1 == at_mode) + { + //ATģʽ Ӧź ˴ifڴûҪĶ + at_mode_data[at_mode_num++] = bluetooth_ch9141_rx_buffer; + bluetooth_ch9141_check_response(); + } + else if(2 == at_mode) + { + //ģڸλ ˴ifڴûҪĶ + at_mode_num++; + } + else + { + //͸ģʽ ûڴ˴Ե͹Ķ + //ӵһֽںƬ˴ͨڴ˴ȡbluetooth_ch9141_rx_bufferȡ + + // ȡߴڵ λձ־ + uart_flag = 1; + uart_data = bluetooth_ch9141_rx_buffer; + } + + } +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģOKӦź +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note û +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_check_response(void) +{ + if(4 <= at_mode_num) + { + if(0 == strncmp("OK\r\n", (int8 *)&at_mode_data[at_mode_num-4], 4)) + { + at_mode_cmd_flag = 1; + } + } +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ鷢һûвȴӦź +// @param *str Ҫ͵ ַ +// @return void +// @since v1.0 +// Sample usage: +// @note û +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_send_at_command(const int8 *str) +{ + at_mode_num = 0; // + uart_putstr(BLUETOOTH_CH9141_UART, str); + uart_putstr(BLUETOOTH_CH9141_UART, "\r\n"); + + //ȴյӦź + while(!at_mode_cmd_flag); + at_mode_cmd_flag = 0; +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ鷢һвȴӦź +// @param *cmd Ҫ͵ +// @param *data Ҫ͵ +// @return void +// @since v1.0 +// Sample usage: +// @note û +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_send_at_command_parameter(const int8 *cmd, const int8 *data) +{ + at_mode_num = 0; // + uart_putstr(BLUETOOTH_CH9141_UART, "AT+"); + uart_putstr(BLUETOOTH_CH9141_UART, cmd); + uart_putstr(BLUETOOTH_CH9141_UART, "="); + uart_putstr(BLUETOOTH_CH9141_UART, data); + uart_putstr(BLUETOOTH_CH9141_UART, "\r\n"); + + //ȴյӦź + while(!at_mode_cmd_flag); + at_mode_cmd_flag = 0; +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģATģʽ +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_enter_at_mode(void) +{ + systick_delay_ms(STM0, 550); //ͽATģʽǰҪ֤ģ550msûнչκ + at_mode = 1; //ATģʽ + bluetooth_ch9141_send_at_command("AT..."); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ˳ATģʽ +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_exit_at_mode(void) +{ + bluetooth_ch9141_send_at_command("AT+EXIT"); + at_mode = 0; //͸ģʽ + systick_delay_ms(STM0, 300); //ȴɹATģʽ +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ鸴λ +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_reset(void) +{ + bluetooth_ch9141_send_at_command("AT+RESET"); + at_mode = 2; //ɹ + at_mode_num = 0; + while(7 > at_mode_num); //ȴģɸλ + at_mode = 0; //λ֮ģԶ͸ģʽ +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģȡMACַ +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note ô˺Ҫȵbluetooth_ch9141_enter_at_modeCMD ATģʽ +// Ҫرעbluetooth_ch9141_enter_at_modeڲ500msʱ +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_get_mac_address(void) +{ + bluetooth_ch9141_send_at_command("AT+MAC?"); + + //macַΪСθʽmac_address[0]macַλ + memcpy(mac_address, (uint8 *)at_mode_data, 17); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ÷͹ +// @param tx_power ÷͹ʣѡ鿴CH9141_TX_POWEER_enumöٳԱ +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_set_tx_power(CH9141_TX_POWEER_enum tx_power) +{ + int8 tx_power_data; + + tx_power_data = (uint8)tx_power + '0'; + bluetooth_ch9141_send_at_command_parameter("TPL", &tx_power_data); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģģʽ +// @param mode ģʽãѡ鿴CH9141_MODE_enumöٳԱ +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_set_mode(CH9141_MODE_enum mode) +{ + int8 mode_data; + + mode_data = (uint8)mode + '0'; + bluetooth_ch9141_send_at_command_parameter("BLEMODE", &mode_data); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģȡ״̬ +// @param mode ģʽãѡ鿴CH9141_MODE_enumöٳԱ +// @return CH9141_STATUS_enum ״̬Ϣ +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +CH9141_STATUS_enum bluetooth_ch9141_get_status(CH9141_MODE_enum mode) +{ + CH9141_STATUS_enum ch9141_status; + int8 mode_data; + + mode_data = (uint8)mode + '0'; + bluetooth_ch9141_send_at_command_parameter("BLEMODE", &mode_data); + + bluetooth_ch9141_send_at_command("AT+BLESTA?"); + + ch9141_status = (at_mode_data[0] - '0') * 10 + (at_mode_data[1] - '0'); + if(SLAVE_MODE == mode) + { + ch9141_status += SLAVE_NO_INIT; + } + + return ch9141_status; +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ豸 +// @param *str +// @return void +// @since v1.0 +// Sample usage: +// @note ƳȲܳ18ַ ֻΪӢ +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_set_name(const int8 *str) +{ + bluetooth_ch9141_send_at_command_parameter("NAME", str); + bluetooth_ch9141_send_at_command_parameter("PNAME", str); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ +// @param enable ʹ 0ʹ룬1ʹӱ豸 +// @param *password ַ Ϊ6ַ +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_set_password(uint8 enable, const int8 *password) +{ + if(0 == enable) + { + //ر + bluetooth_ch9141_send_at_command_parameter("PASEN", "OFF"); + } + else + { + //벢ʹ + bluetooth_ch9141_send_at_command_parameter("PASEN", "ON"); + bluetooth_ch9141_send_at_command_parameter("PASS", password); + } +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģָMACַ +// @param *mac_and_password Ҫӵ豸macַ +// @return void +// @since v1.0 +// Sample usage: +// @note bluetooth_ch9141_connect("58:B7:33:E4:C2:84,000000"); +// 58:B7:33:E4:C2:84Ϊmacַ ,Ϊָ 000000Ϊӻ +// ===================رע================== +// ʹֻ鿴macַʹñӵʱ뽫macһ +// ֻ鿴macַΪ61:62:63:64:65:66ʹñӵʱӦд +// bluetooth_ch9141_connect("66:65:64:63:62:61,000000"); +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_connect(const int8 *mac_and_password) +{ + bluetooth_ch9141_send_at_command_parameter("CONN", mac_and_password); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģĬӲãúúÿοԶ豸 +// @param *mac_and_password Ҫӵ豸macַ +// @return void +// @since v1.0 +// Sample usage: +// @note bluetooth_ch9141_default_connect("58:B7:33:E4:C2:84,000000"); +// 58:B7:33:E4:C2:84Ϊmacַ ,Ϊָ 000000Ϊӻ +// ===================رע================== +// ʹֻ鿴CH9141macַCH9141Ϊӻʹֻ +// ʹñӵʱ뽫macһ +// ֻ鿴macַΪ61:62:63:64:65:67ʹñӵʱӦд +// bluetooth_ch9141_default_connect("67:65:64:63:62:61,000000"); +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_default_connect(const int8 *mac_and_password) +{ + bluetooth_ch9141_send_at_command_parameter("CONADD", mac_and_password); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģȡrssi(źǿ) +// @param void +// @return int8 źǿ0-127 +// @since v1.0 +// Sample usage: +// @note ô˺Ҫȵbluetooth_ch9141_enter_at_modeCMD ATģʽ +// Ҫرעbluetooth_ch9141_enter_at_modeڲ500msʱ +//------------------------------------------------------------------------------------------------------------------- +int16 bluetooth_ch9141_get_rssi(void) +{ + uint8 i; + size_t length; + int16 rssi; + bluetooth_ch9141_send_at_command_parameter("RSSI", "ON,0"); + length = strlen((int8 *)at_mode_data); + length -= 12;//RSSI жλ + + rssi = 0; + for(i=0; i30) { - if(gpio_get(RTS_PIN)) - { - return len;//ģæ,ǰʹwhileȴ ʹúע͵whileȴ滻if - } - //while(gpio_get(RTS_PIN)); //RTSΪ͵ƽ +// if(gpio_get(RTS_PIN)) +// { +// return len;//ģæ,ǰʹwhileȴ ʹúע͵whileȴ滻if +// } + while(gpio_get(RTS_PIN)); //RTSΪ͵ƽ uart_putbuff(WIRELESS_UART,buff,30); buff += 30; //ַƫ len -= 30;// } - if(gpio_get(RTS_PIN)) - { - return len;//ģæ,ǰʹwhileȴ ʹúע͵whileȴ滻if - } - //while(gpio_get(RTS_PIN)); //RTSΪ͵ƽ +// if(gpio_get(RTS_PIN)) +// { +// return len;//ģæ,ǰʹwhileȴ ʹúע͵whileȴ滻if +// } + while(gpio_get(RTS_PIN)); //RTSΪ͵ƽ uart_putbuff(WIRELESS_UART,buff,len);// return 0; diff --git a/Example/EEPROM_Demo/Libraries/seekfree_peripheral/SEEKFREE_WIRELESS.h b/Example/EEPROM_Demo/Libraries/seekfree_peripheral/SEEKFREE_WIRELESS.h index 42c0832..d80339d 100644 --- a/Example/EEPROM_Demo/Libraries/seekfree_peripheral/SEEKFREE_WIRELESS.h +++ b/Example/EEPROM_Demo/Libraries/seekfree_peripheral/SEEKFREE_WIRELESS.h @@ -38,8 +38,26 @@ #define WIRELESS_UART_RX UART2_RX_P10_6 #define WIRELESS_UART_BAUD 115200 -#define RTS_PIN P10_2 //λ ָʾǰģǷԽ 0Լ 1Լ +// ------------------------------------ Զ ------------------------------------ +// ע1תģ汾V2.0µ޷Զʵġ +// ע2ԶRTSţῪʧܡ +// ע3ģԶʧܵĻԳԶϵ +// ԶĶ ע +// ԶĶ ע +// ԶĶ ע + +// 0رԶ +// 1Զ Զʵ޸WIRELESS_UART_BAUD֮ҪģãģԶΪӦIJ + +#define WIRELESS_AUTO_UART_BAUD 0 +// ------------------------------------ Զ ------------------------------------ + +#define RTS_PIN P10_2 //λ ָʾǰģǷԽ 0Լ 1Լ +#define WIRELESS_BUFFER_SIZE 16 + +extern uint8 wireless_send_buffer[WIRELESS_BUFFER_SIZE]; +extern uint32 wireless_rx_index; void wireless_uart_callback(void); void seekfree_wireless_init(void); diff --git a/Example/EEPROM_Demo/USER/isr.c b/Example/EEPROM_Demo/USER/isr.c index c55a012..16bff98 100644 --- a/Example/EEPROM_Demo/USER/isr.c +++ b/Example/EEPROM_Demo/USER/isr.c @@ -179,7 +179,20 @@ IFX_INTERRUPT(uart2_rx_isr, 0, UART2_RX_INT_PRIO) { enableInterrupts();//жǶ IfxAsclin_Asc_isrReceive(&uart2_handle); - wireless_uart_callback(); + switch(wireless_type) + { + case WIRELESS_SI24R1: + { + wireless_uart_callback(); + }break; + + case WIRELESS_CH9141: + { + bluetooth_ch9141_uart_callback(); + }break; + default:break; + } + } IFX_INTERRUPT(uart2_er_isr, 0, UART2_ER_INT_PRIO) { diff --git a/Example/EEPROM_Demo/删除临时文件.bat b/Example/EEPROM_Demo/删除临时文件.bat index 5323dd9..fa499b1 100644 --- a/Example/EEPROM_Demo/删除临时文件.bat +++ b/Example/EEPROM_Demo/删除临时文件.bat @@ -1,9 +1,6 @@ -rmdir .settings /s /q rmdir Debug /s /q del *.launch /s - -pause exit diff --git a/Example/Encoder_Demo/.cproject b/Example/Encoder_Demo/.cproject index c2cc55d..e8d9741 100644 --- a/Example/Encoder_Demo/.cproject +++ b/Example/Encoder_Demo/.cproject @@ -3,9 +3,9 @@ - + - + @@ -25,50 +25,76 @@ - + - + - + - + + + + + + @@ -355,9 +371,9 @@ - + - + @@ -377,43 +393,1895 @@ - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -431,13 +2299,37 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + @@ -459,20 +2351,6 @@ - - - - - - - - - - - - - - - + diff --git a/Example/Encoder_Demo/.project b/Example/Encoder_Demo/.project index 63a24e2..0853efe 100644 --- a/Example/Encoder_Demo/.project +++ b/Example/Encoder_Demo/.project @@ -5,6 +5,18 @@ + + com.infineon.aurix.buildsystem.builders.booster + full,incremental, + + + + + com.infineon.aurix.buildsystem.builders.autodiscovery + full,incremental, + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder clean,full,incremental, diff --git a/Example/Encoder_Demo/.settings/com.infineon.aurix.buildsystem.prefs b/Example/Encoder_Demo/.settings/com.infineon.aurix.buildsystem.prefs new file mode 100644 index 0000000..be61bc1 --- /dev/null +++ b/Example/Encoder_Demo/.settings/com.infineon.aurix.buildsystem.prefs @@ -0,0 +1,10 @@ +AURIX-LIBRARY-PATH=Libraries/iLLD\#Libraries/Infra\#Libraries/Service +DEVICE-ID=TC26B +DEVICE-ID-FULL=TC26xD_B-Step +ILLD-SET=full +IncludesAutodiscovery=true +LIBRARIES-ROOT-PATH=Libraries +NEVER-EXCLUDE-FROM-BUILD=/Libraries/iLLD/TC26B/Tricore/Cpu/CStart\#/Libraries/iLLD/TC26B/Tricore/Cpu/Trap\#/Configurations\#/Configurations/Debug +PROJECT-VERSION=1.0 +aurixDevice=TC26xD_B-Step +eclipse.preferences.version=1 diff --git a/Example/Encoder_Demo/Libraries/doc/version.txt b/Example/Encoder_Demo/Libraries/doc/version.txt index ab79909..11ab82e 100644 --- a/Example/Encoder_Demo/Libraries/doc/version.txt +++ b/Example/Encoder_Demo/Libraries/doc/version.txt @@ -1,3 +1,13 @@ +V1.2.0 + CH9141תģ + ͵öٱ + ޸ ɾʱļ.bat ִԶرմ + ޸ ɾʱļ.bat ɾ°汾ļ + ޸ĹĿļ֧°汾 + +V1.1.10 + ޸ͨ#pragma section all "cpux_dsram"ָλʧЧ + V1.1.9 ڵķbuffӵ128ֽ diff --git a/Example/Encoder_Demo/Libraries/seekfree_libraries/common/common.c b/Example/Encoder_Demo/Libraries/seekfree_libraries/common/common.c index 0b9931e..7620ce6 100644 --- a/Example/Encoder_Demo/Libraries/seekfree_libraries/common/common.c +++ b/Example/Encoder_Demo/Libraries/seekfree_libraries/common/common.c @@ -27,6 +27,8 @@ CAMERA_TYPE_enum camera_type; //ͷͺ uint8 *camera_buffer_addr; //ͷַ +WIRELESS_TYPE_enum wireless_type;//ת + IFX_ALIGN(4) IfxCpu_syncEvent g_cpuSyncEvent = 0;//¼ͬ App_Cpu0 g_AppCpu0; //ƵϢ diff --git a/Example/Encoder_Demo/Libraries/seekfree_libraries/common/common.h b/Example/Encoder_Demo/Libraries/seekfree_libraries/common/common.h index 84c43ee..5b741c0 100644 --- a/Example/Encoder_Demo/Libraries/seekfree_libraries/common/common.h +++ b/Example/Encoder_Demo/Libraries/seekfree_libraries/common/common.h @@ -113,6 +113,12 @@ typedef enum //ö CAMERA_COLOR, //ͫ }CAMERA_TYPE_enum; +typedef enum //ģ +{ + WIRELESS_SI24R1 = 1, //ת + WIRELESS_CH9141, //ת +}WIRELESS_TYPE_enum; + #include #include #include "IfxCpu.h" @@ -120,6 +126,8 @@ typedef enum //ö extern CAMERA_TYPE_enum camera_type; //ͷͺ extern uint8 *camera_buffer_addr; //ͷַ +extern WIRELESS_TYPE_enum wireless_type; + extern IfxCpu_syncEvent g_cpuSyncEvent; void get_clk(void); diff --git a/Example/Encoder_Demo/Libraries/seekfree_libraries/headfile.h b/Example/Encoder_Demo/Libraries/seekfree_libraries/headfile.h index 404ee0a..b745302 100644 --- a/Example/Encoder_Demo/Libraries/seekfree_libraries/headfile.h +++ b/Example/Encoder_Demo/Libraries/seekfree_libraries/headfile.h @@ -65,6 +65,7 @@ #include "SEEKFREE_7725.h" #include "SEEKFREE_RDA5807.h" #include "SEEKFREE_7725_UART.h" +#include "SEEKFREE_BLUETOOTH_CH9141.h" #endif diff --git a/Example/Encoder_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.c b/Example/Encoder_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.c new file mode 100644 index 0000000..b4ec2df --- /dev/null +++ b/Example/Encoder_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.c @@ -0,0 +1,509 @@ +/********************************************************************************************************************* + * COPYRIGHT NOTICE + * Copyright (c) 2021,ɿƼ + * All rights reserved. + * QQȺһȺ179029047() Ⱥ244861897 + * + * ݰȨɿƼУδҵ; + * ӭλʹò޸ʱ뱣ɿƼİȨ + * + * @file ɿƼתģ + * @company ɶɿƼ޹˾ + * @author ɿƼ(QQ3184284598) + * @version 鿴docversionļ 汾˵ + * @Software IAR 8.3 or MDK 5.33 + * @Taobao https://seekfree.taobao.com/ + * @date 2021-08-27 + * @note + ߶壺 + ------------------------------------ + ת Ƭ + RX 鿴SEEKFREE_BLUETOOTH_CH9141.hļеBLUETOOTH_CH9141_UART_TX궨 + TX 鿴SEEKFREE_BLUETOOTH_CH9141.hļеBLUETOOTH_CH9141_UART_RX궨 + RTS 鿴SEEKFREE_BLUETOOTH_CH9141.hļеBLUETOOTH_CH9141_RTS_PIN궨 + CTS + CMD ջ + ------------------------------------ + ********************************************************************************************************************/ +#include "zf_stm_systick.h" +#include "zf_gpio.h" +#include "zf_uart.h" +#include "zf_assert.h" +#include "SEEKFREE_BLUETOOTH_CH9141.h" + +uint8 uart_flag; +uint8 uart_data; + +vuint8 at_mode = 0; //0:͸ģʽ 1:ATģʽ 2:ģ鸴λ +vuint8 at_mode_num; //atģʽʱָʾݽյ +vuint8 at_mode_data[30]; //atĻ +vuint8 at_mode_cmd_flag; //OKӦճɹı־λ + +uint8 mac_address[17]; //macַ + + +uint8 bluetooth_ch9141_rx_buffer; + + +void bluetooth_ch9141_check_response(void); + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ жϻص +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note úISRļ 8жϳ򱻵 +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_uart_callback() +{ + while(uart_query(BLUETOOTH_CH9141_UART, &bluetooth_ch9141_rx_buffer)) + { + if(1 == at_mode) + { + //ATģʽ Ӧź ˴ifڴûҪĶ + at_mode_data[at_mode_num++] = bluetooth_ch9141_rx_buffer; + bluetooth_ch9141_check_response(); + } + else if(2 == at_mode) + { + //ģڸλ ˴ifڴûҪĶ + at_mode_num++; + } + else + { + //͸ģʽ ûڴ˴Ե͹Ķ + //ӵһֽںƬ˴ͨڴ˴ȡbluetooth_ch9141_rx_bufferȡ + + // ȡߴڵ λձ־ + uart_flag = 1; + uart_data = bluetooth_ch9141_rx_buffer; + } + + } +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģOKӦź +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note û +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_check_response(void) +{ + if(4 <= at_mode_num) + { + if(0 == strncmp("OK\r\n", (int8 *)&at_mode_data[at_mode_num-4], 4)) + { + at_mode_cmd_flag = 1; + } + } +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ鷢һûвȴӦź +// @param *str Ҫ͵ ַ +// @return void +// @since v1.0 +// Sample usage: +// @note û +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_send_at_command(const int8 *str) +{ + at_mode_num = 0; // + uart_putstr(BLUETOOTH_CH9141_UART, str); + uart_putstr(BLUETOOTH_CH9141_UART, "\r\n"); + + //ȴյӦź + while(!at_mode_cmd_flag); + at_mode_cmd_flag = 0; +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ鷢һвȴӦź +// @param *cmd Ҫ͵ +// @param *data Ҫ͵ +// @return void +// @since v1.0 +// Sample usage: +// @note û +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_send_at_command_parameter(const int8 *cmd, const int8 *data) +{ + at_mode_num = 0; // + uart_putstr(BLUETOOTH_CH9141_UART, "AT+"); + uart_putstr(BLUETOOTH_CH9141_UART, cmd); + uart_putstr(BLUETOOTH_CH9141_UART, "="); + uart_putstr(BLUETOOTH_CH9141_UART, data); + uart_putstr(BLUETOOTH_CH9141_UART, "\r\n"); + + //ȴյӦź + while(!at_mode_cmd_flag); + at_mode_cmd_flag = 0; +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģATģʽ +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_enter_at_mode(void) +{ + systick_delay_ms(STM0, 550); //ͽATģʽǰҪ֤ģ550msûнչκ + at_mode = 1; //ATģʽ + bluetooth_ch9141_send_at_command("AT..."); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ˳ATģʽ +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_exit_at_mode(void) +{ + bluetooth_ch9141_send_at_command("AT+EXIT"); + at_mode = 0; //͸ģʽ + systick_delay_ms(STM0, 300); //ȴɹATģʽ +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ鸴λ +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_reset(void) +{ + bluetooth_ch9141_send_at_command("AT+RESET"); + at_mode = 2; //ɹ + at_mode_num = 0; + while(7 > at_mode_num); //ȴģɸλ + at_mode = 0; //λ֮ģԶ͸ģʽ +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģȡMACַ +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note ô˺Ҫȵbluetooth_ch9141_enter_at_modeCMD ATģʽ +// Ҫرעbluetooth_ch9141_enter_at_modeڲ500msʱ +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_get_mac_address(void) +{ + bluetooth_ch9141_send_at_command("AT+MAC?"); + + //macַΪСθʽmac_address[0]macַλ + memcpy(mac_address, (uint8 *)at_mode_data, 17); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ÷͹ +// @param tx_power ÷͹ʣѡ鿴CH9141_TX_POWEER_enumöٳԱ +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_set_tx_power(CH9141_TX_POWEER_enum tx_power) +{ + int8 tx_power_data; + + tx_power_data = (uint8)tx_power + '0'; + bluetooth_ch9141_send_at_command_parameter("TPL", &tx_power_data); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģģʽ +// @param mode ģʽãѡ鿴CH9141_MODE_enumöٳԱ +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_set_mode(CH9141_MODE_enum mode) +{ + int8 mode_data; + + mode_data = (uint8)mode + '0'; + bluetooth_ch9141_send_at_command_parameter("BLEMODE", &mode_data); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģȡ״̬ +// @param mode ģʽãѡ鿴CH9141_MODE_enumöٳԱ +// @return CH9141_STATUS_enum ״̬Ϣ +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +CH9141_STATUS_enum bluetooth_ch9141_get_status(CH9141_MODE_enum mode) +{ + CH9141_STATUS_enum ch9141_status; + int8 mode_data; + + mode_data = (uint8)mode + '0'; + bluetooth_ch9141_send_at_command_parameter("BLEMODE", &mode_data); + + bluetooth_ch9141_send_at_command("AT+BLESTA?"); + + ch9141_status = (at_mode_data[0] - '0') * 10 + (at_mode_data[1] - '0'); + if(SLAVE_MODE == mode) + { + ch9141_status += SLAVE_NO_INIT; + } + + return ch9141_status; +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ豸 +// @param *str +// @return void +// @since v1.0 +// Sample usage: +// @note ƳȲܳ18ַ ֻΪӢ +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_set_name(const int8 *str) +{ + bluetooth_ch9141_send_at_command_parameter("NAME", str); + bluetooth_ch9141_send_at_command_parameter("PNAME", str); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ +// @param enable ʹ 0ʹ룬1ʹӱ豸 +// @param *password ַ Ϊ6ַ +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_set_password(uint8 enable, const int8 *password) +{ + if(0 == enable) + { + //ر + bluetooth_ch9141_send_at_command_parameter("PASEN", "OFF"); + } + else + { + //벢ʹ + bluetooth_ch9141_send_at_command_parameter("PASEN", "ON"); + bluetooth_ch9141_send_at_command_parameter("PASS", password); + } +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģָMACַ +// @param *mac_and_password Ҫӵ豸macַ +// @return void +// @since v1.0 +// Sample usage: +// @note bluetooth_ch9141_connect("58:B7:33:E4:C2:84,000000"); +// 58:B7:33:E4:C2:84Ϊmacַ ,Ϊָ 000000Ϊӻ +// ===================رע================== +// ʹֻ鿴macַʹñӵʱ뽫macһ +// ֻ鿴macַΪ61:62:63:64:65:66ʹñӵʱӦд +// bluetooth_ch9141_connect("66:65:64:63:62:61,000000"); +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_connect(const int8 *mac_and_password) +{ + bluetooth_ch9141_send_at_command_parameter("CONN", mac_and_password); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģĬӲãúúÿοԶ豸 +// @param *mac_and_password Ҫӵ豸macַ +// @return void +// @since v1.0 +// Sample usage: +// @note bluetooth_ch9141_default_connect("58:B7:33:E4:C2:84,000000"); +// 58:B7:33:E4:C2:84Ϊmacַ ,Ϊָ 000000Ϊӻ +// ===================رע================== +// ʹֻ鿴CH9141macַCH9141Ϊӻʹֻ +// ʹñӵʱ뽫macһ +// ֻ鿴macַΪ61:62:63:64:65:67ʹñӵʱӦд +// bluetooth_ch9141_default_connect("67:65:64:63:62:61,000000"); +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_default_connect(const int8 *mac_and_password) +{ + bluetooth_ch9141_send_at_command_parameter("CONADD", mac_and_password); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģȡrssi(źǿ) +// @param void +// @return int8 źǿ0-127 +// @since v1.0 +// Sample usage: +// @note ô˺Ҫȵbluetooth_ch9141_enter_at_modeCMD ATģʽ +// Ҫرעbluetooth_ch9141_enter_at_modeڲ500msʱ +//------------------------------------------------------------------------------------------------------------------- +int16 bluetooth_ch9141_get_rssi(void) +{ + uint8 i; + size_t length; + int16 rssi; + bluetooth_ch9141_send_at_command_parameter("RSSI", "ON,0"); + length = strlen((int8 *)at_mode_data); + length -= 12;//RSSI жλ + + rssi = 0; + for(i=0; i30) { - if(gpio_get(RTS_PIN)) - { - return len;//ģæ,ǰʹwhileȴ ʹúע͵whileȴ滻if - } - //while(gpio_get(RTS_PIN)); //RTSΪ͵ƽ +// if(gpio_get(RTS_PIN)) +// { +// return len;//ģæ,ǰʹwhileȴ ʹúע͵whileȴ滻if +// } + while(gpio_get(RTS_PIN)); //RTSΪ͵ƽ uart_putbuff(WIRELESS_UART,buff,30); buff += 30; //ַƫ len -= 30;// } - if(gpio_get(RTS_PIN)) - { - return len;//ģæ,ǰʹwhileȴ ʹúע͵whileȴ滻if - } - //while(gpio_get(RTS_PIN)); //RTSΪ͵ƽ +// if(gpio_get(RTS_PIN)) +// { +// return len;//ģæ,ǰʹwhileȴ ʹúע͵whileȴ滻if +// } + while(gpio_get(RTS_PIN)); //RTSΪ͵ƽ uart_putbuff(WIRELESS_UART,buff,len);// return 0; diff --git a/Example/Encoder_Demo/Libraries/seekfree_peripheral/SEEKFREE_WIRELESS.h b/Example/Encoder_Demo/Libraries/seekfree_peripheral/SEEKFREE_WIRELESS.h index 42c0832..d80339d 100644 --- a/Example/Encoder_Demo/Libraries/seekfree_peripheral/SEEKFREE_WIRELESS.h +++ b/Example/Encoder_Demo/Libraries/seekfree_peripheral/SEEKFREE_WIRELESS.h @@ -38,8 +38,26 @@ #define WIRELESS_UART_RX UART2_RX_P10_6 #define WIRELESS_UART_BAUD 115200 -#define RTS_PIN P10_2 //λ ָʾǰģǷԽ 0Լ 1Լ +// ------------------------------------ Զ ------------------------------------ +// ע1תģ汾V2.0µ޷Զʵġ +// ע2ԶRTSţῪʧܡ +// ע3ģԶʧܵĻԳԶϵ +// ԶĶ ע +// ԶĶ ע +// ԶĶ ע + +// 0رԶ +// 1Զ Զʵ޸WIRELESS_UART_BAUD֮ҪģãģԶΪӦIJ + +#define WIRELESS_AUTO_UART_BAUD 0 +// ------------------------------------ Զ ------------------------------------ + +#define RTS_PIN P10_2 //λ ָʾǰģǷԽ 0Լ 1Լ +#define WIRELESS_BUFFER_SIZE 16 + +extern uint8 wireless_send_buffer[WIRELESS_BUFFER_SIZE]; +extern uint32 wireless_rx_index; void wireless_uart_callback(void); void seekfree_wireless_init(void); diff --git a/Example/Encoder_Demo/USER/isr.c b/Example/Encoder_Demo/USER/isr.c index c55a012..16bff98 100644 --- a/Example/Encoder_Demo/USER/isr.c +++ b/Example/Encoder_Demo/USER/isr.c @@ -179,7 +179,20 @@ IFX_INTERRUPT(uart2_rx_isr, 0, UART2_RX_INT_PRIO) { enableInterrupts();//жǶ IfxAsclin_Asc_isrReceive(&uart2_handle); - wireless_uart_callback(); + switch(wireless_type) + { + case WIRELESS_SI24R1: + { + wireless_uart_callback(); + }break; + + case WIRELESS_CH9141: + { + bluetooth_ch9141_uart_callback(); + }break; + default:break; + } + } IFX_INTERRUPT(uart2_er_isr, 0, UART2_ER_INT_PRIO) { diff --git a/Example/Encoder_Demo/删除临时文件.bat b/Example/Encoder_Demo/删除临时文件.bat index 5323dd9..fa499b1 100644 --- a/Example/Encoder_Demo/删除临时文件.bat +++ b/Example/Encoder_Demo/删除临时文件.bat @@ -1,9 +1,6 @@ -rmdir .settings /s /q rmdir Debug /s /q del *.launch /s - -pause exit diff --git a/Example/FFT_Demo/.cproject b/Example/FFT_Demo/.cproject index dd69b8f..07e693c 100644 --- a/Example/FFT_Demo/.cproject +++ b/Example/FFT_Demo/.cproject @@ -3,9 +3,9 @@ - + - + @@ -25,50 +25,76 @@ - + - + - + - + + + + + + @@ -355,9 +371,9 @@ - + - + @@ -377,43 +393,1895 @@ - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -431,13 +2299,37 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + @@ -458,21 +2350,5 @@ - - - - - - - - - - - - - - - - diff --git a/Example/FFT_Demo/.project b/Example/FFT_Demo/.project index ff99e6c..d7a9f25 100644 --- a/Example/FFT_Demo/.project +++ b/Example/FFT_Demo/.project @@ -5,6 +5,18 @@ + + com.infineon.aurix.buildsystem.builders.booster + full,incremental, + + + + + com.infineon.aurix.buildsystem.builders.autodiscovery + full,incremental, + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder clean,full,incremental, diff --git a/Example/FFT_Demo/.settings/com.infineon.aurix.buildsystem.prefs b/Example/FFT_Demo/.settings/com.infineon.aurix.buildsystem.prefs new file mode 100644 index 0000000..be61bc1 --- /dev/null +++ b/Example/FFT_Demo/.settings/com.infineon.aurix.buildsystem.prefs @@ -0,0 +1,10 @@ +AURIX-LIBRARY-PATH=Libraries/iLLD\#Libraries/Infra\#Libraries/Service +DEVICE-ID=TC26B +DEVICE-ID-FULL=TC26xD_B-Step +ILLD-SET=full +IncludesAutodiscovery=true +LIBRARIES-ROOT-PATH=Libraries +NEVER-EXCLUDE-FROM-BUILD=/Libraries/iLLD/TC26B/Tricore/Cpu/CStart\#/Libraries/iLLD/TC26B/Tricore/Cpu/Trap\#/Configurations\#/Configurations/Debug +PROJECT-VERSION=1.0 +aurixDevice=TC26xD_B-Step +eclipse.preferences.version=1 diff --git a/Example/FFT_Demo/Libraries/doc/version.txt b/Example/FFT_Demo/Libraries/doc/version.txt index ab79909..11ab82e 100644 --- a/Example/FFT_Demo/Libraries/doc/version.txt +++ b/Example/FFT_Demo/Libraries/doc/version.txt @@ -1,3 +1,13 @@ +V1.2.0 + CH9141תģ + ͵öٱ + ޸ ɾʱļ.bat ִԶرմ + ޸ ɾʱļ.bat ɾ°汾ļ + ޸ĹĿļ֧°汾 + +V1.1.10 + ޸ͨ#pragma section all "cpux_dsram"ָλʧЧ + V1.1.9 ڵķbuffӵ128ֽ diff --git a/Example/FFT_Demo/Libraries/seekfree_libraries/common/common.c b/Example/FFT_Demo/Libraries/seekfree_libraries/common/common.c index 0b9931e..7620ce6 100644 --- a/Example/FFT_Demo/Libraries/seekfree_libraries/common/common.c +++ b/Example/FFT_Demo/Libraries/seekfree_libraries/common/common.c @@ -27,6 +27,8 @@ CAMERA_TYPE_enum camera_type; //ͷͺ uint8 *camera_buffer_addr; //ͷַ +WIRELESS_TYPE_enum wireless_type;//ת + IFX_ALIGN(4) IfxCpu_syncEvent g_cpuSyncEvent = 0;//¼ͬ App_Cpu0 g_AppCpu0; //ƵϢ diff --git a/Example/FFT_Demo/Libraries/seekfree_libraries/common/common.h b/Example/FFT_Demo/Libraries/seekfree_libraries/common/common.h index 84c43ee..5b741c0 100644 --- a/Example/FFT_Demo/Libraries/seekfree_libraries/common/common.h +++ b/Example/FFT_Demo/Libraries/seekfree_libraries/common/common.h @@ -113,6 +113,12 @@ typedef enum //ö CAMERA_COLOR, //ͫ }CAMERA_TYPE_enum; +typedef enum //ģ +{ + WIRELESS_SI24R1 = 1, //ת + WIRELESS_CH9141, //ת +}WIRELESS_TYPE_enum; + #include #include #include "IfxCpu.h" @@ -120,6 +126,8 @@ typedef enum //ö extern CAMERA_TYPE_enum camera_type; //ͷͺ extern uint8 *camera_buffer_addr; //ͷַ +extern WIRELESS_TYPE_enum wireless_type; + extern IfxCpu_syncEvent g_cpuSyncEvent; void get_clk(void); diff --git a/Example/FFT_Demo/Libraries/seekfree_libraries/headfile.h b/Example/FFT_Demo/Libraries/seekfree_libraries/headfile.h index 404ee0a..b745302 100644 --- a/Example/FFT_Demo/Libraries/seekfree_libraries/headfile.h +++ b/Example/FFT_Demo/Libraries/seekfree_libraries/headfile.h @@ -65,6 +65,7 @@ #include "SEEKFREE_7725.h" #include "SEEKFREE_RDA5807.h" #include "SEEKFREE_7725_UART.h" +#include "SEEKFREE_BLUETOOTH_CH9141.h" #endif diff --git a/Example/FFT_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.c b/Example/FFT_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.c new file mode 100644 index 0000000..b4ec2df --- /dev/null +++ b/Example/FFT_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.c @@ -0,0 +1,509 @@ +/********************************************************************************************************************* + * COPYRIGHT NOTICE + * Copyright (c) 2021,ɿƼ + * All rights reserved. + * QQȺһȺ179029047() Ⱥ244861897 + * + * ݰȨɿƼУδҵ; + * ӭλʹò޸ʱ뱣ɿƼİȨ + * + * @file ɿƼתģ + * @company ɶɿƼ޹˾ + * @author ɿƼ(QQ3184284598) + * @version 鿴docversionļ 汾˵ + * @Software IAR 8.3 or MDK 5.33 + * @Taobao https://seekfree.taobao.com/ + * @date 2021-08-27 + * @note + ߶壺 + ------------------------------------ + ת Ƭ + RX 鿴SEEKFREE_BLUETOOTH_CH9141.hļеBLUETOOTH_CH9141_UART_TX궨 + TX 鿴SEEKFREE_BLUETOOTH_CH9141.hļеBLUETOOTH_CH9141_UART_RX궨 + RTS 鿴SEEKFREE_BLUETOOTH_CH9141.hļеBLUETOOTH_CH9141_RTS_PIN궨 + CTS + CMD ջ + ------------------------------------ + ********************************************************************************************************************/ +#include "zf_stm_systick.h" +#include "zf_gpio.h" +#include "zf_uart.h" +#include "zf_assert.h" +#include "SEEKFREE_BLUETOOTH_CH9141.h" + +uint8 uart_flag; +uint8 uart_data; + +vuint8 at_mode = 0; //0:͸ģʽ 1:ATģʽ 2:ģ鸴λ +vuint8 at_mode_num; //atģʽʱָʾݽյ +vuint8 at_mode_data[30]; //atĻ +vuint8 at_mode_cmd_flag; //OKӦճɹı־λ + +uint8 mac_address[17]; //macַ + + +uint8 bluetooth_ch9141_rx_buffer; + + +void bluetooth_ch9141_check_response(void); + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ жϻص +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note úISRļ 8жϳ򱻵 +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_uart_callback() +{ + while(uart_query(BLUETOOTH_CH9141_UART, &bluetooth_ch9141_rx_buffer)) + { + if(1 == at_mode) + { + //ATģʽ Ӧź ˴ifڴûҪĶ + at_mode_data[at_mode_num++] = bluetooth_ch9141_rx_buffer; + bluetooth_ch9141_check_response(); + } + else if(2 == at_mode) + { + //ģڸλ ˴ifڴûҪĶ + at_mode_num++; + } + else + { + //͸ģʽ ûڴ˴Ե͹Ķ + //ӵһֽںƬ˴ͨڴ˴ȡbluetooth_ch9141_rx_bufferȡ + + // ȡߴڵ λձ־ + uart_flag = 1; + uart_data = bluetooth_ch9141_rx_buffer; + } + + } +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģOKӦź +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note û +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_check_response(void) +{ + if(4 <= at_mode_num) + { + if(0 == strncmp("OK\r\n", (int8 *)&at_mode_data[at_mode_num-4], 4)) + { + at_mode_cmd_flag = 1; + } + } +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ鷢һûвȴӦź +// @param *str Ҫ͵ ַ +// @return void +// @since v1.0 +// Sample usage: +// @note û +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_send_at_command(const int8 *str) +{ + at_mode_num = 0; // + uart_putstr(BLUETOOTH_CH9141_UART, str); + uart_putstr(BLUETOOTH_CH9141_UART, "\r\n"); + + //ȴյӦź + while(!at_mode_cmd_flag); + at_mode_cmd_flag = 0; +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ鷢һвȴӦź +// @param *cmd Ҫ͵ +// @param *data Ҫ͵ +// @return void +// @since v1.0 +// Sample usage: +// @note û +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_send_at_command_parameter(const int8 *cmd, const int8 *data) +{ + at_mode_num = 0; // + uart_putstr(BLUETOOTH_CH9141_UART, "AT+"); + uart_putstr(BLUETOOTH_CH9141_UART, cmd); + uart_putstr(BLUETOOTH_CH9141_UART, "="); + uart_putstr(BLUETOOTH_CH9141_UART, data); + uart_putstr(BLUETOOTH_CH9141_UART, "\r\n"); + + //ȴյӦź + while(!at_mode_cmd_flag); + at_mode_cmd_flag = 0; +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģATģʽ +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_enter_at_mode(void) +{ + systick_delay_ms(STM0, 550); //ͽATģʽǰҪ֤ģ550msûнչκ + at_mode = 1; //ATģʽ + bluetooth_ch9141_send_at_command("AT..."); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ˳ATģʽ +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_exit_at_mode(void) +{ + bluetooth_ch9141_send_at_command("AT+EXIT"); + at_mode = 0; //͸ģʽ + systick_delay_ms(STM0, 300); //ȴɹATģʽ +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ鸴λ +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_reset(void) +{ + bluetooth_ch9141_send_at_command("AT+RESET"); + at_mode = 2; //ɹ + at_mode_num = 0; + while(7 > at_mode_num); //ȴģɸλ + at_mode = 0; //λ֮ģԶ͸ģʽ +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģȡMACַ +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note ô˺Ҫȵbluetooth_ch9141_enter_at_modeCMD ATģʽ +// Ҫرעbluetooth_ch9141_enter_at_modeڲ500msʱ +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_get_mac_address(void) +{ + bluetooth_ch9141_send_at_command("AT+MAC?"); + + //macַΪСθʽmac_address[0]macַλ + memcpy(mac_address, (uint8 *)at_mode_data, 17); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ÷͹ +// @param tx_power ÷͹ʣѡ鿴CH9141_TX_POWEER_enumöٳԱ +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_set_tx_power(CH9141_TX_POWEER_enum tx_power) +{ + int8 tx_power_data; + + tx_power_data = (uint8)tx_power + '0'; + bluetooth_ch9141_send_at_command_parameter("TPL", &tx_power_data); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģģʽ +// @param mode ģʽãѡ鿴CH9141_MODE_enumöٳԱ +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_set_mode(CH9141_MODE_enum mode) +{ + int8 mode_data; + + mode_data = (uint8)mode + '0'; + bluetooth_ch9141_send_at_command_parameter("BLEMODE", &mode_data); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģȡ״̬ +// @param mode ģʽãѡ鿴CH9141_MODE_enumöٳԱ +// @return CH9141_STATUS_enum ״̬Ϣ +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +CH9141_STATUS_enum bluetooth_ch9141_get_status(CH9141_MODE_enum mode) +{ + CH9141_STATUS_enum ch9141_status; + int8 mode_data; + + mode_data = (uint8)mode + '0'; + bluetooth_ch9141_send_at_command_parameter("BLEMODE", &mode_data); + + bluetooth_ch9141_send_at_command("AT+BLESTA?"); + + ch9141_status = (at_mode_data[0] - '0') * 10 + (at_mode_data[1] - '0'); + if(SLAVE_MODE == mode) + { + ch9141_status += SLAVE_NO_INIT; + } + + return ch9141_status; +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ豸 +// @param *str +// @return void +// @since v1.0 +// Sample usage: +// @note ƳȲܳ18ַ ֻΪӢ +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_set_name(const int8 *str) +{ + bluetooth_ch9141_send_at_command_parameter("NAME", str); + bluetooth_ch9141_send_at_command_parameter("PNAME", str); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ +// @param enable ʹ 0ʹ룬1ʹӱ豸 +// @param *password ַ Ϊ6ַ +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_set_password(uint8 enable, const int8 *password) +{ + if(0 == enable) + { + //ر + bluetooth_ch9141_send_at_command_parameter("PASEN", "OFF"); + } + else + { + //벢ʹ + bluetooth_ch9141_send_at_command_parameter("PASEN", "ON"); + bluetooth_ch9141_send_at_command_parameter("PASS", password); + } +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģָMACַ +// @param *mac_and_password Ҫӵ豸macַ +// @return void +// @since v1.0 +// Sample usage: +// @note bluetooth_ch9141_connect("58:B7:33:E4:C2:84,000000"); +// 58:B7:33:E4:C2:84Ϊmacַ ,Ϊָ 000000Ϊӻ +// ===================رע================== +// ʹֻ鿴macַʹñӵʱ뽫macһ +// ֻ鿴macַΪ61:62:63:64:65:66ʹñӵʱӦд +// bluetooth_ch9141_connect("66:65:64:63:62:61,000000"); +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_connect(const int8 *mac_and_password) +{ + bluetooth_ch9141_send_at_command_parameter("CONN", mac_and_password); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģĬӲãúúÿοԶ豸 +// @param *mac_and_password Ҫӵ豸macַ +// @return void +// @since v1.0 +// Sample usage: +// @note bluetooth_ch9141_default_connect("58:B7:33:E4:C2:84,000000"); +// 58:B7:33:E4:C2:84Ϊmacַ ,Ϊָ 000000Ϊӻ +// ===================رע================== +// ʹֻ鿴CH9141macַCH9141Ϊӻʹֻ +// ʹñӵʱ뽫macһ +// ֻ鿴macַΪ61:62:63:64:65:67ʹñӵʱӦд +// bluetooth_ch9141_default_connect("67:65:64:63:62:61,000000"); +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_default_connect(const int8 *mac_and_password) +{ + bluetooth_ch9141_send_at_command_parameter("CONADD", mac_and_password); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģȡrssi(źǿ) +// @param void +// @return int8 źǿ0-127 +// @since v1.0 +// Sample usage: +// @note ô˺Ҫȵbluetooth_ch9141_enter_at_modeCMD ATģʽ +// Ҫرעbluetooth_ch9141_enter_at_modeڲ500msʱ +//------------------------------------------------------------------------------------------------------------------- +int16 bluetooth_ch9141_get_rssi(void) +{ + uint8 i; + size_t length; + int16 rssi; + bluetooth_ch9141_send_at_command_parameter("RSSI", "ON,0"); + length = strlen((int8 *)at_mode_data); + length -= 12;//RSSI жλ + + rssi = 0; + for(i=0; i30) { - if(gpio_get(RTS_PIN)) - { - return len;//ģæ,ǰʹwhileȴ ʹúע͵whileȴ滻if - } - //while(gpio_get(RTS_PIN)); //RTSΪ͵ƽ +// if(gpio_get(RTS_PIN)) +// { +// return len;//ģæ,ǰʹwhileȴ ʹúע͵whileȴ滻if +// } + while(gpio_get(RTS_PIN)); //RTSΪ͵ƽ uart_putbuff(WIRELESS_UART,buff,30); buff += 30; //ַƫ len -= 30;// } - if(gpio_get(RTS_PIN)) - { - return len;//ģæ,ǰʹwhileȴ ʹúע͵whileȴ滻if - } - //while(gpio_get(RTS_PIN)); //RTSΪ͵ƽ +// if(gpio_get(RTS_PIN)) +// { +// return len;//ģæ,ǰʹwhileȴ ʹúע͵whileȴ滻if +// } + while(gpio_get(RTS_PIN)); //RTSΪ͵ƽ uart_putbuff(WIRELESS_UART,buff,len);// return 0; diff --git a/Example/FFT_Demo/Libraries/seekfree_peripheral/SEEKFREE_WIRELESS.h b/Example/FFT_Demo/Libraries/seekfree_peripheral/SEEKFREE_WIRELESS.h index 42c0832..d80339d 100644 --- a/Example/FFT_Demo/Libraries/seekfree_peripheral/SEEKFREE_WIRELESS.h +++ b/Example/FFT_Demo/Libraries/seekfree_peripheral/SEEKFREE_WIRELESS.h @@ -38,8 +38,26 @@ #define WIRELESS_UART_RX UART2_RX_P10_6 #define WIRELESS_UART_BAUD 115200 -#define RTS_PIN P10_2 //λ ָʾǰģǷԽ 0Լ 1Լ +// ------------------------------------ Զ ------------------------------------ +// ע1תģ汾V2.0µ޷Զʵġ +// ע2ԶRTSţῪʧܡ +// ע3ģԶʧܵĻԳԶϵ +// ԶĶ ע +// ԶĶ ע +// ԶĶ ע + +// 0رԶ +// 1Զ Զʵ޸WIRELESS_UART_BAUD֮ҪģãģԶΪӦIJ + +#define WIRELESS_AUTO_UART_BAUD 0 +// ------------------------------------ Զ ------------------------------------ + +#define RTS_PIN P10_2 //λ ָʾǰģǷԽ 0Լ 1Լ +#define WIRELESS_BUFFER_SIZE 16 + +extern uint8 wireless_send_buffer[WIRELESS_BUFFER_SIZE]; +extern uint32 wireless_rx_index; void wireless_uart_callback(void); void seekfree_wireless_init(void); diff --git a/Example/FFT_Demo/USER/isr.c b/Example/FFT_Demo/USER/isr.c index c55a012..16bff98 100644 --- a/Example/FFT_Demo/USER/isr.c +++ b/Example/FFT_Demo/USER/isr.c @@ -179,7 +179,20 @@ IFX_INTERRUPT(uart2_rx_isr, 0, UART2_RX_INT_PRIO) { enableInterrupts();//жǶ IfxAsclin_Asc_isrReceive(&uart2_handle); - wireless_uart_callback(); + switch(wireless_type) + { + case WIRELESS_SI24R1: + { + wireless_uart_callback(); + }break; + + case WIRELESS_CH9141: + { + bluetooth_ch9141_uart_callback(); + }break; + default:break; + } + } IFX_INTERRUPT(uart2_er_isr, 0, UART2_ER_INT_PRIO) { diff --git a/Example/FFT_Demo/删除临时文件.bat b/Example/FFT_Demo/删除临时文件.bat index 5323dd9..fa499b1 100644 --- a/Example/FFT_Demo/删除临时文件.bat +++ b/Example/FFT_Demo/删除临时文件.bat @@ -1,9 +1,6 @@ -rmdir .settings /s /q rmdir Debug /s /q del *.launch /s - -pause exit diff --git a/Example/GPIO_Interrupt_Demo/.cproject b/Example/GPIO_Interrupt_Demo/.cproject index c4f672b..35371d8 100644 --- a/Example/GPIO_Interrupt_Demo/.cproject +++ b/Example/GPIO_Interrupt_Demo/.cproject @@ -3,9 +3,9 @@ - + - + @@ -25,50 +25,76 @@ - + - + - + - + + + + + + @@ -355,9 +371,9 @@ - + - + @@ -377,43 +393,1895 @@ - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -431,13 +2299,37 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + @@ -458,21 +2350,5 @@ - - - - - - - - - - - - - - - - diff --git a/Example/GPIO_Interrupt_Demo/.project b/Example/GPIO_Interrupt_Demo/.project index 5223db4..fcdddec 100644 --- a/Example/GPIO_Interrupt_Demo/.project +++ b/Example/GPIO_Interrupt_Demo/.project @@ -5,6 +5,18 @@ + + com.infineon.aurix.buildsystem.builders.booster + full,incremental, + + + + + com.infineon.aurix.buildsystem.builders.autodiscovery + full,incremental, + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder clean,full,incremental, diff --git a/Example/GPIO_Interrupt_Demo/.settings/com.infineon.aurix.buildsystem.prefs b/Example/GPIO_Interrupt_Demo/.settings/com.infineon.aurix.buildsystem.prefs new file mode 100644 index 0000000..be61bc1 --- /dev/null +++ b/Example/GPIO_Interrupt_Demo/.settings/com.infineon.aurix.buildsystem.prefs @@ -0,0 +1,10 @@ +AURIX-LIBRARY-PATH=Libraries/iLLD\#Libraries/Infra\#Libraries/Service +DEVICE-ID=TC26B +DEVICE-ID-FULL=TC26xD_B-Step +ILLD-SET=full +IncludesAutodiscovery=true +LIBRARIES-ROOT-PATH=Libraries +NEVER-EXCLUDE-FROM-BUILD=/Libraries/iLLD/TC26B/Tricore/Cpu/CStart\#/Libraries/iLLD/TC26B/Tricore/Cpu/Trap\#/Configurations\#/Configurations/Debug +PROJECT-VERSION=1.0 +aurixDevice=TC26xD_B-Step +eclipse.preferences.version=1 diff --git a/Example/GPIO_Interrupt_Demo/Libraries/doc/version.txt b/Example/GPIO_Interrupt_Demo/Libraries/doc/version.txt index ab79909..11ab82e 100644 --- a/Example/GPIO_Interrupt_Demo/Libraries/doc/version.txt +++ b/Example/GPIO_Interrupt_Demo/Libraries/doc/version.txt @@ -1,3 +1,13 @@ +V1.2.0 + CH9141תģ + ͵öٱ + ޸ ɾʱļ.bat ִԶرմ + ޸ ɾʱļ.bat ɾ°汾ļ + ޸ĹĿļ֧°汾 + +V1.1.10 + ޸ͨ#pragma section all "cpux_dsram"ָλʧЧ + V1.1.9 ڵķbuffӵ128ֽ diff --git a/Example/GPIO_Interrupt_Demo/Libraries/seekfree_libraries/common/common.c b/Example/GPIO_Interrupt_Demo/Libraries/seekfree_libraries/common/common.c index 0b9931e..7620ce6 100644 --- a/Example/GPIO_Interrupt_Demo/Libraries/seekfree_libraries/common/common.c +++ b/Example/GPIO_Interrupt_Demo/Libraries/seekfree_libraries/common/common.c @@ -27,6 +27,8 @@ CAMERA_TYPE_enum camera_type; //ͷͺ uint8 *camera_buffer_addr; //ͷַ +WIRELESS_TYPE_enum wireless_type;//ת + IFX_ALIGN(4) IfxCpu_syncEvent g_cpuSyncEvent = 0;//¼ͬ App_Cpu0 g_AppCpu0; //ƵϢ diff --git a/Example/GPIO_Interrupt_Demo/Libraries/seekfree_libraries/common/common.h b/Example/GPIO_Interrupt_Demo/Libraries/seekfree_libraries/common/common.h index 84c43ee..5b741c0 100644 --- a/Example/GPIO_Interrupt_Demo/Libraries/seekfree_libraries/common/common.h +++ b/Example/GPIO_Interrupt_Demo/Libraries/seekfree_libraries/common/common.h @@ -113,6 +113,12 @@ typedef enum //ö CAMERA_COLOR, //ͫ }CAMERA_TYPE_enum; +typedef enum //ģ +{ + WIRELESS_SI24R1 = 1, //ת + WIRELESS_CH9141, //ת +}WIRELESS_TYPE_enum; + #include #include #include "IfxCpu.h" @@ -120,6 +126,8 @@ typedef enum //ö extern CAMERA_TYPE_enum camera_type; //ͷͺ extern uint8 *camera_buffer_addr; //ͷַ +extern WIRELESS_TYPE_enum wireless_type; + extern IfxCpu_syncEvent g_cpuSyncEvent; void get_clk(void); diff --git a/Example/GPIO_Interrupt_Demo/Libraries/seekfree_libraries/headfile.h b/Example/GPIO_Interrupt_Demo/Libraries/seekfree_libraries/headfile.h index 404ee0a..b745302 100644 --- a/Example/GPIO_Interrupt_Demo/Libraries/seekfree_libraries/headfile.h +++ b/Example/GPIO_Interrupt_Demo/Libraries/seekfree_libraries/headfile.h @@ -65,6 +65,7 @@ #include "SEEKFREE_7725.h" #include "SEEKFREE_RDA5807.h" #include "SEEKFREE_7725_UART.h" +#include "SEEKFREE_BLUETOOTH_CH9141.h" #endif diff --git a/Example/GPIO_Interrupt_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.c b/Example/GPIO_Interrupt_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.c new file mode 100644 index 0000000..b4ec2df --- /dev/null +++ b/Example/GPIO_Interrupt_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.c @@ -0,0 +1,509 @@ +/********************************************************************************************************************* + * COPYRIGHT NOTICE + * Copyright (c) 2021,ɿƼ + * All rights reserved. + * QQȺһȺ179029047() Ⱥ244861897 + * + * ݰȨɿƼУδҵ; + * ӭλʹò޸ʱ뱣ɿƼİȨ + * + * @file ɿƼתģ + * @company ɶɿƼ޹˾ + * @author ɿƼ(QQ3184284598) + * @version 鿴docversionļ 汾˵ + * @Software IAR 8.3 or MDK 5.33 + * @Taobao https://seekfree.taobao.com/ + * @date 2021-08-27 + * @note + ߶壺 + ------------------------------------ + ת Ƭ + RX 鿴SEEKFREE_BLUETOOTH_CH9141.hļеBLUETOOTH_CH9141_UART_TX궨 + TX 鿴SEEKFREE_BLUETOOTH_CH9141.hļеBLUETOOTH_CH9141_UART_RX궨 + RTS 鿴SEEKFREE_BLUETOOTH_CH9141.hļеBLUETOOTH_CH9141_RTS_PIN궨 + CTS + CMD ջ + ------------------------------------ + ********************************************************************************************************************/ +#include "zf_stm_systick.h" +#include "zf_gpio.h" +#include "zf_uart.h" +#include "zf_assert.h" +#include "SEEKFREE_BLUETOOTH_CH9141.h" + +uint8 uart_flag; +uint8 uart_data; + +vuint8 at_mode = 0; //0:͸ģʽ 1:ATģʽ 2:ģ鸴λ +vuint8 at_mode_num; //atģʽʱָʾݽյ +vuint8 at_mode_data[30]; //atĻ +vuint8 at_mode_cmd_flag; //OKӦճɹı־λ + +uint8 mac_address[17]; //macַ + + +uint8 bluetooth_ch9141_rx_buffer; + + +void bluetooth_ch9141_check_response(void); + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ жϻص +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note úISRļ 8жϳ򱻵 +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_uart_callback() +{ + while(uart_query(BLUETOOTH_CH9141_UART, &bluetooth_ch9141_rx_buffer)) + { + if(1 == at_mode) + { + //ATģʽ Ӧź ˴ifڴûҪĶ + at_mode_data[at_mode_num++] = bluetooth_ch9141_rx_buffer; + bluetooth_ch9141_check_response(); + } + else if(2 == at_mode) + { + //ģڸλ ˴ifڴûҪĶ + at_mode_num++; + } + else + { + //͸ģʽ ûڴ˴Ե͹Ķ + //ӵһֽںƬ˴ͨڴ˴ȡbluetooth_ch9141_rx_bufferȡ + + // ȡߴڵ λձ־ + uart_flag = 1; + uart_data = bluetooth_ch9141_rx_buffer; + } + + } +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģOKӦź +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note û +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_check_response(void) +{ + if(4 <= at_mode_num) + { + if(0 == strncmp("OK\r\n", (int8 *)&at_mode_data[at_mode_num-4], 4)) + { + at_mode_cmd_flag = 1; + } + } +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ鷢һûвȴӦź +// @param *str Ҫ͵ ַ +// @return void +// @since v1.0 +// Sample usage: +// @note û +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_send_at_command(const int8 *str) +{ + at_mode_num = 0; // + uart_putstr(BLUETOOTH_CH9141_UART, str); + uart_putstr(BLUETOOTH_CH9141_UART, "\r\n"); + + //ȴյӦź + while(!at_mode_cmd_flag); + at_mode_cmd_flag = 0; +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ鷢һвȴӦź +// @param *cmd Ҫ͵ +// @param *data Ҫ͵ +// @return void +// @since v1.0 +// Sample usage: +// @note û +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_send_at_command_parameter(const int8 *cmd, const int8 *data) +{ + at_mode_num = 0; // + uart_putstr(BLUETOOTH_CH9141_UART, "AT+"); + uart_putstr(BLUETOOTH_CH9141_UART, cmd); + uart_putstr(BLUETOOTH_CH9141_UART, "="); + uart_putstr(BLUETOOTH_CH9141_UART, data); + uart_putstr(BLUETOOTH_CH9141_UART, "\r\n"); + + //ȴյӦź + while(!at_mode_cmd_flag); + at_mode_cmd_flag = 0; +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģATģʽ +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_enter_at_mode(void) +{ + systick_delay_ms(STM0, 550); //ͽATģʽǰҪ֤ģ550msûнչκ + at_mode = 1; //ATģʽ + bluetooth_ch9141_send_at_command("AT..."); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ˳ATģʽ +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_exit_at_mode(void) +{ + bluetooth_ch9141_send_at_command("AT+EXIT"); + at_mode = 0; //͸ģʽ + systick_delay_ms(STM0, 300); //ȴɹATģʽ +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ鸴λ +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_reset(void) +{ + bluetooth_ch9141_send_at_command("AT+RESET"); + at_mode = 2; //ɹ + at_mode_num = 0; + while(7 > at_mode_num); //ȴģɸλ + at_mode = 0; //λ֮ģԶ͸ģʽ +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģȡMACַ +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note ô˺Ҫȵbluetooth_ch9141_enter_at_modeCMD ATģʽ +// Ҫرעbluetooth_ch9141_enter_at_modeڲ500msʱ +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_get_mac_address(void) +{ + bluetooth_ch9141_send_at_command("AT+MAC?"); + + //macַΪСθʽmac_address[0]macַλ + memcpy(mac_address, (uint8 *)at_mode_data, 17); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ÷͹ +// @param tx_power ÷͹ʣѡ鿴CH9141_TX_POWEER_enumöٳԱ +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_set_tx_power(CH9141_TX_POWEER_enum tx_power) +{ + int8 tx_power_data; + + tx_power_data = (uint8)tx_power + '0'; + bluetooth_ch9141_send_at_command_parameter("TPL", &tx_power_data); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģģʽ +// @param mode ģʽãѡ鿴CH9141_MODE_enumöٳԱ +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_set_mode(CH9141_MODE_enum mode) +{ + int8 mode_data; + + mode_data = (uint8)mode + '0'; + bluetooth_ch9141_send_at_command_parameter("BLEMODE", &mode_data); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģȡ״̬ +// @param mode ģʽãѡ鿴CH9141_MODE_enumöٳԱ +// @return CH9141_STATUS_enum ״̬Ϣ +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +CH9141_STATUS_enum bluetooth_ch9141_get_status(CH9141_MODE_enum mode) +{ + CH9141_STATUS_enum ch9141_status; + int8 mode_data; + + mode_data = (uint8)mode + '0'; + bluetooth_ch9141_send_at_command_parameter("BLEMODE", &mode_data); + + bluetooth_ch9141_send_at_command("AT+BLESTA?"); + + ch9141_status = (at_mode_data[0] - '0') * 10 + (at_mode_data[1] - '0'); + if(SLAVE_MODE == mode) + { + ch9141_status += SLAVE_NO_INIT; + } + + return ch9141_status; +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ豸 +// @param *str +// @return void +// @since v1.0 +// Sample usage: +// @note ƳȲܳ18ַ ֻΪӢ +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_set_name(const int8 *str) +{ + bluetooth_ch9141_send_at_command_parameter("NAME", str); + bluetooth_ch9141_send_at_command_parameter("PNAME", str); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ +// @param enable ʹ 0ʹ룬1ʹӱ豸 +// @param *password ַ Ϊ6ַ +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_set_password(uint8 enable, const int8 *password) +{ + if(0 == enable) + { + //ر + bluetooth_ch9141_send_at_command_parameter("PASEN", "OFF"); + } + else + { + //벢ʹ + bluetooth_ch9141_send_at_command_parameter("PASEN", "ON"); + bluetooth_ch9141_send_at_command_parameter("PASS", password); + } +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģָMACַ +// @param *mac_and_password Ҫӵ豸macַ +// @return void +// @since v1.0 +// Sample usage: +// @note bluetooth_ch9141_connect("58:B7:33:E4:C2:84,000000"); +// 58:B7:33:E4:C2:84Ϊmacַ ,Ϊָ 000000Ϊӻ +// ===================رע================== +// ʹֻ鿴macַʹñӵʱ뽫macһ +// ֻ鿴macַΪ61:62:63:64:65:66ʹñӵʱӦд +// bluetooth_ch9141_connect("66:65:64:63:62:61,000000"); +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_connect(const int8 *mac_and_password) +{ + bluetooth_ch9141_send_at_command_parameter("CONN", mac_and_password); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģĬӲãúúÿοԶ豸 +// @param *mac_and_password Ҫӵ豸macַ +// @return void +// @since v1.0 +// Sample usage: +// @note bluetooth_ch9141_default_connect("58:B7:33:E4:C2:84,000000"); +// 58:B7:33:E4:C2:84Ϊmacַ ,Ϊָ 000000Ϊӻ +// ===================رע================== +// ʹֻ鿴CH9141macַCH9141Ϊӻʹֻ +// ʹñӵʱ뽫macһ +// ֻ鿴macַΪ61:62:63:64:65:67ʹñӵʱӦд +// bluetooth_ch9141_default_connect("67:65:64:63:62:61,000000"); +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_default_connect(const int8 *mac_and_password) +{ + bluetooth_ch9141_send_at_command_parameter("CONADD", mac_and_password); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģȡrssi(źǿ) +// @param void +// @return int8 źǿ0-127 +// @since v1.0 +// Sample usage: +// @note ô˺Ҫȵbluetooth_ch9141_enter_at_modeCMD ATģʽ +// Ҫرעbluetooth_ch9141_enter_at_modeڲ500msʱ +//------------------------------------------------------------------------------------------------------------------- +int16 bluetooth_ch9141_get_rssi(void) +{ + uint8 i; + size_t length; + int16 rssi; + bluetooth_ch9141_send_at_command_parameter("RSSI", "ON,0"); + length = strlen((int8 *)at_mode_data); + length -= 12;//RSSI жλ + + rssi = 0; + for(i=0; i30) { - if(gpio_get(RTS_PIN)) - { - return len;//ģæ,ǰʹwhileȴ ʹúע͵whileȴ滻if - } - //while(gpio_get(RTS_PIN)); //RTSΪ͵ƽ +// if(gpio_get(RTS_PIN)) +// { +// return len;//ģæ,ǰʹwhileȴ ʹúע͵whileȴ滻if +// } + while(gpio_get(RTS_PIN)); //RTSΪ͵ƽ uart_putbuff(WIRELESS_UART,buff,30); buff += 30; //ַƫ len -= 30;// } - if(gpio_get(RTS_PIN)) - { - return len;//ģæ,ǰʹwhileȴ ʹúע͵whileȴ滻if - } - //while(gpio_get(RTS_PIN)); //RTSΪ͵ƽ +// if(gpio_get(RTS_PIN)) +// { +// return len;//ģæ,ǰʹwhileȴ ʹúע͵whileȴ滻if +// } + while(gpio_get(RTS_PIN)); //RTSΪ͵ƽ uart_putbuff(WIRELESS_UART,buff,len);// return 0; diff --git a/Example/GPIO_Interrupt_Demo/Libraries/seekfree_peripheral/SEEKFREE_WIRELESS.h b/Example/GPIO_Interrupt_Demo/Libraries/seekfree_peripheral/SEEKFREE_WIRELESS.h index 42c0832..d80339d 100644 --- a/Example/GPIO_Interrupt_Demo/Libraries/seekfree_peripheral/SEEKFREE_WIRELESS.h +++ b/Example/GPIO_Interrupt_Demo/Libraries/seekfree_peripheral/SEEKFREE_WIRELESS.h @@ -38,8 +38,26 @@ #define WIRELESS_UART_RX UART2_RX_P10_6 #define WIRELESS_UART_BAUD 115200 -#define RTS_PIN P10_2 //λ ָʾǰģǷԽ 0Լ 1Լ +// ------------------------------------ Զ ------------------------------------ +// ע1תģ汾V2.0µ޷Զʵġ +// ע2ԶRTSţῪʧܡ +// ע3ģԶʧܵĻԳԶϵ +// ԶĶ ע +// ԶĶ ע +// ԶĶ ע + +// 0رԶ +// 1Զ Զʵ޸WIRELESS_UART_BAUD֮ҪģãģԶΪӦIJ + +#define WIRELESS_AUTO_UART_BAUD 0 +// ------------------------------------ Զ ------------------------------------ + +#define RTS_PIN P10_2 //λ ָʾǰģǷԽ 0Լ 1Լ +#define WIRELESS_BUFFER_SIZE 16 + +extern uint8 wireless_send_buffer[WIRELESS_BUFFER_SIZE]; +extern uint32 wireless_rx_index; void wireless_uart_callback(void); void seekfree_wireless_init(void); diff --git a/Example/GPIO_Interrupt_Demo/USER/isr.c b/Example/GPIO_Interrupt_Demo/USER/isr.c index 50acc67..42c2fc7 100644 --- a/Example/GPIO_Interrupt_Demo/USER/isr.c +++ b/Example/GPIO_Interrupt_Demo/USER/isr.c @@ -191,7 +191,20 @@ IFX_INTERRUPT(uart2_rx_isr, 0, UART2_RX_INT_PRIO) { enableInterrupts();//жǶ IfxAsclin_Asc_isrReceive(&uart2_handle); - wireless_uart_callback(); + switch(wireless_type) + { + case WIRELESS_SI24R1: + { + wireless_uart_callback(); + }break; + + case WIRELESS_CH9141: + { + bluetooth_ch9141_uart_callback(); + }break; + default:break; + } + } IFX_INTERRUPT(uart2_er_isr, 0, UART2_ER_INT_PRIO) { diff --git a/Example/GPIO_Interrupt_Demo/删除临时文件.bat b/Example/GPIO_Interrupt_Demo/删除临时文件.bat index 5323dd9..fa499b1 100644 --- a/Example/GPIO_Interrupt_Demo/删除临时文件.bat +++ b/Example/GPIO_Interrupt_Demo/删除临时文件.bat @@ -1,9 +1,6 @@ -rmdir .settings /s /q rmdir Debug /s /q del *.launch /s - -pause exit diff --git a/Example/Interrupt_Priority_Set_Demo/.cproject b/Example/Interrupt_Priority_Set_Demo/.cproject index 0c0d7a3..9b9f6c9 100644 --- a/Example/Interrupt_Priority_Set_Demo/.cproject +++ b/Example/Interrupt_Priority_Set_Demo/.cproject @@ -3,9 +3,9 @@ - + - + @@ -25,50 +25,76 @@ - + - + - + - + + + + + + @@ -355,9 +371,9 @@ - + - + @@ -377,43 +393,1895 @@ - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -431,13 +2299,37 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + @@ -458,21 +2350,5 @@ - - - - - - - - - - - - - - - - diff --git a/Example/Interrupt_Priority_Set_Demo/.project b/Example/Interrupt_Priority_Set_Demo/.project index bc63143..b487c65 100644 --- a/Example/Interrupt_Priority_Set_Demo/.project +++ b/Example/Interrupt_Priority_Set_Demo/.project @@ -5,6 +5,18 @@ + + com.infineon.aurix.buildsystem.builders.booster + full,incremental, + + + + + com.infineon.aurix.buildsystem.builders.autodiscovery + full,incremental, + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder clean,full,incremental, diff --git a/Example/Interrupt_Priority_Set_Demo/.settings/com.infineon.aurix.buildsystem.prefs b/Example/Interrupt_Priority_Set_Demo/.settings/com.infineon.aurix.buildsystem.prefs new file mode 100644 index 0000000..be61bc1 --- /dev/null +++ b/Example/Interrupt_Priority_Set_Demo/.settings/com.infineon.aurix.buildsystem.prefs @@ -0,0 +1,10 @@ +AURIX-LIBRARY-PATH=Libraries/iLLD\#Libraries/Infra\#Libraries/Service +DEVICE-ID=TC26B +DEVICE-ID-FULL=TC26xD_B-Step +ILLD-SET=full +IncludesAutodiscovery=true +LIBRARIES-ROOT-PATH=Libraries +NEVER-EXCLUDE-FROM-BUILD=/Libraries/iLLD/TC26B/Tricore/Cpu/CStart\#/Libraries/iLLD/TC26B/Tricore/Cpu/Trap\#/Configurations\#/Configurations/Debug +PROJECT-VERSION=1.0 +aurixDevice=TC26xD_B-Step +eclipse.preferences.version=1 diff --git a/Example/Interrupt_Priority_Set_Demo/Libraries/doc/version.txt b/Example/Interrupt_Priority_Set_Demo/Libraries/doc/version.txt index ab79909..11ab82e 100644 --- a/Example/Interrupt_Priority_Set_Demo/Libraries/doc/version.txt +++ b/Example/Interrupt_Priority_Set_Demo/Libraries/doc/version.txt @@ -1,3 +1,13 @@ +V1.2.0 + CH9141תģ + ͵öٱ + ޸ ɾʱļ.bat ִԶرմ + ޸ ɾʱļ.bat ɾ°汾ļ + ޸ĹĿļ֧°汾 + +V1.1.10 + ޸ͨ#pragma section all "cpux_dsram"ָλʧЧ + V1.1.9 ڵķbuffӵ128ֽ diff --git a/Example/Interrupt_Priority_Set_Demo/Libraries/seekfree_libraries/common/common.c b/Example/Interrupt_Priority_Set_Demo/Libraries/seekfree_libraries/common/common.c index 0b9931e..7620ce6 100644 --- a/Example/Interrupt_Priority_Set_Demo/Libraries/seekfree_libraries/common/common.c +++ b/Example/Interrupt_Priority_Set_Demo/Libraries/seekfree_libraries/common/common.c @@ -27,6 +27,8 @@ CAMERA_TYPE_enum camera_type; //ͷͺ uint8 *camera_buffer_addr; //ͷַ +WIRELESS_TYPE_enum wireless_type;//ת + IFX_ALIGN(4) IfxCpu_syncEvent g_cpuSyncEvent = 0;//¼ͬ App_Cpu0 g_AppCpu0; //ƵϢ diff --git a/Example/Interrupt_Priority_Set_Demo/Libraries/seekfree_libraries/common/common.h b/Example/Interrupt_Priority_Set_Demo/Libraries/seekfree_libraries/common/common.h index 84c43ee..5b741c0 100644 --- a/Example/Interrupt_Priority_Set_Demo/Libraries/seekfree_libraries/common/common.h +++ b/Example/Interrupt_Priority_Set_Demo/Libraries/seekfree_libraries/common/common.h @@ -113,6 +113,12 @@ typedef enum //ö CAMERA_COLOR, //ͫ }CAMERA_TYPE_enum; +typedef enum //ģ +{ + WIRELESS_SI24R1 = 1, //ת + WIRELESS_CH9141, //ת +}WIRELESS_TYPE_enum; + #include #include #include "IfxCpu.h" @@ -120,6 +126,8 @@ typedef enum //ö extern CAMERA_TYPE_enum camera_type; //ͷͺ extern uint8 *camera_buffer_addr; //ͷַ +extern WIRELESS_TYPE_enum wireless_type; + extern IfxCpu_syncEvent g_cpuSyncEvent; void get_clk(void); diff --git a/Example/Interrupt_Priority_Set_Demo/Libraries/seekfree_libraries/headfile.h b/Example/Interrupt_Priority_Set_Demo/Libraries/seekfree_libraries/headfile.h index 404ee0a..b745302 100644 --- a/Example/Interrupt_Priority_Set_Demo/Libraries/seekfree_libraries/headfile.h +++ b/Example/Interrupt_Priority_Set_Demo/Libraries/seekfree_libraries/headfile.h @@ -65,6 +65,7 @@ #include "SEEKFREE_7725.h" #include "SEEKFREE_RDA5807.h" #include "SEEKFREE_7725_UART.h" +#include "SEEKFREE_BLUETOOTH_CH9141.h" #endif diff --git a/Example/Interrupt_Priority_Set_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.c b/Example/Interrupt_Priority_Set_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.c new file mode 100644 index 0000000..b4ec2df --- /dev/null +++ b/Example/Interrupt_Priority_Set_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.c @@ -0,0 +1,509 @@ +/********************************************************************************************************************* + * COPYRIGHT NOTICE + * Copyright (c) 2021,ɿƼ + * All rights reserved. + * QQȺһȺ179029047() Ⱥ244861897 + * + * ݰȨɿƼУδҵ; + * ӭλʹò޸ʱ뱣ɿƼİȨ + * + * @file ɿƼתģ + * @company ɶɿƼ޹˾ + * @author ɿƼ(QQ3184284598) + * @version 鿴docversionļ 汾˵ + * @Software IAR 8.3 or MDK 5.33 + * @Taobao https://seekfree.taobao.com/ + * @date 2021-08-27 + * @note + ߶壺 + ------------------------------------ + ת Ƭ + RX 鿴SEEKFREE_BLUETOOTH_CH9141.hļеBLUETOOTH_CH9141_UART_TX궨 + TX 鿴SEEKFREE_BLUETOOTH_CH9141.hļеBLUETOOTH_CH9141_UART_RX궨 + RTS 鿴SEEKFREE_BLUETOOTH_CH9141.hļеBLUETOOTH_CH9141_RTS_PIN궨 + CTS + CMD ջ + ------------------------------------ + ********************************************************************************************************************/ +#include "zf_stm_systick.h" +#include "zf_gpio.h" +#include "zf_uart.h" +#include "zf_assert.h" +#include "SEEKFREE_BLUETOOTH_CH9141.h" + +uint8 uart_flag; +uint8 uart_data; + +vuint8 at_mode = 0; //0:͸ģʽ 1:ATģʽ 2:ģ鸴λ +vuint8 at_mode_num; //atģʽʱָʾݽյ +vuint8 at_mode_data[30]; //atĻ +vuint8 at_mode_cmd_flag; //OKӦճɹı־λ + +uint8 mac_address[17]; //macַ + + +uint8 bluetooth_ch9141_rx_buffer; + + +void bluetooth_ch9141_check_response(void); + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ жϻص +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note úISRļ 8жϳ򱻵 +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_uart_callback() +{ + while(uart_query(BLUETOOTH_CH9141_UART, &bluetooth_ch9141_rx_buffer)) + { + if(1 == at_mode) + { + //ATģʽ Ӧź ˴ifڴûҪĶ + at_mode_data[at_mode_num++] = bluetooth_ch9141_rx_buffer; + bluetooth_ch9141_check_response(); + } + else if(2 == at_mode) + { + //ģڸλ ˴ifڴûҪĶ + at_mode_num++; + } + else + { + //͸ģʽ ûڴ˴Ե͹Ķ + //ӵһֽںƬ˴ͨڴ˴ȡbluetooth_ch9141_rx_bufferȡ + + // ȡߴڵ λձ־ + uart_flag = 1; + uart_data = bluetooth_ch9141_rx_buffer; + } + + } +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģOKӦź +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note û +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_check_response(void) +{ + if(4 <= at_mode_num) + { + if(0 == strncmp("OK\r\n", (int8 *)&at_mode_data[at_mode_num-4], 4)) + { + at_mode_cmd_flag = 1; + } + } +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ鷢һûвȴӦź +// @param *str Ҫ͵ ַ +// @return void +// @since v1.0 +// Sample usage: +// @note û +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_send_at_command(const int8 *str) +{ + at_mode_num = 0; // + uart_putstr(BLUETOOTH_CH9141_UART, str); + uart_putstr(BLUETOOTH_CH9141_UART, "\r\n"); + + //ȴյӦź + while(!at_mode_cmd_flag); + at_mode_cmd_flag = 0; +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ鷢һвȴӦź +// @param *cmd Ҫ͵ +// @param *data Ҫ͵ +// @return void +// @since v1.0 +// Sample usage: +// @note û +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_send_at_command_parameter(const int8 *cmd, const int8 *data) +{ + at_mode_num = 0; // + uart_putstr(BLUETOOTH_CH9141_UART, "AT+"); + uart_putstr(BLUETOOTH_CH9141_UART, cmd); + uart_putstr(BLUETOOTH_CH9141_UART, "="); + uart_putstr(BLUETOOTH_CH9141_UART, data); + uart_putstr(BLUETOOTH_CH9141_UART, "\r\n"); + + //ȴյӦź + while(!at_mode_cmd_flag); + at_mode_cmd_flag = 0; +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģATģʽ +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_enter_at_mode(void) +{ + systick_delay_ms(STM0, 550); //ͽATģʽǰҪ֤ģ550msûнչκ + at_mode = 1; //ATģʽ + bluetooth_ch9141_send_at_command("AT..."); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ˳ATģʽ +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_exit_at_mode(void) +{ + bluetooth_ch9141_send_at_command("AT+EXIT"); + at_mode = 0; //͸ģʽ + systick_delay_ms(STM0, 300); //ȴɹATģʽ +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ鸴λ +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_reset(void) +{ + bluetooth_ch9141_send_at_command("AT+RESET"); + at_mode = 2; //ɹ + at_mode_num = 0; + while(7 > at_mode_num); //ȴģɸλ + at_mode = 0; //λ֮ģԶ͸ģʽ +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģȡMACַ +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note ô˺Ҫȵbluetooth_ch9141_enter_at_modeCMD ATģʽ +// Ҫرעbluetooth_ch9141_enter_at_modeڲ500msʱ +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_get_mac_address(void) +{ + bluetooth_ch9141_send_at_command("AT+MAC?"); + + //macַΪСθʽmac_address[0]macַλ + memcpy(mac_address, (uint8 *)at_mode_data, 17); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ÷͹ +// @param tx_power ÷͹ʣѡ鿴CH9141_TX_POWEER_enumöٳԱ +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_set_tx_power(CH9141_TX_POWEER_enum tx_power) +{ + int8 tx_power_data; + + tx_power_data = (uint8)tx_power + '0'; + bluetooth_ch9141_send_at_command_parameter("TPL", &tx_power_data); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģģʽ +// @param mode ģʽãѡ鿴CH9141_MODE_enumöٳԱ +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_set_mode(CH9141_MODE_enum mode) +{ + int8 mode_data; + + mode_data = (uint8)mode + '0'; + bluetooth_ch9141_send_at_command_parameter("BLEMODE", &mode_data); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģȡ״̬ +// @param mode ģʽãѡ鿴CH9141_MODE_enumöٳԱ +// @return CH9141_STATUS_enum ״̬Ϣ +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +CH9141_STATUS_enum bluetooth_ch9141_get_status(CH9141_MODE_enum mode) +{ + CH9141_STATUS_enum ch9141_status; + int8 mode_data; + + mode_data = (uint8)mode + '0'; + bluetooth_ch9141_send_at_command_parameter("BLEMODE", &mode_data); + + bluetooth_ch9141_send_at_command("AT+BLESTA?"); + + ch9141_status = (at_mode_data[0] - '0') * 10 + (at_mode_data[1] - '0'); + if(SLAVE_MODE == mode) + { + ch9141_status += SLAVE_NO_INIT; + } + + return ch9141_status; +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ豸 +// @param *str +// @return void +// @since v1.0 +// Sample usage: +// @note ƳȲܳ18ַ ֻΪӢ +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_set_name(const int8 *str) +{ + bluetooth_ch9141_send_at_command_parameter("NAME", str); + bluetooth_ch9141_send_at_command_parameter("PNAME", str); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ +// @param enable ʹ 0ʹ룬1ʹӱ豸 +// @param *password ַ Ϊ6ַ +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_set_password(uint8 enable, const int8 *password) +{ + if(0 == enable) + { + //ر + bluetooth_ch9141_send_at_command_parameter("PASEN", "OFF"); + } + else + { + //벢ʹ + bluetooth_ch9141_send_at_command_parameter("PASEN", "ON"); + bluetooth_ch9141_send_at_command_parameter("PASS", password); + } +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģָMACַ +// @param *mac_and_password Ҫӵ豸macַ +// @return void +// @since v1.0 +// Sample usage: +// @note bluetooth_ch9141_connect("58:B7:33:E4:C2:84,000000"); +// 58:B7:33:E4:C2:84Ϊmacַ ,Ϊָ 000000Ϊӻ +// ===================رע================== +// ʹֻ鿴macַʹñӵʱ뽫macһ +// ֻ鿴macַΪ61:62:63:64:65:66ʹñӵʱӦд +// bluetooth_ch9141_connect("66:65:64:63:62:61,000000"); +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_connect(const int8 *mac_and_password) +{ + bluetooth_ch9141_send_at_command_parameter("CONN", mac_and_password); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģĬӲãúúÿοԶ豸 +// @param *mac_and_password Ҫӵ豸macַ +// @return void +// @since v1.0 +// Sample usage: +// @note bluetooth_ch9141_default_connect("58:B7:33:E4:C2:84,000000"); +// 58:B7:33:E4:C2:84Ϊmacַ ,Ϊָ 000000Ϊӻ +// ===================رע================== +// ʹֻ鿴CH9141macַCH9141Ϊӻʹֻ +// ʹñӵʱ뽫macһ +// ֻ鿴macַΪ61:62:63:64:65:67ʹñӵʱӦд +// bluetooth_ch9141_default_connect("67:65:64:63:62:61,000000"); +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_default_connect(const int8 *mac_and_password) +{ + bluetooth_ch9141_send_at_command_parameter("CONADD", mac_and_password); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģȡrssi(źǿ) +// @param void +// @return int8 źǿ0-127 +// @since v1.0 +// Sample usage: +// @note ô˺Ҫȵbluetooth_ch9141_enter_at_modeCMD ATģʽ +// Ҫرעbluetooth_ch9141_enter_at_modeڲ500msʱ +//------------------------------------------------------------------------------------------------------------------- +int16 bluetooth_ch9141_get_rssi(void) +{ + uint8 i; + size_t length; + int16 rssi; + bluetooth_ch9141_send_at_command_parameter("RSSI", "ON,0"); + length = strlen((int8 *)at_mode_data); + length -= 12;//RSSI жλ + + rssi = 0; + for(i=0; i30) { - if(gpio_get(RTS_PIN)) - { - return len;//ģæ,ǰʹwhileȴ ʹúע͵whileȴ滻if - } - //while(gpio_get(RTS_PIN)); //RTSΪ͵ƽ +// if(gpio_get(RTS_PIN)) +// { +// return len;//ģæ,ǰʹwhileȴ ʹúע͵whileȴ滻if +// } + while(gpio_get(RTS_PIN)); //RTSΪ͵ƽ uart_putbuff(WIRELESS_UART,buff,30); buff += 30; //ַƫ len -= 30;// } - if(gpio_get(RTS_PIN)) - { - return len;//ģæ,ǰʹwhileȴ ʹúע͵whileȴ滻if - } - //while(gpio_get(RTS_PIN)); //RTSΪ͵ƽ +// if(gpio_get(RTS_PIN)) +// { +// return len;//ģæ,ǰʹwhileȴ ʹúע͵whileȴ滻if +// } + while(gpio_get(RTS_PIN)); //RTSΪ͵ƽ uart_putbuff(WIRELESS_UART,buff,len);// return 0; diff --git a/Example/Interrupt_Priority_Set_Demo/Libraries/seekfree_peripheral/SEEKFREE_WIRELESS.h b/Example/Interrupt_Priority_Set_Demo/Libraries/seekfree_peripheral/SEEKFREE_WIRELESS.h index 42c0832..d80339d 100644 --- a/Example/Interrupt_Priority_Set_Demo/Libraries/seekfree_peripheral/SEEKFREE_WIRELESS.h +++ b/Example/Interrupt_Priority_Set_Demo/Libraries/seekfree_peripheral/SEEKFREE_WIRELESS.h @@ -38,8 +38,26 @@ #define WIRELESS_UART_RX UART2_RX_P10_6 #define WIRELESS_UART_BAUD 115200 -#define RTS_PIN P10_2 //λ ָʾǰģǷԽ 0Լ 1Լ +// ------------------------------------ Զ ------------------------------------ +// ע1תģ汾V2.0µ޷Զʵġ +// ע2ԶRTSţῪʧܡ +// ע3ģԶʧܵĻԳԶϵ +// ԶĶ ע +// ԶĶ ע +// ԶĶ ע + +// 0رԶ +// 1Զ Զʵ޸WIRELESS_UART_BAUD֮ҪģãģԶΪӦIJ + +#define WIRELESS_AUTO_UART_BAUD 0 +// ------------------------------------ Զ ------------------------------------ + +#define RTS_PIN P10_2 //λ ָʾǰģǷԽ 0Լ 1Լ +#define WIRELESS_BUFFER_SIZE 16 + +extern uint8 wireless_send_buffer[WIRELESS_BUFFER_SIZE]; +extern uint32 wireless_rx_index; void wireless_uart_callback(void); void seekfree_wireless_init(void); diff --git a/Example/Interrupt_Priority_Set_Demo/USER/isr.c b/Example/Interrupt_Priority_Set_Demo/USER/isr.c index c55a012..16bff98 100644 --- a/Example/Interrupt_Priority_Set_Demo/USER/isr.c +++ b/Example/Interrupt_Priority_Set_Demo/USER/isr.c @@ -179,7 +179,20 @@ IFX_INTERRUPT(uart2_rx_isr, 0, UART2_RX_INT_PRIO) { enableInterrupts();//жǶ IfxAsclin_Asc_isrReceive(&uart2_handle); - wireless_uart_callback(); + switch(wireless_type) + { + case WIRELESS_SI24R1: + { + wireless_uart_callback(); + }break; + + case WIRELESS_CH9141: + { + bluetooth_ch9141_uart_callback(); + }break; + default:break; + } + } IFX_INTERRUPT(uart2_er_isr, 0, UART2_ER_INT_PRIO) { diff --git a/Example/Interrupt_Priority_Set_Demo/删除临时文件.bat b/Example/Interrupt_Priority_Set_Demo/删除临时文件.bat index 5323dd9..fa499b1 100644 --- a/Example/Interrupt_Priority_Set_Demo/删除临时文件.bat +++ b/Example/Interrupt_Priority_Set_Demo/删除临时文件.bat @@ -1,9 +1,6 @@ -rmdir .settings /s /q rmdir Debug /s /q del *.launch /s - -pause exit diff --git a/Example/LED_Blink_Demo/.cproject b/Example/LED_Blink_Demo/.cproject index beaaf7a..9ec6d79 100644 --- a/Example/LED_Blink_Demo/.cproject +++ b/Example/LED_Blink_Demo/.cproject @@ -3,9 +3,9 @@ - + - + @@ -25,50 +25,76 @@ - + - + - + - + + + + + + @@ -355,9 +371,9 @@ - + - + @@ -377,43 +393,1895 @@ - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -431,13 +2299,37 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + @@ -458,21 +2350,5 @@ - - - - - - - - - - - - - - - - diff --git a/Example/LED_Blink_Demo/.project b/Example/LED_Blink_Demo/.project index d235cb3..9553e30 100644 --- a/Example/LED_Blink_Demo/.project +++ b/Example/LED_Blink_Demo/.project @@ -5,6 +5,18 @@ + + com.infineon.aurix.buildsystem.builders.booster + full,incremental, + + + + + com.infineon.aurix.buildsystem.builders.autodiscovery + full,incremental, + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder clean,full,incremental, diff --git a/Example/LED_Blink_Demo/.settings/com.infineon.aurix.buildsystem.prefs b/Example/LED_Blink_Demo/.settings/com.infineon.aurix.buildsystem.prefs new file mode 100644 index 0000000..be61bc1 --- /dev/null +++ b/Example/LED_Blink_Demo/.settings/com.infineon.aurix.buildsystem.prefs @@ -0,0 +1,10 @@ +AURIX-LIBRARY-PATH=Libraries/iLLD\#Libraries/Infra\#Libraries/Service +DEVICE-ID=TC26B +DEVICE-ID-FULL=TC26xD_B-Step +ILLD-SET=full +IncludesAutodiscovery=true +LIBRARIES-ROOT-PATH=Libraries +NEVER-EXCLUDE-FROM-BUILD=/Libraries/iLLD/TC26B/Tricore/Cpu/CStart\#/Libraries/iLLD/TC26B/Tricore/Cpu/Trap\#/Configurations\#/Configurations/Debug +PROJECT-VERSION=1.0 +aurixDevice=TC26xD_B-Step +eclipse.preferences.version=1 diff --git a/Example/LED_Blink_Demo/Libraries/doc/version.txt b/Example/LED_Blink_Demo/Libraries/doc/version.txt index ab79909..11ab82e 100644 --- a/Example/LED_Blink_Demo/Libraries/doc/version.txt +++ b/Example/LED_Blink_Demo/Libraries/doc/version.txt @@ -1,3 +1,13 @@ +V1.2.0 + CH9141תģ + ͵öٱ + ޸ ɾʱļ.bat ִԶرմ + ޸ ɾʱļ.bat ɾ°汾ļ + ޸ĹĿļ֧°汾 + +V1.1.10 + ޸ͨ#pragma section all "cpux_dsram"ָλʧЧ + V1.1.9 ڵķbuffӵ128ֽ diff --git a/Example/LED_Blink_Demo/Libraries/seekfree_libraries/common/common.c b/Example/LED_Blink_Demo/Libraries/seekfree_libraries/common/common.c index 0b9931e..7620ce6 100644 --- a/Example/LED_Blink_Demo/Libraries/seekfree_libraries/common/common.c +++ b/Example/LED_Blink_Demo/Libraries/seekfree_libraries/common/common.c @@ -27,6 +27,8 @@ CAMERA_TYPE_enum camera_type; //ͷͺ uint8 *camera_buffer_addr; //ͷַ +WIRELESS_TYPE_enum wireless_type;//ת + IFX_ALIGN(4) IfxCpu_syncEvent g_cpuSyncEvent = 0;//¼ͬ App_Cpu0 g_AppCpu0; //ƵϢ diff --git a/Example/LED_Blink_Demo/Libraries/seekfree_libraries/common/common.h b/Example/LED_Blink_Demo/Libraries/seekfree_libraries/common/common.h index 84c43ee..5b741c0 100644 --- a/Example/LED_Blink_Demo/Libraries/seekfree_libraries/common/common.h +++ b/Example/LED_Blink_Demo/Libraries/seekfree_libraries/common/common.h @@ -113,6 +113,12 @@ typedef enum //ö CAMERA_COLOR, //ͫ }CAMERA_TYPE_enum; +typedef enum //ģ +{ + WIRELESS_SI24R1 = 1, //ת + WIRELESS_CH9141, //ת +}WIRELESS_TYPE_enum; + #include #include #include "IfxCpu.h" @@ -120,6 +126,8 @@ typedef enum //ö extern CAMERA_TYPE_enum camera_type; //ͷͺ extern uint8 *camera_buffer_addr; //ͷַ +extern WIRELESS_TYPE_enum wireless_type; + extern IfxCpu_syncEvent g_cpuSyncEvent; void get_clk(void); diff --git a/Example/LED_Blink_Demo/Libraries/seekfree_libraries/headfile.h b/Example/LED_Blink_Demo/Libraries/seekfree_libraries/headfile.h index 404ee0a..b745302 100644 --- a/Example/LED_Blink_Demo/Libraries/seekfree_libraries/headfile.h +++ b/Example/LED_Blink_Demo/Libraries/seekfree_libraries/headfile.h @@ -65,6 +65,7 @@ #include "SEEKFREE_7725.h" #include "SEEKFREE_RDA5807.h" #include "SEEKFREE_7725_UART.h" +#include "SEEKFREE_BLUETOOTH_CH9141.h" #endif diff --git a/Example/LED_Blink_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.c b/Example/LED_Blink_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.c new file mode 100644 index 0000000..b4ec2df --- /dev/null +++ b/Example/LED_Blink_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.c @@ -0,0 +1,509 @@ +/********************************************************************************************************************* + * COPYRIGHT NOTICE + * Copyright (c) 2021,ɿƼ + * All rights reserved. + * QQȺһȺ179029047() Ⱥ244861897 + * + * ݰȨɿƼУδҵ; + * ӭλʹò޸ʱ뱣ɿƼİȨ + * + * @file ɿƼתģ + * @company ɶɿƼ޹˾ + * @author ɿƼ(QQ3184284598) + * @version 鿴docversionļ 汾˵ + * @Software IAR 8.3 or MDK 5.33 + * @Taobao https://seekfree.taobao.com/ + * @date 2021-08-27 + * @note + ߶壺 + ------------------------------------ + ת Ƭ + RX 鿴SEEKFREE_BLUETOOTH_CH9141.hļеBLUETOOTH_CH9141_UART_TX궨 + TX 鿴SEEKFREE_BLUETOOTH_CH9141.hļеBLUETOOTH_CH9141_UART_RX궨 + RTS 鿴SEEKFREE_BLUETOOTH_CH9141.hļеBLUETOOTH_CH9141_RTS_PIN궨 + CTS + CMD ջ + ------------------------------------ + ********************************************************************************************************************/ +#include "zf_stm_systick.h" +#include "zf_gpio.h" +#include "zf_uart.h" +#include "zf_assert.h" +#include "SEEKFREE_BLUETOOTH_CH9141.h" + +uint8 uart_flag; +uint8 uart_data; + +vuint8 at_mode = 0; //0:͸ģʽ 1:ATģʽ 2:ģ鸴λ +vuint8 at_mode_num; //atģʽʱָʾݽյ +vuint8 at_mode_data[30]; //atĻ +vuint8 at_mode_cmd_flag; //OKӦճɹı־λ + +uint8 mac_address[17]; //macַ + + +uint8 bluetooth_ch9141_rx_buffer; + + +void bluetooth_ch9141_check_response(void); + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ жϻص +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note úISRļ 8жϳ򱻵 +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_uart_callback() +{ + while(uart_query(BLUETOOTH_CH9141_UART, &bluetooth_ch9141_rx_buffer)) + { + if(1 == at_mode) + { + //ATģʽ Ӧź ˴ifڴûҪĶ + at_mode_data[at_mode_num++] = bluetooth_ch9141_rx_buffer; + bluetooth_ch9141_check_response(); + } + else if(2 == at_mode) + { + //ģڸλ ˴ifڴûҪĶ + at_mode_num++; + } + else + { + //͸ģʽ ûڴ˴Ե͹Ķ + //ӵһֽںƬ˴ͨڴ˴ȡbluetooth_ch9141_rx_bufferȡ + + // ȡߴڵ λձ־ + uart_flag = 1; + uart_data = bluetooth_ch9141_rx_buffer; + } + + } +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģOKӦź +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note û +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_check_response(void) +{ + if(4 <= at_mode_num) + { + if(0 == strncmp("OK\r\n", (int8 *)&at_mode_data[at_mode_num-4], 4)) + { + at_mode_cmd_flag = 1; + } + } +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ鷢һûвȴӦź +// @param *str Ҫ͵ ַ +// @return void +// @since v1.0 +// Sample usage: +// @note û +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_send_at_command(const int8 *str) +{ + at_mode_num = 0; // + uart_putstr(BLUETOOTH_CH9141_UART, str); + uart_putstr(BLUETOOTH_CH9141_UART, "\r\n"); + + //ȴյӦź + while(!at_mode_cmd_flag); + at_mode_cmd_flag = 0; +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ鷢һвȴӦź +// @param *cmd Ҫ͵ +// @param *data Ҫ͵ +// @return void +// @since v1.0 +// Sample usage: +// @note û +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_send_at_command_parameter(const int8 *cmd, const int8 *data) +{ + at_mode_num = 0; // + uart_putstr(BLUETOOTH_CH9141_UART, "AT+"); + uart_putstr(BLUETOOTH_CH9141_UART, cmd); + uart_putstr(BLUETOOTH_CH9141_UART, "="); + uart_putstr(BLUETOOTH_CH9141_UART, data); + uart_putstr(BLUETOOTH_CH9141_UART, "\r\n"); + + //ȴյӦź + while(!at_mode_cmd_flag); + at_mode_cmd_flag = 0; +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģATģʽ +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_enter_at_mode(void) +{ + systick_delay_ms(STM0, 550); //ͽATģʽǰҪ֤ģ550msûнչκ + at_mode = 1; //ATģʽ + bluetooth_ch9141_send_at_command("AT..."); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ˳ATģʽ +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_exit_at_mode(void) +{ + bluetooth_ch9141_send_at_command("AT+EXIT"); + at_mode = 0; //͸ģʽ + systick_delay_ms(STM0, 300); //ȴɹATģʽ +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ鸴λ +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_reset(void) +{ + bluetooth_ch9141_send_at_command("AT+RESET"); + at_mode = 2; //ɹ + at_mode_num = 0; + while(7 > at_mode_num); //ȴģɸλ + at_mode = 0; //λ֮ģԶ͸ģʽ +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģȡMACַ +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note ô˺Ҫȵbluetooth_ch9141_enter_at_modeCMD ATģʽ +// Ҫرעbluetooth_ch9141_enter_at_modeڲ500msʱ +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_get_mac_address(void) +{ + bluetooth_ch9141_send_at_command("AT+MAC?"); + + //macַΪСθʽmac_address[0]macַλ + memcpy(mac_address, (uint8 *)at_mode_data, 17); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ÷͹ +// @param tx_power ÷͹ʣѡ鿴CH9141_TX_POWEER_enumöٳԱ +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_set_tx_power(CH9141_TX_POWEER_enum tx_power) +{ + int8 tx_power_data; + + tx_power_data = (uint8)tx_power + '0'; + bluetooth_ch9141_send_at_command_parameter("TPL", &tx_power_data); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģģʽ +// @param mode ģʽãѡ鿴CH9141_MODE_enumöٳԱ +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_set_mode(CH9141_MODE_enum mode) +{ + int8 mode_data; + + mode_data = (uint8)mode + '0'; + bluetooth_ch9141_send_at_command_parameter("BLEMODE", &mode_data); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģȡ״̬ +// @param mode ģʽãѡ鿴CH9141_MODE_enumöٳԱ +// @return CH9141_STATUS_enum ״̬Ϣ +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +CH9141_STATUS_enum bluetooth_ch9141_get_status(CH9141_MODE_enum mode) +{ + CH9141_STATUS_enum ch9141_status; + int8 mode_data; + + mode_data = (uint8)mode + '0'; + bluetooth_ch9141_send_at_command_parameter("BLEMODE", &mode_data); + + bluetooth_ch9141_send_at_command("AT+BLESTA?"); + + ch9141_status = (at_mode_data[0] - '0') * 10 + (at_mode_data[1] - '0'); + if(SLAVE_MODE == mode) + { + ch9141_status += SLAVE_NO_INIT; + } + + return ch9141_status; +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ豸 +// @param *str +// @return void +// @since v1.0 +// Sample usage: +// @note ƳȲܳ18ַ ֻΪӢ +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_set_name(const int8 *str) +{ + bluetooth_ch9141_send_at_command_parameter("NAME", str); + bluetooth_ch9141_send_at_command_parameter("PNAME", str); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ +// @param enable ʹ 0ʹ룬1ʹӱ豸 +// @param *password ַ Ϊ6ַ +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_set_password(uint8 enable, const int8 *password) +{ + if(0 == enable) + { + //ر + bluetooth_ch9141_send_at_command_parameter("PASEN", "OFF"); + } + else + { + //벢ʹ + bluetooth_ch9141_send_at_command_parameter("PASEN", "ON"); + bluetooth_ch9141_send_at_command_parameter("PASS", password); + } +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģָMACַ +// @param *mac_and_password Ҫӵ豸macַ +// @return void +// @since v1.0 +// Sample usage: +// @note bluetooth_ch9141_connect("58:B7:33:E4:C2:84,000000"); +// 58:B7:33:E4:C2:84Ϊmacַ ,Ϊָ 000000Ϊӻ +// ===================رע================== +// ʹֻ鿴macַʹñӵʱ뽫macһ +// ֻ鿴macַΪ61:62:63:64:65:66ʹñӵʱӦд +// bluetooth_ch9141_connect("66:65:64:63:62:61,000000"); +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_connect(const int8 *mac_and_password) +{ + bluetooth_ch9141_send_at_command_parameter("CONN", mac_and_password); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģĬӲãúúÿοԶ豸 +// @param *mac_and_password Ҫӵ豸macַ +// @return void +// @since v1.0 +// Sample usage: +// @note bluetooth_ch9141_default_connect("58:B7:33:E4:C2:84,000000"); +// 58:B7:33:E4:C2:84Ϊmacַ ,Ϊָ 000000Ϊӻ +// ===================رע================== +// ʹֻ鿴CH9141macַCH9141Ϊӻʹֻ +// ʹñӵʱ뽫macһ +// ֻ鿴macַΪ61:62:63:64:65:67ʹñӵʱӦд +// bluetooth_ch9141_default_connect("67:65:64:63:62:61,000000"); +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_default_connect(const int8 *mac_and_password) +{ + bluetooth_ch9141_send_at_command_parameter("CONADD", mac_and_password); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģȡrssi(źǿ) +// @param void +// @return int8 źǿ0-127 +// @since v1.0 +// Sample usage: +// @note ô˺Ҫȵbluetooth_ch9141_enter_at_modeCMD ATģʽ +// Ҫرעbluetooth_ch9141_enter_at_modeڲ500msʱ +//------------------------------------------------------------------------------------------------------------------- +int16 bluetooth_ch9141_get_rssi(void) +{ + uint8 i; + size_t length; + int16 rssi; + bluetooth_ch9141_send_at_command_parameter("RSSI", "ON,0"); + length = strlen((int8 *)at_mode_data); + length -= 12;//RSSI жλ + + rssi = 0; + for(i=0; i30) { - if(gpio_get(RTS_PIN)) - { - return len;//ģæ,ǰʹwhileȴ ʹúע͵whileȴ滻if - } - //while(gpio_get(RTS_PIN)); //RTSΪ͵ƽ +// if(gpio_get(RTS_PIN)) +// { +// return len;//ģæ,ǰʹwhileȴ ʹúע͵whileȴ滻if +// } + while(gpio_get(RTS_PIN)); //RTSΪ͵ƽ uart_putbuff(WIRELESS_UART,buff,30); buff += 30; //ַƫ len -= 30;// } - if(gpio_get(RTS_PIN)) - { - return len;//ģæ,ǰʹwhileȴ ʹúע͵whileȴ滻if - } - //while(gpio_get(RTS_PIN)); //RTSΪ͵ƽ +// if(gpio_get(RTS_PIN)) +// { +// return len;//ģæ,ǰʹwhileȴ ʹúע͵whileȴ滻if +// } + while(gpio_get(RTS_PIN)); //RTSΪ͵ƽ uart_putbuff(WIRELESS_UART,buff,len);// return 0; diff --git a/Example/LED_Blink_Demo/Libraries/seekfree_peripheral/SEEKFREE_WIRELESS.h b/Example/LED_Blink_Demo/Libraries/seekfree_peripheral/SEEKFREE_WIRELESS.h index 42c0832..d80339d 100644 --- a/Example/LED_Blink_Demo/Libraries/seekfree_peripheral/SEEKFREE_WIRELESS.h +++ b/Example/LED_Blink_Demo/Libraries/seekfree_peripheral/SEEKFREE_WIRELESS.h @@ -38,8 +38,26 @@ #define WIRELESS_UART_RX UART2_RX_P10_6 #define WIRELESS_UART_BAUD 115200 -#define RTS_PIN P10_2 //λ ָʾǰģǷԽ 0Լ 1Լ +// ------------------------------------ Զ ------------------------------------ +// ע1תģ汾V2.0µ޷Զʵġ +// ע2ԶRTSţῪʧܡ +// ע3ģԶʧܵĻԳԶϵ +// ԶĶ ע +// ԶĶ ע +// ԶĶ ע + +// 0رԶ +// 1Զ Զʵ޸WIRELESS_UART_BAUD֮ҪģãģԶΪӦIJ + +#define WIRELESS_AUTO_UART_BAUD 0 +// ------------------------------------ Զ ------------------------------------ + +#define RTS_PIN P10_2 //λ ָʾǰģǷԽ 0Լ 1Լ +#define WIRELESS_BUFFER_SIZE 16 + +extern uint8 wireless_send_buffer[WIRELESS_BUFFER_SIZE]; +extern uint32 wireless_rx_index; void wireless_uart_callback(void); void seekfree_wireless_init(void); diff --git a/Example/LED_Blink_Demo/USER/isr.c b/Example/LED_Blink_Demo/USER/isr.c index c55a012..16bff98 100644 --- a/Example/LED_Blink_Demo/USER/isr.c +++ b/Example/LED_Blink_Demo/USER/isr.c @@ -179,7 +179,20 @@ IFX_INTERRUPT(uart2_rx_isr, 0, UART2_RX_INT_PRIO) { enableInterrupts();//жǶ IfxAsclin_Asc_isrReceive(&uart2_handle); - wireless_uart_callback(); + switch(wireless_type) + { + case WIRELESS_SI24R1: + { + wireless_uart_callback(); + }break; + + case WIRELESS_CH9141: + { + bluetooth_ch9141_uart_callback(); + }break; + default:break; + } + } IFX_INTERRUPT(uart2_er_isr, 0, UART2_ER_INT_PRIO) { diff --git a/Example/LED_Blink_Demo/删除临时文件.bat b/Example/LED_Blink_Demo/删除临时文件.bat index 5323dd9..fa499b1 100644 --- a/Example/LED_Blink_Demo/删除临时文件.bat +++ b/Example/LED_Blink_Demo/删除临时文件.bat @@ -1,9 +1,6 @@ -rmdir .settings /s /q rmdir Debug /s /q del *.launch /s - -pause exit diff --git a/Example/PIT_Demo/.cproject b/Example/PIT_Demo/.cproject index 0619901..7c6eeb0 100644 --- a/Example/PIT_Demo/.cproject +++ b/Example/PIT_Demo/.cproject @@ -3,9 +3,9 @@ - + - + @@ -25,50 +25,76 @@ - + - + - + - + + + + + + @@ -355,9 +371,9 @@ - + - + @@ -377,43 +393,1895 @@ - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -431,13 +2299,37 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + @@ -458,21 +2350,5 @@ - - - - - - - - - - - - - - - - diff --git a/Example/PIT_Demo/.project b/Example/PIT_Demo/.project index 726de88..a8071fe 100644 --- a/Example/PIT_Demo/.project +++ b/Example/PIT_Demo/.project @@ -5,6 +5,18 @@ + + com.infineon.aurix.buildsystem.builders.booster + full,incremental, + + + + + com.infineon.aurix.buildsystem.builders.autodiscovery + full,incremental, + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder clean,full,incremental, diff --git a/Example/PIT_Demo/.settings/com.infineon.aurix.buildsystem.prefs b/Example/PIT_Demo/.settings/com.infineon.aurix.buildsystem.prefs new file mode 100644 index 0000000..be61bc1 --- /dev/null +++ b/Example/PIT_Demo/.settings/com.infineon.aurix.buildsystem.prefs @@ -0,0 +1,10 @@ +AURIX-LIBRARY-PATH=Libraries/iLLD\#Libraries/Infra\#Libraries/Service +DEVICE-ID=TC26B +DEVICE-ID-FULL=TC26xD_B-Step +ILLD-SET=full +IncludesAutodiscovery=true +LIBRARIES-ROOT-PATH=Libraries +NEVER-EXCLUDE-FROM-BUILD=/Libraries/iLLD/TC26B/Tricore/Cpu/CStart\#/Libraries/iLLD/TC26B/Tricore/Cpu/Trap\#/Configurations\#/Configurations/Debug +PROJECT-VERSION=1.0 +aurixDevice=TC26xD_B-Step +eclipse.preferences.version=1 diff --git a/Example/PIT_Demo/Libraries/doc/version.txt b/Example/PIT_Demo/Libraries/doc/version.txt index ab79909..11ab82e 100644 --- a/Example/PIT_Demo/Libraries/doc/version.txt +++ b/Example/PIT_Demo/Libraries/doc/version.txt @@ -1,3 +1,13 @@ +V1.2.0 + CH9141תģ + ͵öٱ + ޸ ɾʱļ.bat ִԶرմ + ޸ ɾʱļ.bat ɾ°汾ļ + ޸ĹĿļ֧°汾 + +V1.1.10 + ޸ͨ#pragma section all "cpux_dsram"ָλʧЧ + V1.1.9 ڵķbuffӵ128ֽ diff --git a/Example/PIT_Demo/Libraries/seekfree_libraries/common/common.c b/Example/PIT_Demo/Libraries/seekfree_libraries/common/common.c index 0b9931e..7620ce6 100644 --- a/Example/PIT_Demo/Libraries/seekfree_libraries/common/common.c +++ b/Example/PIT_Demo/Libraries/seekfree_libraries/common/common.c @@ -27,6 +27,8 @@ CAMERA_TYPE_enum camera_type; //ͷͺ uint8 *camera_buffer_addr; //ͷַ +WIRELESS_TYPE_enum wireless_type;//ת + IFX_ALIGN(4) IfxCpu_syncEvent g_cpuSyncEvent = 0;//¼ͬ App_Cpu0 g_AppCpu0; //ƵϢ diff --git a/Example/PIT_Demo/Libraries/seekfree_libraries/common/common.h b/Example/PIT_Demo/Libraries/seekfree_libraries/common/common.h index 84c43ee..5b741c0 100644 --- a/Example/PIT_Demo/Libraries/seekfree_libraries/common/common.h +++ b/Example/PIT_Demo/Libraries/seekfree_libraries/common/common.h @@ -113,6 +113,12 @@ typedef enum //ö CAMERA_COLOR, //ͫ }CAMERA_TYPE_enum; +typedef enum //ģ +{ + WIRELESS_SI24R1 = 1, //ת + WIRELESS_CH9141, //ת +}WIRELESS_TYPE_enum; + #include #include #include "IfxCpu.h" @@ -120,6 +126,8 @@ typedef enum //ö extern CAMERA_TYPE_enum camera_type; //ͷͺ extern uint8 *camera_buffer_addr; //ͷַ +extern WIRELESS_TYPE_enum wireless_type; + extern IfxCpu_syncEvent g_cpuSyncEvent; void get_clk(void); diff --git a/Example/PIT_Demo/Libraries/seekfree_libraries/headfile.h b/Example/PIT_Demo/Libraries/seekfree_libraries/headfile.h index 404ee0a..b745302 100644 --- a/Example/PIT_Demo/Libraries/seekfree_libraries/headfile.h +++ b/Example/PIT_Demo/Libraries/seekfree_libraries/headfile.h @@ -65,6 +65,7 @@ #include "SEEKFREE_7725.h" #include "SEEKFREE_RDA5807.h" #include "SEEKFREE_7725_UART.h" +#include "SEEKFREE_BLUETOOTH_CH9141.h" #endif diff --git a/Example/PIT_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.c b/Example/PIT_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.c new file mode 100644 index 0000000..b4ec2df --- /dev/null +++ b/Example/PIT_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.c @@ -0,0 +1,509 @@ +/********************************************************************************************************************* + * COPYRIGHT NOTICE + * Copyright (c) 2021,ɿƼ + * All rights reserved. + * QQȺһȺ179029047() Ⱥ244861897 + * + * ݰȨɿƼУδҵ; + * ӭλʹò޸ʱ뱣ɿƼİȨ + * + * @file ɿƼתģ + * @company ɶɿƼ޹˾ + * @author ɿƼ(QQ3184284598) + * @version 鿴docversionļ 汾˵ + * @Software IAR 8.3 or MDK 5.33 + * @Taobao https://seekfree.taobao.com/ + * @date 2021-08-27 + * @note + ߶壺 + ------------------------------------ + ת Ƭ + RX 鿴SEEKFREE_BLUETOOTH_CH9141.hļеBLUETOOTH_CH9141_UART_TX궨 + TX 鿴SEEKFREE_BLUETOOTH_CH9141.hļеBLUETOOTH_CH9141_UART_RX궨 + RTS 鿴SEEKFREE_BLUETOOTH_CH9141.hļеBLUETOOTH_CH9141_RTS_PIN궨 + CTS + CMD ջ + ------------------------------------ + ********************************************************************************************************************/ +#include "zf_stm_systick.h" +#include "zf_gpio.h" +#include "zf_uart.h" +#include "zf_assert.h" +#include "SEEKFREE_BLUETOOTH_CH9141.h" + +uint8 uart_flag; +uint8 uart_data; + +vuint8 at_mode = 0; //0:͸ģʽ 1:ATģʽ 2:ģ鸴λ +vuint8 at_mode_num; //atģʽʱָʾݽյ +vuint8 at_mode_data[30]; //atĻ +vuint8 at_mode_cmd_flag; //OKӦճɹı־λ + +uint8 mac_address[17]; //macַ + + +uint8 bluetooth_ch9141_rx_buffer; + + +void bluetooth_ch9141_check_response(void); + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ жϻص +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note úISRļ 8жϳ򱻵 +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_uart_callback() +{ + while(uart_query(BLUETOOTH_CH9141_UART, &bluetooth_ch9141_rx_buffer)) + { + if(1 == at_mode) + { + //ATģʽ Ӧź ˴ifڴûҪĶ + at_mode_data[at_mode_num++] = bluetooth_ch9141_rx_buffer; + bluetooth_ch9141_check_response(); + } + else if(2 == at_mode) + { + //ģڸλ ˴ifڴûҪĶ + at_mode_num++; + } + else + { + //͸ģʽ ûڴ˴Ե͹Ķ + //ӵһֽںƬ˴ͨڴ˴ȡbluetooth_ch9141_rx_bufferȡ + + // ȡߴڵ λձ־ + uart_flag = 1; + uart_data = bluetooth_ch9141_rx_buffer; + } + + } +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģOKӦź +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note û +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_check_response(void) +{ + if(4 <= at_mode_num) + { + if(0 == strncmp("OK\r\n", (int8 *)&at_mode_data[at_mode_num-4], 4)) + { + at_mode_cmd_flag = 1; + } + } +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ鷢һûвȴӦź +// @param *str Ҫ͵ ַ +// @return void +// @since v1.0 +// Sample usage: +// @note û +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_send_at_command(const int8 *str) +{ + at_mode_num = 0; // + uart_putstr(BLUETOOTH_CH9141_UART, str); + uart_putstr(BLUETOOTH_CH9141_UART, "\r\n"); + + //ȴյӦź + while(!at_mode_cmd_flag); + at_mode_cmd_flag = 0; +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ鷢һвȴӦź +// @param *cmd Ҫ͵ +// @param *data Ҫ͵ +// @return void +// @since v1.0 +// Sample usage: +// @note û +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_send_at_command_parameter(const int8 *cmd, const int8 *data) +{ + at_mode_num = 0; // + uart_putstr(BLUETOOTH_CH9141_UART, "AT+"); + uart_putstr(BLUETOOTH_CH9141_UART, cmd); + uart_putstr(BLUETOOTH_CH9141_UART, "="); + uart_putstr(BLUETOOTH_CH9141_UART, data); + uart_putstr(BLUETOOTH_CH9141_UART, "\r\n"); + + //ȴյӦź + while(!at_mode_cmd_flag); + at_mode_cmd_flag = 0; +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģATģʽ +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_enter_at_mode(void) +{ + systick_delay_ms(STM0, 550); //ͽATģʽǰҪ֤ģ550msûнչκ + at_mode = 1; //ATģʽ + bluetooth_ch9141_send_at_command("AT..."); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ˳ATģʽ +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_exit_at_mode(void) +{ + bluetooth_ch9141_send_at_command("AT+EXIT"); + at_mode = 0; //͸ģʽ + systick_delay_ms(STM0, 300); //ȴɹATģʽ +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ鸴λ +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_reset(void) +{ + bluetooth_ch9141_send_at_command("AT+RESET"); + at_mode = 2; //ɹ + at_mode_num = 0; + while(7 > at_mode_num); //ȴģɸλ + at_mode = 0; //λ֮ģԶ͸ģʽ +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģȡMACַ +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note ô˺Ҫȵbluetooth_ch9141_enter_at_modeCMD ATģʽ +// Ҫرעbluetooth_ch9141_enter_at_modeڲ500msʱ +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_get_mac_address(void) +{ + bluetooth_ch9141_send_at_command("AT+MAC?"); + + //macַΪСθʽmac_address[0]macַλ + memcpy(mac_address, (uint8 *)at_mode_data, 17); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ÷͹ +// @param tx_power ÷͹ʣѡ鿴CH9141_TX_POWEER_enumöٳԱ +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_set_tx_power(CH9141_TX_POWEER_enum tx_power) +{ + int8 tx_power_data; + + tx_power_data = (uint8)tx_power + '0'; + bluetooth_ch9141_send_at_command_parameter("TPL", &tx_power_data); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģģʽ +// @param mode ģʽãѡ鿴CH9141_MODE_enumöٳԱ +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_set_mode(CH9141_MODE_enum mode) +{ + int8 mode_data; + + mode_data = (uint8)mode + '0'; + bluetooth_ch9141_send_at_command_parameter("BLEMODE", &mode_data); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģȡ״̬ +// @param mode ģʽãѡ鿴CH9141_MODE_enumöٳԱ +// @return CH9141_STATUS_enum ״̬Ϣ +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +CH9141_STATUS_enum bluetooth_ch9141_get_status(CH9141_MODE_enum mode) +{ + CH9141_STATUS_enum ch9141_status; + int8 mode_data; + + mode_data = (uint8)mode + '0'; + bluetooth_ch9141_send_at_command_parameter("BLEMODE", &mode_data); + + bluetooth_ch9141_send_at_command("AT+BLESTA?"); + + ch9141_status = (at_mode_data[0] - '0') * 10 + (at_mode_data[1] - '0'); + if(SLAVE_MODE == mode) + { + ch9141_status += SLAVE_NO_INIT; + } + + return ch9141_status; +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ豸 +// @param *str +// @return void +// @since v1.0 +// Sample usage: +// @note ƳȲܳ18ַ ֻΪӢ +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_set_name(const int8 *str) +{ + bluetooth_ch9141_send_at_command_parameter("NAME", str); + bluetooth_ch9141_send_at_command_parameter("PNAME", str); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ +// @param enable ʹ 0ʹ룬1ʹӱ豸 +// @param *password ַ Ϊ6ַ +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_set_password(uint8 enable, const int8 *password) +{ + if(0 == enable) + { + //ر + bluetooth_ch9141_send_at_command_parameter("PASEN", "OFF"); + } + else + { + //벢ʹ + bluetooth_ch9141_send_at_command_parameter("PASEN", "ON"); + bluetooth_ch9141_send_at_command_parameter("PASS", password); + } +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģָMACַ +// @param *mac_and_password Ҫӵ豸macַ +// @return void +// @since v1.0 +// Sample usage: +// @note bluetooth_ch9141_connect("58:B7:33:E4:C2:84,000000"); +// 58:B7:33:E4:C2:84Ϊmacַ ,Ϊָ 000000Ϊӻ +// ===================رע================== +// ʹֻ鿴macַʹñӵʱ뽫macһ +// ֻ鿴macַΪ61:62:63:64:65:66ʹñӵʱӦд +// bluetooth_ch9141_connect("66:65:64:63:62:61,000000"); +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_connect(const int8 *mac_and_password) +{ + bluetooth_ch9141_send_at_command_parameter("CONN", mac_and_password); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģĬӲãúúÿοԶ豸 +// @param *mac_and_password Ҫӵ豸macַ +// @return void +// @since v1.0 +// Sample usage: +// @note bluetooth_ch9141_default_connect("58:B7:33:E4:C2:84,000000"); +// 58:B7:33:E4:C2:84Ϊmacַ ,Ϊָ 000000Ϊӻ +// ===================رע================== +// ʹֻ鿴CH9141macַCH9141Ϊӻʹֻ +// ʹñӵʱ뽫macһ +// ֻ鿴macַΪ61:62:63:64:65:67ʹñӵʱӦд +// bluetooth_ch9141_default_connect("67:65:64:63:62:61,000000"); +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_default_connect(const int8 *mac_and_password) +{ + bluetooth_ch9141_send_at_command_parameter("CONADD", mac_and_password); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģȡrssi(źǿ) +// @param void +// @return int8 źǿ0-127 +// @since v1.0 +// Sample usage: +// @note ô˺Ҫȵbluetooth_ch9141_enter_at_modeCMD ATģʽ +// Ҫرעbluetooth_ch9141_enter_at_modeڲ500msʱ +//------------------------------------------------------------------------------------------------------------------- +int16 bluetooth_ch9141_get_rssi(void) +{ + uint8 i; + size_t length; + int16 rssi; + bluetooth_ch9141_send_at_command_parameter("RSSI", "ON,0"); + length = strlen((int8 *)at_mode_data); + length -= 12;//RSSI жλ + + rssi = 0; + for(i=0; i30) { - if(gpio_get(RTS_PIN)) - { - return len;//ģæ,ǰʹwhileȴ ʹúע͵whileȴ滻if - } - //while(gpio_get(RTS_PIN)); //RTSΪ͵ƽ +// if(gpio_get(RTS_PIN)) +// { +// return len;//ģæ,ǰʹwhileȴ ʹúע͵whileȴ滻if +// } + while(gpio_get(RTS_PIN)); //RTSΪ͵ƽ uart_putbuff(WIRELESS_UART,buff,30); buff += 30; //ַƫ len -= 30;// } - if(gpio_get(RTS_PIN)) - { - return len;//ģæ,ǰʹwhileȴ ʹúע͵whileȴ滻if - } - //while(gpio_get(RTS_PIN)); //RTSΪ͵ƽ +// if(gpio_get(RTS_PIN)) +// { +// return len;//ģæ,ǰʹwhileȴ ʹúע͵whileȴ滻if +// } + while(gpio_get(RTS_PIN)); //RTSΪ͵ƽ uart_putbuff(WIRELESS_UART,buff,len);// return 0; diff --git a/Example/PIT_Demo/Libraries/seekfree_peripheral/SEEKFREE_WIRELESS.h b/Example/PIT_Demo/Libraries/seekfree_peripheral/SEEKFREE_WIRELESS.h index 42c0832..d80339d 100644 --- a/Example/PIT_Demo/Libraries/seekfree_peripheral/SEEKFREE_WIRELESS.h +++ b/Example/PIT_Demo/Libraries/seekfree_peripheral/SEEKFREE_WIRELESS.h @@ -38,8 +38,26 @@ #define WIRELESS_UART_RX UART2_RX_P10_6 #define WIRELESS_UART_BAUD 115200 -#define RTS_PIN P10_2 //λ ָʾǰģǷԽ 0Լ 1Լ +// ------------------------------------ Զ ------------------------------------ +// ע1תģ汾V2.0µ޷Զʵġ +// ע2ԶRTSţῪʧܡ +// ע3ģԶʧܵĻԳԶϵ +// ԶĶ ע +// ԶĶ ע +// ԶĶ ע + +// 0رԶ +// 1Զ Զʵ޸WIRELESS_UART_BAUD֮ҪģãģԶΪӦIJ + +#define WIRELESS_AUTO_UART_BAUD 0 +// ------------------------------------ Զ ------------------------------------ + +#define RTS_PIN P10_2 //λ ָʾǰģǷԽ 0Լ 1Լ +#define WIRELESS_BUFFER_SIZE 16 + +extern uint8 wireless_send_buffer[WIRELESS_BUFFER_SIZE]; +extern uint32 wireless_rx_index; void wireless_uart_callback(void); void seekfree_wireless_init(void); diff --git a/Example/PIT_Demo/USER/isr.c b/Example/PIT_Demo/USER/isr.c index f345040..042670f 100644 --- a/Example/PIT_Demo/USER/isr.c +++ b/Example/PIT_Demo/USER/isr.c @@ -181,7 +181,20 @@ IFX_INTERRUPT(uart2_rx_isr, 0, UART2_RX_INT_PRIO) { enableInterrupts();//жǶ IfxAsclin_Asc_isrReceive(&uart2_handle); - wireless_uart_callback(); + switch(wireless_type) + { + case WIRELESS_SI24R1: + { + wireless_uart_callback(); + }break; + + case WIRELESS_CH9141: + { + bluetooth_ch9141_uart_callback(); + }break; + default:break; + } + } IFX_INTERRUPT(uart2_er_isr, 0, UART2_ER_INT_PRIO) { diff --git a/Example/PIT_Demo/删除临时文件.bat b/Example/PIT_Demo/删除临时文件.bat index 5323dd9..fa499b1 100644 --- a/Example/PIT_Demo/删除临时文件.bat +++ b/Example/PIT_Demo/删除临时文件.bat @@ -1,9 +1,6 @@ -rmdir .settings /s /q rmdir Debug /s /q del *.launch /s - -pause exit diff --git a/Example/PWM_Demo/.cproject b/Example/PWM_Demo/.cproject index e8a32f0..c0f7ed3 100644 --- a/Example/PWM_Demo/.cproject +++ b/Example/PWM_Demo/.cproject @@ -3,9 +3,9 @@ - + - + @@ -25,50 +25,76 @@ - + - + - + - + + + + + + @@ -355,9 +371,9 @@ - + - + @@ -377,43 +393,1895 @@ - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -431,13 +2299,37 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + @@ -458,21 +2350,5 @@ - - - - - - - - - - - - - - - - diff --git a/Example/PWM_Demo/.project b/Example/PWM_Demo/.project index d14ea9b..ca33250 100644 --- a/Example/PWM_Demo/.project +++ b/Example/PWM_Demo/.project @@ -5,6 +5,18 @@ + + com.infineon.aurix.buildsystem.builders.booster + full,incremental, + + + + + com.infineon.aurix.buildsystem.builders.autodiscovery + full,incremental, + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder clean,full,incremental, diff --git a/Example/PWM_Demo/.settings/com.infineon.aurix.buildsystem.prefs b/Example/PWM_Demo/.settings/com.infineon.aurix.buildsystem.prefs new file mode 100644 index 0000000..be61bc1 --- /dev/null +++ b/Example/PWM_Demo/.settings/com.infineon.aurix.buildsystem.prefs @@ -0,0 +1,10 @@ +AURIX-LIBRARY-PATH=Libraries/iLLD\#Libraries/Infra\#Libraries/Service +DEVICE-ID=TC26B +DEVICE-ID-FULL=TC26xD_B-Step +ILLD-SET=full +IncludesAutodiscovery=true +LIBRARIES-ROOT-PATH=Libraries +NEVER-EXCLUDE-FROM-BUILD=/Libraries/iLLD/TC26B/Tricore/Cpu/CStart\#/Libraries/iLLD/TC26B/Tricore/Cpu/Trap\#/Configurations\#/Configurations/Debug +PROJECT-VERSION=1.0 +aurixDevice=TC26xD_B-Step +eclipse.preferences.version=1 diff --git a/Example/PWM_Demo/Libraries/doc/version.txt b/Example/PWM_Demo/Libraries/doc/version.txt index ab79909..11ab82e 100644 --- a/Example/PWM_Demo/Libraries/doc/version.txt +++ b/Example/PWM_Demo/Libraries/doc/version.txt @@ -1,3 +1,13 @@ +V1.2.0 + CH9141תģ + ͵öٱ + ޸ ɾʱļ.bat ִԶرմ + ޸ ɾʱļ.bat ɾ°汾ļ + ޸ĹĿļ֧°汾 + +V1.1.10 + ޸ͨ#pragma section all "cpux_dsram"ָλʧЧ + V1.1.9 ڵķbuffӵ128ֽ diff --git a/Example/PWM_Demo/Libraries/seekfree_libraries/common/common.c b/Example/PWM_Demo/Libraries/seekfree_libraries/common/common.c index 0b9931e..7620ce6 100644 --- a/Example/PWM_Demo/Libraries/seekfree_libraries/common/common.c +++ b/Example/PWM_Demo/Libraries/seekfree_libraries/common/common.c @@ -27,6 +27,8 @@ CAMERA_TYPE_enum camera_type; //ͷͺ uint8 *camera_buffer_addr; //ͷַ +WIRELESS_TYPE_enum wireless_type;//ת + IFX_ALIGN(4) IfxCpu_syncEvent g_cpuSyncEvent = 0;//¼ͬ App_Cpu0 g_AppCpu0; //ƵϢ diff --git a/Example/PWM_Demo/Libraries/seekfree_libraries/common/common.h b/Example/PWM_Demo/Libraries/seekfree_libraries/common/common.h index 84c43ee..5b741c0 100644 --- a/Example/PWM_Demo/Libraries/seekfree_libraries/common/common.h +++ b/Example/PWM_Demo/Libraries/seekfree_libraries/common/common.h @@ -113,6 +113,12 @@ typedef enum //ö CAMERA_COLOR, //ͫ }CAMERA_TYPE_enum; +typedef enum //ģ +{ + WIRELESS_SI24R1 = 1, //ת + WIRELESS_CH9141, //ת +}WIRELESS_TYPE_enum; + #include #include #include "IfxCpu.h" @@ -120,6 +126,8 @@ typedef enum //ö extern CAMERA_TYPE_enum camera_type; //ͷͺ extern uint8 *camera_buffer_addr; //ͷַ +extern WIRELESS_TYPE_enum wireless_type; + extern IfxCpu_syncEvent g_cpuSyncEvent; void get_clk(void); diff --git a/Example/PWM_Demo/Libraries/seekfree_libraries/headfile.h b/Example/PWM_Demo/Libraries/seekfree_libraries/headfile.h index 404ee0a..b745302 100644 --- a/Example/PWM_Demo/Libraries/seekfree_libraries/headfile.h +++ b/Example/PWM_Demo/Libraries/seekfree_libraries/headfile.h @@ -65,6 +65,7 @@ #include "SEEKFREE_7725.h" #include "SEEKFREE_RDA5807.h" #include "SEEKFREE_7725_UART.h" +#include "SEEKFREE_BLUETOOTH_CH9141.h" #endif diff --git a/Example/PWM_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.c b/Example/PWM_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.c new file mode 100644 index 0000000..b4ec2df --- /dev/null +++ b/Example/PWM_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.c @@ -0,0 +1,509 @@ +/********************************************************************************************************************* + * COPYRIGHT NOTICE + * Copyright (c) 2021,ɿƼ + * All rights reserved. + * QQȺһȺ179029047() Ⱥ244861897 + * + * ݰȨɿƼУδҵ; + * ӭλʹò޸ʱ뱣ɿƼİȨ + * + * @file ɿƼתģ + * @company ɶɿƼ޹˾ + * @author ɿƼ(QQ3184284598) + * @version 鿴docversionļ 汾˵ + * @Software IAR 8.3 or MDK 5.33 + * @Taobao https://seekfree.taobao.com/ + * @date 2021-08-27 + * @note + ߶壺 + ------------------------------------ + ת Ƭ + RX 鿴SEEKFREE_BLUETOOTH_CH9141.hļеBLUETOOTH_CH9141_UART_TX궨 + TX 鿴SEEKFREE_BLUETOOTH_CH9141.hļеBLUETOOTH_CH9141_UART_RX궨 + RTS 鿴SEEKFREE_BLUETOOTH_CH9141.hļеBLUETOOTH_CH9141_RTS_PIN궨 + CTS + CMD ջ + ------------------------------------ + ********************************************************************************************************************/ +#include "zf_stm_systick.h" +#include "zf_gpio.h" +#include "zf_uart.h" +#include "zf_assert.h" +#include "SEEKFREE_BLUETOOTH_CH9141.h" + +uint8 uart_flag; +uint8 uart_data; + +vuint8 at_mode = 0; //0:͸ģʽ 1:ATģʽ 2:ģ鸴λ +vuint8 at_mode_num; //atģʽʱָʾݽյ +vuint8 at_mode_data[30]; //atĻ +vuint8 at_mode_cmd_flag; //OKӦճɹı־λ + +uint8 mac_address[17]; //macַ + + +uint8 bluetooth_ch9141_rx_buffer; + + +void bluetooth_ch9141_check_response(void); + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ жϻص +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note úISRļ 8жϳ򱻵 +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_uart_callback() +{ + while(uart_query(BLUETOOTH_CH9141_UART, &bluetooth_ch9141_rx_buffer)) + { + if(1 == at_mode) + { + //ATģʽ Ӧź ˴ifڴûҪĶ + at_mode_data[at_mode_num++] = bluetooth_ch9141_rx_buffer; + bluetooth_ch9141_check_response(); + } + else if(2 == at_mode) + { + //ģڸλ ˴ifڴûҪĶ + at_mode_num++; + } + else + { + //͸ģʽ ûڴ˴Ե͹Ķ + //ӵһֽںƬ˴ͨڴ˴ȡbluetooth_ch9141_rx_bufferȡ + + // ȡߴڵ λձ־ + uart_flag = 1; + uart_data = bluetooth_ch9141_rx_buffer; + } + + } +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģOKӦź +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note û +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_check_response(void) +{ + if(4 <= at_mode_num) + { + if(0 == strncmp("OK\r\n", (int8 *)&at_mode_data[at_mode_num-4], 4)) + { + at_mode_cmd_flag = 1; + } + } +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ鷢һûвȴӦź +// @param *str Ҫ͵ ַ +// @return void +// @since v1.0 +// Sample usage: +// @note û +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_send_at_command(const int8 *str) +{ + at_mode_num = 0; // + uart_putstr(BLUETOOTH_CH9141_UART, str); + uart_putstr(BLUETOOTH_CH9141_UART, "\r\n"); + + //ȴյӦź + while(!at_mode_cmd_flag); + at_mode_cmd_flag = 0; +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ鷢һвȴӦź +// @param *cmd Ҫ͵ +// @param *data Ҫ͵ +// @return void +// @since v1.0 +// Sample usage: +// @note û +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_send_at_command_parameter(const int8 *cmd, const int8 *data) +{ + at_mode_num = 0; // + uart_putstr(BLUETOOTH_CH9141_UART, "AT+"); + uart_putstr(BLUETOOTH_CH9141_UART, cmd); + uart_putstr(BLUETOOTH_CH9141_UART, "="); + uart_putstr(BLUETOOTH_CH9141_UART, data); + uart_putstr(BLUETOOTH_CH9141_UART, "\r\n"); + + //ȴյӦź + while(!at_mode_cmd_flag); + at_mode_cmd_flag = 0; +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģATģʽ +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_enter_at_mode(void) +{ + systick_delay_ms(STM0, 550); //ͽATģʽǰҪ֤ģ550msûнչκ + at_mode = 1; //ATģʽ + bluetooth_ch9141_send_at_command("AT..."); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ˳ATģʽ +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_exit_at_mode(void) +{ + bluetooth_ch9141_send_at_command("AT+EXIT"); + at_mode = 0; //͸ģʽ + systick_delay_ms(STM0, 300); //ȴɹATģʽ +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ鸴λ +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_reset(void) +{ + bluetooth_ch9141_send_at_command("AT+RESET"); + at_mode = 2; //ɹ + at_mode_num = 0; + while(7 > at_mode_num); //ȴģɸλ + at_mode = 0; //λ֮ģԶ͸ģʽ +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģȡMACַ +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note ô˺Ҫȵbluetooth_ch9141_enter_at_modeCMD ATģʽ +// Ҫرעbluetooth_ch9141_enter_at_modeڲ500msʱ +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_get_mac_address(void) +{ + bluetooth_ch9141_send_at_command("AT+MAC?"); + + //macַΪСθʽmac_address[0]macַλ + memcpy(mac_address, (uint8 *)at_mode_data, 17); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ÷͹ +// @param tx_power ÷͹ʣѡ鿴CH9141_TX_POWEER_enumöٳԱ +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_set_tx_power(CH9141_TX_POWEER_enum tx_power) +{ + int8 tx_power_data; + + tx_power_data = (uint8)tx_power + '0'; + bluetooth_ch9141_send_at_command_parameter("TPL", &tx_power_data); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģģʽ +// @param mode ģʽãѡ鿴CH9141_MODE_enumöٳԱ +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_set_mode(CH9141_MODE_enum mode) +{ + int8 mode_data; + + mode_data = (uint8)mode + '0'; + bluetooth_ch9141_send_at_command_parameter("BLEMODE", &mode_data); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģȡ״̬ +// @param mode ģʽãѡ鿴CH9141_MODE_enumöٳԱ +// @return CH9141_STATUS_enum ״̬Ϣ +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +CH9141_STATUS_enum bluetooth_ch9141_get_status(CH9141_MODE_enum mode) +{ + CH9141_STATUS_enum ch9141_status; + int8 mode_data; + + mode_data = (uint8)mode + '0'; + bluetooth_ch9141_send_at_command_parameter("BLEMODE", &mode_data); + + bluetooth_ch9141_send_at_command("AT+BLESTA?"); + + ch9141_status = (at_mode_data[0] - '0') * 10 + (at_mode_data[1] - '0'); + if(SLAVE_MODE == mode) + { + ch9141_status += SLAVE_NO_INIT; + } + + return ch9141_status; +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ豸 +// @param *str +// @return void +// @since v1.0 +// Sample usage: +// @note ƳȲܳ18ַ ֻΪӢ +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_set_name(const int8 *str) +{ + bluetooth_ch9141_send_at_command_parameter("NAME", str); + bluetooth_ch9141_send_at_command_parameter("PNAME", str); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ +// @param enable ʹ 0ʹ룬1ʹӱ豸 +// @param *password ַ Ϊ6ַ +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_set_password(uint8 enable, const int8 *password) +{ + if(0 == enable) + { + //ر + bluetooth_ch9141_send_at_command_parameter("PASEN", "OFF"); + } + else + { + //벢ʹ + bluetooth_ch9141_send_at_command_parameter("PASEN", "ON"); + bluetooth_ch9141_send_at_command_parameter("PASS", password); + } +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģָMACַ +// @param *mac_and_password Ҫӵ豸macַ +// @return void +// @since v1.0 +// Sample usage: +// @note bluetooth_ch9141_connect("58:B7:33:E4:C2:84,000000"); +// 58:B7:33:E4:C2:84Ϊmacַ ,Ϊָ 000000Ϊӻ +// ===================رע================== +// ʹֻ鿴macַʹñӵʱ뽫macһ +// ֻ鿴macַΪ61:62:63:64:65:66ʹñӵʱӦд +// bluetooth_ch9141_connect("66:65:64:63:62:61,000000"); +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_connect(const int8 *mac_and_password) +{ + bluetooth_ch9141_send_at_command_parameter("CONN", mac_and_password); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģĬӲãúúÿοԶ豸 +// @param *mac_and_password Ҫӵ豸macַ +// @return void +// @since v1.0 +// Sample usage: +// @note bluetooth_ch9141_default_connect("58:B7:33:E4:C2:84,000000"); +// 58:B7:33:E4:C2:84Ϊmacַ ,Ϊָ 000000Ϊӻ +// ===================رע================== +// ʹֻ鿴CH9141macַCH9141Ϊӻʹֻ +// ʹñӵʱ뽫macһ +// ֻ鿴macַΪ61:62:63:64:65:67ʹñӵʱӦд +// bluetooth_ch9141_default_connect("67:65:64:63:62:61,000000"); +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_default_connect(const int8 *mac_and_password) +{ + bluetooth_ch9141_send_at_command_parameter("CONADD", mac_and_password); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģȡrssi(źǿ) +// @param void +// @return int8 źǿ0-127 +// @since v1.0 +// Sample usage: +// @note ô˺Ҫȵbluetooth_ch9141_enter_at_modeCMD ATģʽ +// Ҫرעbluetooth_ch9141_enter_at_modeڲ500msʱ +//------------------------------------------------------------------------------------------------------------------- +int16 bluetooth_ch9141_get_rssi(void) +{ + uint8 i; + size_t length; + int16 rssi; + bluetooth_ch9141_send_at_command_parameter("RSSI", "ON,0"); + length = strlen((int8 *)at_mode_data); + length -= 12;//RSSI жλ + + rssi = 0; + for(i=0; i30) { - if(gpio_get(RTS_PIN)) - { - return len;//ģæ,ǰʹwhileȴ ʹúע͵whileȴ滻if - } - //while(gpio_get(RTS_PIN)); //RTSΪ͵ƽ +// if(gpio_get(RTS_PIN)) +// { +// return len;//ģæ,ǰʹwhileȴ ʹúע͵whileȴ滻if +// } + while(gpio_get(RTS_PIN)); //RTSΪ͵ƽ uart_putbuff(WIRELESS_UART,buff,30); buff += 30; //ַƫ len -= 30;// } - if(gpio_get(RTS_PIN)) - { - return len;//ģæ,ǰʹwhileȴ ʹúע͵whileȴ滻if - } - //while(gpio_get(RTS_PIN)); //RTSΪ͵ƽ +// if(gpio_get(RTS_PIN)) +// { +// return len;//ģæ,ǰʹwhileȴ ʹúע͵whileȴ滻if +// } + while(gpio_get(RTS_PIN)); //RTSΪ͵ƽ uart_putbuff(WIRELESS_UART,buff,len);// return 0; diff --git a/Example/PWM_Demo/Libraries/seekfree_peripheral/SEEKFREE_WIRELESS.h b/Example/PWM_Demo/Libraries/seekfree_peripheral/SEEKFREE_WIRELESS.h index 42c0832..d80339d 100644 --- a/Example/PWM_Demo/Libraries/seekfree_peripheral/SEEKFREE_WIRELESS.h +++ b/Example/PWM_Demo/Libraries/seekfree_peripheral/SEEKFREE_WIRELESS.h @@ -38,8 +38,26 @@ #define WIRELESS_UART_RX UART2_RX_P10_6 #define WIRELESS_UART_BAUD 115200 -#define RTS_PIN P10_2 //λ ָʾǰģǷԽ 0Լ 1Լ +// ------------------------------------ Զ ------------------------------------ +// ע1תģ汾V2.0µ޷Զʵġ +// ע2ԶRTSţῪʧܡ +// ע3ģԶʧܵĻԳԶϵ +// ԶĶ ע +// ԶĶ ע +// ԶĶ ע + +// 0رԶ +// 1Զ Զʵ޸WIRELESS_UART_BAUD֮ҪģãģԶΪӦIJ + +#define WIRELESS_AUTO_UART_BAUD 0 +// ------------------------------------ Զ ------------------------------------ + +#define RTS_PIN P10_2 //λ ָʾǰģǷԽ 0Լ 1Լ +#define WIRELESS_BUFFER_SIZE 16 + +extern uint8 wireless_send_buffer[WIRELESS_BUFFER_SIZE]; +extern uint32 wireless_rx_index; void wireless_uart_callback(void); void seekfree_wireless_init(void); diff --git a/Example/PWM_Demo/USER/isr.c b/Example/PWM_Demo/USER/isr.c index c55a012..16bff98 100644 --- a/Example/PWM_Demo/USER/isr.c +++ b/Example/PWM_Demo/USER/isr.c @@ -179,7 +179,20 @@ IFX_INTERRUPT(uart2_rx_isr, 0, UART2_RX_INT_PRIO) { enableInterrupts();//жǶ IfxAsclin_Asc_isrReceive(&uart2_handle); - wireless_uart_callback(); + switch(wireless_type) + { + case WIRELESS_SI24R1: + { + wireless_uart_callback(); + }break; + + case WIRELESS_CH9141: + { + bluetooth_ch9141_uart_callback(); + }break; + default:break; + } + } IFX_INTERRUPT(uart2_er_isr, 0, UART2_ER_INT_PRIO) { diff --git a/Example/PWM_Demo/删除临时文件.bat b/Example/PWM_Demo/删除临时文件.bat index 5323dd9..fa499b1 100644 --- a/Example/PWM_Demo/删除临时文件.bat +++ b/Example/PWM_Demo/删除临时文件.bat @@ -1,9 +1,6 @@ -rmdir .settings /s /q rmdir Debug /s /q del *.launch /s - -pause exit diff --git a/Example/Printf_Demo/.cproject b/Example/Printf_Demo/.cproject index 37fdd5a..8fa9ce2 100644 --- a/Example/Printf_Demo/.cproject +++ b/Example/Printf_Demo/.cproject @@ -3,9 +3,9 @@ - + - + @@ -25,50 +25,76 @@ - + - + - + - + + + + + + @@ -355,9 +371,9 @@ - + - + @@ -377,43 +393,1895 @@ - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -431,13 +2299,37 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + @@ -458,21 +2350,5 @@ - - - - - - - - - - - - - - - - diff --git a/Example/Printf_Demo/.project b/Example/Printf_Demo/.project index 679101d..9e0cf03 100644 --- a/Example/Printf_Demo/.project +++ b/Example/Printf_Demo/.project @@ -5,6 +5,18 @@ + + com.infineon.aurix.buildsystem.builders.booster + full,incremental, + + + + + com.infineon.aurix.buildsystem.builders.autodiscovery + full,incremental, + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder clean,full,incremental, diff --git a/Example/Printf_Demo/.settings/com.infineon.aurix.buildsystem.prefs b/Example/Printf_Demo/.settings/com.infineon.aurix.buildsystem.prefs new file mode 100644 index 0000000..be61bc1 --- /dev/null +++ b/Example/Printf_Demo/.settings/com.infineon.aurix.buildsystem.prefs @@ -0,0 +1,10 @@ +AURIX-LIBRARY-PATH=Libraries/iLLD\#Libraries/Infra\#Libraries/Service +DEVICE-ID=TC26B +DEVICE-ID-FULL=TC26xD_B-Step +ILLD-SET=full +IncludesAutodiscovery=true +LIBRARIES-ROOT-PATH=Libraries +NEVER-EXCLUDE-FROM-BUILD=/Libraries/iLLD/TC26B/Tricore/Cpu/CStart\#/Libraries/iLLD/TC26B/Tricore/Cpu/Trap\#/Configurations\#/Configurations/Debug +PROJECT-VERSION=1.0 +aurixDevice=TC26xD_B-Step +eclipse.preferences.version=1 diff --git a/Example/Printf_Demo/Libraries/doc/version.txt b/Example/Printf_Demo/Libraries/doc/version.txt index ab79909..11ab82e 100644 --- a/Example/Printf_Demo/Libraries/doc/version.txt +++ b/Example/Printf_Demo/Libraries/doc/version.txt @@ -1,3 +1,13 @@ +V1.2.0 + CH9141תģ + ͵öٱ + ޸ ɾʱļ.bat ִԶرմ + ޸ ɾʱļ.bat ɾ°汾ļ + ޸ĹĿļ֧°汾 + +V1.1.10 + ޸ͨ#pragma section all "cpux_dsram"ָλʧЧ + V1.1.9 ڵķbuffӵ128ֽ diff --git a/Example/Printf_Demo/Libraries/seekfree_libraries/common/common.c b/Example/Printf_Demo/Libraries/seekfree_libraries/common/common.c index 0b9931e..7620ce6 100644 --- a/Example/Printf_Demo/Libraries/seekfree_libraries/common/common.c +++ b/Example/Printf_Demo/Libraries/seekfree_libraries/common/common.c @@ -27,6 +27,8 @@ CAMERA_TYPE_enum camera_type; //ͷͺ uint8 *camera_buffer_addr; //ͷַ +WIRELESS_TYPE_enum wireless_type;//ת + IFX_ALIGN(4) IfxCpu_syncEvent g_cpuSyncEvent = 0;//¼ͬ App_Cpu0 g_AppCpu0; //ƵϢ diff --git a/Example/Printf_Demo/Libraries/seekfree_libraries/common/common.h b/Example/Printf_Demo/Libraries/seekfree_libraries/common/common.h index 84c43ee..5b741c0 100644 --- a/Example/Printf_Demo/Libraries/seekfree_libraries/common/common.h +++ b/Example/Printf_Demo/Libraries/seekfree_libraries/common/common.h @@ -113,6 +113,12 @@ typedef enum //ö CAMERA_COLOR, //ͫ }CAMERA_TYPE_enum; +typedef enum //ģ +{ + WIRELESS_SI24R1 = 1, //ת + WIRELESS_CH9141, //ת +}WIRELESS_TYPE_enum; + #include #include #include "IfxCpu.h" @@ -120,6 +126,8 @@ typedef enum //ö extern CAMERA_TYPE_enum camera_type; //ͷͺ extern uint8 *camera_buffer_addr; //ͷַ +extern WIRELESS_TYPE_enum wireless_type; + extern IfxCpu_syncEvent g_cpuSyncEvent; void get_clk(void); diff --git a/Example/Printf_Demo/Libraries/seekfree_libraries/headfile.h b/Example/Printf_Demo/Libraries/seekfree_libraries/headfile.h index 404ee0a..b745302 100644 --- a/Example/Printf_Demo/Libraries/seekfree_libraries/headfile.h +++ b/Example/Printf_Demo/Libraries/seekfree_libraries/headfile.h @@ -65,6 +65,7 @@ #include "SEEKFREE_7725.h" #include "SEEKFREE_RDA5807.h" #include "SEEKFREE_7725_UART.h" +#include "SEEKFREE_BLUETOOTH_CH9141.h" #endif diff --git a/Example/Printf_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.c b/Example/Printf_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.c new file mode 100644 index 0000000..b4ec2df --- /dev/null +++ b/Example/Printf_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.c @@ -0,0 +1,509 @@ +/********************************************************************************************************************* + * COPYRIGHT NOTICE + * Copyright (c) 2021,ɿƼ + * All rights reserved. + * QQȺһȺ179029047() Ⱥ244861897 + * + * ݰȨɿƼУδҵ; + * ӭλʹò޸ʱ뱣ɿƼİȨ + * + * @file ɿƼתģ + * @company ɶɿƼ޹˾ + * @author ɿƼ(QQ3184284598) + * @version 鿴docversionļ 汾˵ + * @Software IAR 8.3 or MDK 5.33 + * @Taobao https://seekfree.taobao.com/ + * @date 2021-08-27 + * @note + ߶壺 + ------------------------------------ + ת Ƭ + RX 鿴SEEKFREE_BLUETOOTH_CH9141.hļеBLUETOOTH_CH9141_UART_TX궨 + TX 鿴SEEKFREE_BLUETOOTH_CH9141.hļеBLUETOOTH_CH9141_UART_RX궨 + RTS 鿴SEEKFREE_BLUETOOTH_CH9141.hļеBLUETOOTH_CH9141_RTS_PIN궨 + CTS + CMD ջ + ------------------------------------ + ********************************************************************************************************************/ +#include "zf_stm_systick.h" +#include "zf_gpio.h" +#include "zf_uart.h" +#include "zf_assert.h" +#include "SEEKFREE_BLUETOOTH_CH9141.h" + +uint8 uart_flag; +uint8 uart_data; + +vuint8 at_mode = 0; //0:͸ģʽ 1:ATģʽ 2:ģ鸴λ +vuint8 at_mode_num; //atģʽʱָʾݽյ +vuint8 at_mode_data[30]; //atĻ +vuint8 at_mode_cmd_flag; //OKӦճɹı־λ + +uint8 mac_address[17]; //macַ + + +uint8 bluetooth_ch9141_rx_buffer; + + +void bluetooth_ch9141_check_response(void); + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ жϻص +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note úISRļ 8жϳ򱻵 +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_uart_callback() +{ + while(uart_query(BLUETOOTH_CH9141_UART, &bluetooth_ch9141_rx_buffer)) + { + if(1 == at_mode) + { + //ATģʽ Ӧź ˴ifڴûҪĶ + at_mode_data[at_mode_num++] = bluetooth_ch9141_rx_buffer; + bluetooth_ch9141_check_response(); + } + else if(2 == at_mode) + { + //ģڸλ ˴ifڴûҪĶ + at_mode_num++; + } + else + { + //͸ģʽ ûڴ˴Ե͹Ķ + //ӵһֽںƬ˴ͨڴ˴ȡbluetooth_ch9141_rx_bufferȡ + + // ȡߴڵ λձ־ + uart_flag = 1; + uart_data = bluetooth_ch9141_rx_buffer; + } + + } +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģOKӦź +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note û +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_check_response(void) +{ + if(4 <= at_mode_num) + { + if(0 == strncmp("OK\r\n", (int8 *)&at_mode_data[at_mode_num-4], 4)) + { + at_mode_cmd_flag = 1; + } + } +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ鷢һûвȴӦź +// @param *str Ҫ͵ ַ +// @return void +// @since v1.0 +// Sample usage: +// @note û +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_send_at_command(const int8 *str) +{ + at_mode_num = 0; // + uart_putstr(BLUETOOTH_CH9141_UART, str); + uart_putstr(BLUETOOTH_CH9141_UART, "\r\n"); + + //ȴյӦź + while(!at_mode_cmd_flag); + at_mode_cmd_flag = 0; +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ鷢һвȴӦź +// @param *cmd Ҫ͵ +// @param *data Ҫ͵ +// @return void +// @since v1.0 +// Sample usage: +// @note û +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_send_at_command_parameter(const int8 *cmd, const int8 *data) +{ + at_mode_num = 0; // + uart_putstr(BLUETOOTH_CH9141_UART, "AT+"); + uart_putstr(BLUETOOTH_CH9141_UART, cmd); + uart_putstr(BLUETOOTH_CH9141_UART, "="); + uart_putstr(BLUETOOTH_CH9141_UART, data); + uart_putstr(BLUETOOTH_CH9141_UART, "\r\n"); + + //ȴյӦź + while(!at_mode_cmd_flag); + at_mode_cmd_flag = 0; +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģATģʽ +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_enter_at_mode(void) +{ + systick_delay_ms(STM0, 550); //ͽATģʽǰҪ֤ģ550msûнչκ + at_mode = 1; //ATģʽ + bluetooth_ch9141_send_at_command("AT..."); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ˳ATģʽ +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_exit_at_mode(void) +{ + bluetooth_ch9141_send_at_command("AT+EXIT"); + at_mode = 0; //͸ģʽ + systick_delay_ms(STM0, 300); //ȴɹATģʽ +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ鸴λ +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_reset(void) +{ + bluetooth_ch9141_send_at_command("AT+RESET"); + at_mode = 2; //ɹ + at_mode_num = 0; + while(7 > at_mode_num); //ȴģɸλ + at_mode = 0; //λ֮ģԶ͸ģʽ +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģȡMACַ +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note ô˺Ҫȵbluetooth_ch9141_enter_at_modeCMD ATģʽ +// Ҫرעbluetooth_ch9141_enter_at_modeڲ500msʱ +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_get_mac_address(void) +{ + bluetooth_ch9141_send_at_command("AT+MAC?"); + + //macַΪСθʽmac_address[0]macַλ + memcpy(mac_address, (uint8 *)at_mode_data, 17); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ÷͹ +// @param tx_power ÷͹ʣѡ鿴CH9141_TX_POWEER_enumöٳԱ +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_set_tx_power(CH9141_TX_POWEER_enum tx_power) +{ + int8 tx_power_data; + + tx_power_data = (uint8)tx_power + '0'; + bluetooth_ch9141_send_at_command_parameter("TPL", &tx_power_data); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģģʽ +// @param mode ģʽãѡ鿴CH9141_MODE_enumöٳԱ +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_set_mode(CH9141_MODE_enum mode) +{ + int8 mode_data; + + mode_data = (uint8)mode + '0'; + bluetooth_ch9141_send_at_command_parameter("BLEMODE", &mode_data); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģȡ״̬ +// @param mode ģʽãѡ鿴CH9141_MODE_enumöٳԱ +// @return CH9141_STATUS_enum ״̬Ϣ +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +CH9141_STATUS_enum bluetooth_ch9141_get_status(CH9141_MODE_enum mode) +{ + CH9141_STATUS_enum ch9141_status; + int8 mode_data; + + mode_data = (uint8)mode + '0'; + bluetooth_ch9141_send_at_command_parameter("BLEMODE", &mode_data); + + bluetooth_ch9141_send_at_command("AT+BLESTA?"); + + ch9141_status = (at_mode_data[0] - '0') * 10 + (at_mode_data[1] - '0'); + if(SLAVE_MODE == mode) + { + ch9141_status += SLAVE_NO_INIT; + } + + return ch9141_status; +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ豸 +// @param *str +// @return void +// @since v1.0 +// Sample usage: +// @note ƳȲܳ18ַ ֻΪӢ +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_set_name(const int8 *str) +{ + bluetooth_ch9141_send_at_command_parameter("NAME", str); + bluetooth_ch9141_send_at_command_parameter("PNAME", str); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ +// @param enable ʹ 0ʹ룬1ʹӱ豸 +// @param *password ַ Ϊ6ַ +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_set_password(uint8 enable, const int8 *password) +{ + if(0 == enable) + { + //ر + bluetooth_ch9141_send_at_command_parameter("PASEN", "OFF"); + } + else + { + //벢ʹ + bluetooth_ch9141_send_at_command_parameter("PASEN", "ON"); + bluetooth_ch9141_send_at_command_parameter("PASS", password); + } +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģָMACַ +// @param *mac_and_password Ҫӵ豸macַ +// @return void +// @since v1.0 +// Sample usage: +// @note bluetooth_ch9141_connect("58:B7:33:E4:C2:84,000000"); +// 58:B7:33:E4:C2:84Ϊmacַ ,Ϊָ 000000Ϊӻ +// ===================رע================== +// ʹֻ鿴macַʹñӵʱ뽫macһ +// ֻ鿴macַΪ61:62:63:64:65:66ʹñӵʱӦд +// bluetooth_ch9141_connect("66:65:64:63:62:61,000000"); +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_connect(const int8 *mac_and_password) +{ + bluetooth_ch9141_send_at_command_parameter("CONN", mac_and_password); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģĬӲãúúÿοԶ豸 +// @param *mac_and_password Ҫӵ豸macַ +// @return void +// @since v1.0 +// Sample usage: +// @note bluetooth_ch9141_default_connect("58:B7:33:E4:C2:84,000000"); +// 58:B7:33:E4:C2:84Ϊmacַ ,Ϊָ 000000Ϊӻ +// ===================رע================== +// ʹֻ鿴CH9141macַCH9141Ϊӻʹֻ +// ʹñӵʱ뽫macһ +// ֻ鿴macַΪ61:62:63:64:65:67ʹñӵʱӦд +// bluetooth_ch9141_default_connect("67:65:64:63:62:61,000000"); +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_default_connect(const int8 *mac_and_password) +{ + bluetooth_ch9141_send_at_command_parameter("CONADD", mac_and_password); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģȡrssi(źǿ) +// @param void +// @return int8 źǿ0-127 +// @since v1.0 +// Sample usage: +// @note ô˺Ҫȵbluetooth_ch9141_enter_at_modeCMD ATģʽ +// Ҫرעbluetooth_ch9141_enter_at_modeڲ500msʱ +//------------------------------------------------------------------------------------------------------------------- +int16 bluetooth_ch9141_get_rssi(void) +{ + uint8 i; + size_t length; + int16 rssi; + bluetooth_ch9141_send_at_command_parameter("RSSI", "ON,0"); + length = strlen((int8 *)at_mode_data); + length -= 12;//RSSI жλ + + rssi = 0; + for(i=0; i30) { - if(gpio_get(RTS_PIN)) - { - return len;//ģæ,ǰʹwhileȴ ʹúע͵whileȴ滻if - } - //while(gpio_get(RTS_PIN)); //RTSΪ͵ƽ +// if(gpio_get(RTS_PIN)) +// { +// return len;//ģæ,ǰʹwhileȴ ʹúע͵whileȴ滻if +// } + while(gpio_get(RTS_PIN)); //RTSΪ͵ƽ uart_putbuff(WIRELESS_UART,buff,30); buff += 30; //ַƫ len -= 30;// } - if(gpio_get(RTS_PIN)) - { - return len;//ģæ,ǰʹwhileȴ ʹúע͵whileȴ滻if - } - //while(gpio_get(RTS_PIN)); //RTSΪ͵ƽ +// if(gpio_get(RTS_PIN)) +// { +// return len;//ģæ,ǰʹwhileȴ ʹúע͵whileȴ滻if +// } + while(gpio_get(RTS_PIN)); //RTSΪ͵ƽ uart_putbuff(WIRELESS_UART,buff,len);// return 0; diff --git a/Example/Printf_Demo/Libraries/seekfree_peripheral/SEEKFREE_WIRELESS.h b/Example/Printf_Demo/Libraries/seekfree_peripheral/SEEKFREE_WIRELESS.h index 42c0832..d80339d 100644 --- a/Example/Printf_Demo/Libraries/seekfree_peripheral/SEEKFREE_WIRELESS.h +++ b/Example/Printf_Demo/Libraries/seekfree_peripheral/SEEKFREE_WIRELESS.h @@ -38,8 +38,26 @@ #define WIRELESS_UART_RX UART2_RX_P10_6 #define WIRELESS_UART_BAUD 115200 -#define RTS_PIN P10_2 //λ ָʾǰģǷԽ 0Լ 1Լ +// ------------------------------------ Զ ------------------------------------ +// ע1תģ汾V2.0µ޷Զʵġ +// ע2ԶRTSţῪʧܡ +// ע3ģԶʧܵĻԳԶϵ +// ԶĶ ע +// ԶĶ ע +// ԶĶ ע + +// 0رԶ +// 1Զ Զʵ޸WIRELESS_UART_BAUD֮ҪģãģԶΪӦIJ + +#define WIRELESS_AUTO_UART_BAUD 0 +// ------------------------------------ Զ ------------------------------------ + +#define RTS_PIN P10_2 //λ ָʾǰģǷԽ 0Լ 1Լ +#define WIRELESS_BUFFER_SIZE 16 + +extern uint8 wireless_send_buffer[WIRELESS_BUFFER_SIZE]; +extern uint32 wireless_rx_index; void wireless_uart_callback(void); void seekfree_wireless_init(void); diff --git a/Example/Printf_Demo/USER/isr.c b/Example/Printf_Demo/USER/isr.c index c55a012..16bff98 100644 --- a/Example/Printf_Demo/USER/isr.c +++ b/Example/Printf_Demo/USER/isr.c @@ -179,7 +179,20 @@ IFX_INTERRUPT(uart2_rx_isr, 0, UART2_RX_INT_PRIO) { enableInterrupts();//жǶ IfxAsclin_Asc_isrReceive(&uart2_handle); - wireless_uart_callback(); + switch(wireless_type) + { + case WIRELESS_SI24R1: + { + wireless_uart_callback(); + }break; + + case WIRELESS_CH9141: + { + bluetooth_ch9141_uart_callback(); + }break; + default:break; + } + } IFX_INTERRUPT(uart2_er_isr, 0, UART2_ER_INT_PRIO) { diff --git a/Example/Printf_Demo/删除临时文件.bat b/Example/Printf_Demo/删除临时文件.bat index 5323dd9..fa499b1 100644 --- a/Example/Printf_Demo/删除临时文件.bat +++ b/Example/Printf_Demo/删除临时文件.bat @@ -1,9 +1,6 @@ -rmdir .settings /s /q rmdir Debug /s /q del *.launch /s - -pause exit diff --git a/Example/Specifies_Variable_Or_Code_Location_Demo/.cproject b/Example/Specifies_Variable_Or_Code_Location_Demo/.cproject index b306bed..0355683 100644 --- a/Example/Specifies_Variable_Or_Code_Location_Demo/.cproject +++ b/Example/Specifies_Variable_Or_Code_Location_Demo/.cproject @@ -3,9 +3,9 @@ - + - + @@ -25,50 +25,76 @@ - + - + - + - + + + + + + @@ -355,9 +371,9 @@ - + - + @@ -377,43 +393,1895 @@ - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -431,13 +2299,37 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + @@ -458,21 +2350,5 @@ - - - - - - - - - - - - - - - - diff --git a/Example/Specifies_Variable_Or_Code_Location_Demo/.project b/Example/Specifies_Variable_Or_Code_Location_Demo/.project index 8e1f20d..209ac5c 100644 --- a/Example/Specifies_Variable_Or_Code_Location_Demo/.project +++ b/Example/Specifies_Variable_Or_Code_Location_Demo/.project @@ -5,6 +5,18 @@ + + com.infineon.aurix.buildsystem.builders.booster + full,incremental, + + + + + com.infineon.aurix.buildsystem.builders.autodiscovery + full,incremental, + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder clean,full,incremental, diff --git a/Example/Specifies_Variable_Or_Code_Location_Demo/.settings/com.infineon.aurix.buildsystem.prefs b/Example/Specifies_Variable_Or_Code_Location_Demo/.settings/com.infineon.aurix.buildsystem.prefs new file mode 100644 index 0000000..be61bc1 --- /dev/null +++ b/Example/Specifies_Variable_Or_Code_Location_Demo/.settings/com.infineon.aurix.buildsystem.prefs @@ -0,0 +1,10 @@ +AURIX-LIBRARY-PATH=Libraries/iLLD\#Libraries/Infra\#Libraries/Service +DEVICE-ID=TC26B +DEVICE-ID-FULL=TC26xD_B-Step +ILLD-SET=full +IncludesAutodiscovery=true +LIBRARIES-ROOT-PATH=Libraries +NEVER-EXCLUDE-FROM-BUILD=/Libraries/iLLD/TC26B/Tricore/Cpu/CStart\#/Libraries/iLLD/TC26B/Tricore/Cpu/Trap\#/Configurations\#/Configurations/Debug +PROJECT-VERSION=1.0 +aurixDevice=TC26xD_B-Step +eclipse.preferences.version=1 diff --git a/Example/Specifies_Variable_Or_Code_Location_Demo/Libraries/doc/version.txt b/Example/Specifies_Variable_Or_Code_Location_Demo/Libraries/doc/version.txt index ab79909..11ab82e 100644 --- a/Example/Specifies_Variable_Or_Code_Location_Demo/Libraries/doc/version.txt +++ b/Example/Specifies_Variable_Or_Code_Location_Demo/Libraries/doc/version.txt @@ -1,3 +1,13 @@ +V1.2.0 + CH9141תģ + ͵öٱ + ޸ ɾʱļ.bat ִԶرմ + ޸ ɾʱļ.bat ɾ°汾ļ + ޸ĹĿļ֧°汾 + +V1.1.10 + ޸ͨ#pragma section all "cpux_dsram"ָλʧЧ + V1.1.9 ڵķbuffӵ128ֽ diff --git a/Example/Specifies_Variable_Or_Code_Location_Demo/Libraries/seekfree_libraries/common/common.c b/Example/Specifies_Variable_Or_Code_Location_Demo/Libraries/seekfree_libraries/common/common.c index 0b9931e..7620ce6 100644 --- a/Example/Specifies_Variable_Or_Code_Location_Demo/Libraries/seekfree_libraries/common/common.c +++ b/Example/Specifies_Variable_Or_Code_Location_Demo/Libraries/seekfree_libraries/common/common.c @@ -27,6 +27,8 @@ CAMERA_TYPE_enum camera_type; //ͷͺ uint8 *camera_buffer_addr; //ͷַ +WIRELESS_TYPE_enum wireless_type;//ת + IFX_ALIGN(4) IfxCpu_syncEvent g_cpuSyncEvent = 0;//¼ͬ App_Cpu0 g_AppCpu0; //ƵϢ diff --git a/Example/Specifies_Variable_Or_Code_Location_Demo/Libraries/seekfree_libraries/common/common.h b/Example/Specifies_Variable_Or_Code_Location_Demo/Libraries/seekfree_libraries/common/common.h index 84c43ee..5b741c0 100644 --- a/Example/Specifies_Variable_Or_Code_Location_Demo/Libraries/seekfree_libraries/common/common.h +++ b/Example/Specifies_Variable_Or_Code_Location_Demo/Libraries/seekfree_libraries/common/common.h @@ -113,6 +113,12 @@ typedef enum //ö CAMERA_COLOR, //ͫ }CAMERA_TYPE_enum; +typedef enum //ģ +{ + WIRELESS_SI24R1 = 1, //ת + WIRELESS_CH9141, //ת +}WIRELESS_TYPE_enum; + #include #include #include "IfxCpu.h" @@ -120,6 +126,8 @@ typedef enum //ö extern CAMERA_TYPE_enum camera_type; //ͷͺ extern uint8 *camera_buffer_addr; //ͷַ +extern WIRELESS_TYPE_enum wireless_type; + extern IfxCpu_syncEvent g_cpuSyncEvent; void get_clk(void); diff --git a/Example/Specifies_Variable_Or_Code_Location_Demo/Libraries/seekfree_libraries/headfile.h b/Example/Specifies_Variable_Or_Code_Location_Demo/Libraries/seekfree_libraries/headfile.h index 404ee0a..b745302 100644 --- a/Example/Specifies_Variable_Or_Code_Location_Demo/Libraries/seekfree_libraries/headfile.h +++ b/Example/Specifies_Variable_Or_Code_Location_Demo/Libraries/seekfree_libraries/headfile.h @@ -65,6 +65,7 @@ #include "SEEKFREE_7725.h" #include "SEEKFREE_RDA5807.h" #include "SEEKFREE_7725_UART.h" +#include "SEEKFREE_BLUETOOTH_CH9141.h" #endif diff --git a/Example/Specifies_Variable_Or_Code_Location_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.c b/Example/Specifies_Variable_Or_Code_Location_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.c new file mode 100644 index 0000000..b4ec2df --- /dev/null +++ b/Example/Specifies_Variable_Or_Code_Location_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.c @@ -0,0 +1,509 @@ +/********************************************************************************************************************* + * COPYRIGHT NOTICE + * Copyright (c) 2021,ɿƼ + * All rights reserved. + * QQȺһȺ179029047() Ⱥ244861897 + * + * ݰȨɿƼУδҵ; + * ӭλʹò޸ʱ뱣ɿƼİȨ + * + * @file ɿƼתģ + * @company ɶɿƼ޹˾ + * @author ɿƼ(QQ3184284598) + * @version 鿴docversionļ 汾˵ + * @Software IAR 8.3 or MDK 5.33 + * @Taobao https://seekfree.taobao.com/ + * @date 2021-08-27 + * @note + ߶壺 + ------------------------------------ + ת Ƭ + RX 鿴SEEKFREE_BLUETOOTH_CH9141.hļеBLUETOOTH_CH9141_UART_TX궨 + TX 鿴SEEKFREE_BLUETOOTH_CH9141.hļеBLUETOOTH_CH9141_UART_RX궨 + RTS 鿴SEEKFREE_BLUETOOTH_CH9141.hļеBLUETOOTH_CH9141_RTS_PIN궨 + CTS + CMD ջ + ------------------------------------ + ********************************************************************************************************************/ +#include "zf_stm_systick.h" +#include "zf_gpio.h" +#include "zf_uart.h" +#include "zf_assert.h" +#include "SEEKFREE_BLUETOOTH_CH9141.h" + +uint8 uart_flag; +uint8 uart_data; + +vuint8 at_mode = 0; //0:͸ģʽ 1:ATģʽ 2:ģ鸴λ +vuint8 at_mode_num; //atģʽʱָʾݽյ +vuint8 at_mode_data[30]; //atĻ +vuint8 at_mode_cmd_flag; //OKӦճɹı־λ + +uint8 mac_address[17]; //macַ + + +uint8 bluetooth_ch9141_rx_buffer; + + +void bluetooth_ch9141_check_response(void); + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ жϻص +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note úISRļ 8жϳ򱻵 +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_uart_callback() +{ + while(uart_query(BLUETOOTH_CH9141_UART, &bluetooth_ch9141_rx_buffer)) + { + if(1 == at_mode) + { + //ATģʽ Ӧź ˴ifڴûҪĶ + at_mode_data[at_mode_num++] = bluetooth_ch9141_rx_buffer; + bluetooth_ch9141_check_response(); + } + else if(2 == at_mode) + { + //ģڸλ ˴ifڴûҪĶ + at_mode_num++; + } + else + { + //͸ģʽ ûڴ˴Ե͹Ķ + //ӵһֽںƬ˴ͨڴ˴ȡbluetooth_ch9141_rx_bufferȡ + + // ȡߴڵ λձ־ + uart_flag = 1; + uart_data = bluetooth_ch9141_rx_buffer; + } + + } +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģOKӦź +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note û +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_check_response(void) +{ + if(4 <= at_mode_num) + { + if(0 == strncmp("OK\r\n", (int8 *)&at_mode_data[at_mode_num-4], 4)) + { + at_mode_cmd_flag = 1; + } + } +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ鷢һûвȴӦź +// @param *str Ҫ͵ ַ +// @return void +// @since v1.0 +// Sample usage: +// @note û +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_send_at_command(const int8 *str) +{ + at_mode_num = 0; // + uart_putstr(BLUETOOTH_CH9141_UART, str); + uart_putstr(BLUETOOTH_CH9141_UART, "\r\n"); + + //ȴյӦź + while(!at_mode_cmd_flag); + at_mode_cmd_flag = 0; +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ鷢һвȴӦź +// @param *cmd Ҫ͵ +// @param *data Ҫ͵ +// @return void +// @since v1.0 +// Sample usage: +// @note û +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_send_at_command_parameter(const int8 *cmd, const int8 *data) +{ + at_mode_num = 0; // + uart_putstr(BLUETOOTH_CH9141_UART, "AT+"); + uart_putstr(BLUETOOTH_CH9141_UART, cmd); + uart_putstr(BLUETOOTH_CH9141_UART, "="); + uart_putstr(BLUETOOTH_CH9141_UART, data); + uart_putstr(BLUETOOTH_CH9141_UART, "\r\n"); + + //ȴյӦź + while(!at_mode_cmd_flag); + at_mode_cmd_flag = 0; +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģATģʽ +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_enter_at_mode(void) +{ + systick_delay_ms(STM0, 550); //ͽATģʽǰҪ֤ģ550msûнչκ + at_mode = 1; //ATģʽ + bluetooth_ch9141_send_at_command("AT..."); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ˳ATģʽ +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_exit_at_mode(void) +{ + bluetooth_ch9141_send_at_command("AT+EXIT"); + at_mode = 0; //͸ģʽ + systick_delay_ms(STM0, 300); //ȴɹATģʽ +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ鸴λ +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_reset(void) +{ + bluetooth_ch9141_send_at_command("AT+RESET"); + at_mode = 2; //ɹ + at_mode_num = 0; + while(7 > at_mode_num); //ȴģɸλ + at_mode = 0; //λ֮ģԶ͸ģʽ +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģȡMACַ +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note ô˺Ҫȵbluetooth_ch9141_enter_at_modeCMD ATģʽ +// Ҫرעbluetooth_ch9141_enter_at_modeڲ500msʱ +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_get_mac_address(void) +{ + bluetooth_ch9141_send_at_command("AT+MAC?"); + + //macַΪСθʽmac_address[0]macַλ + memcpy(mac_address, (uint8 *)at_mode_data, 17); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ÷͹ +// @param tx_power ÷͹ʣѡ鿴CH9141_TX_POWEER_enumöٳԱ +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_set_tx_power(CH9141_TX_POWEER_enum tx_power) +{ + int8 tx_power_data; + + tx_power_data = (uint8)tx_power + '0'; + bluetooth_ch9141_send_at_command_parameter("TPL", &tx_power_data); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģģʽ +// @param mode ģʽãѡ鿴CH9141_MODE_enumöٳԱ +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_set_mode(CH9141_MODE_enum mode) +{ + int8 mode_data; + + mode_data = (uint8)mode + '0'; + bluetooth_ch9141_send_at_command_parameter("BLEMODE", &mode_data); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģȡ״̬ +// @param mode ģʽãѡ鿴CH9141_MODE_enumöٳԱ +// @return CH9141_STATUS_enum ״̬Ϣ +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +CH9141_STATUS_enum bluetooth_ch9141_get_status(CH9141_MODE_enum mode) +{ + CH9141_STATUS_enum ch9141_status; + int8 mode_data; + + mode_data = (uint8)mode + '0'; + bluetooth_ch9141_send_at_command_parameter("BLEMODE", &mode_data); + + bluetooth_ch9141_send_at_command("AT+BLESTA?"); + + ch9141_status = (at_mode_data[0] - '0') * 10 + (at_mode_data[1] - '0'); + if(SLAVE_MODE == mode) + { + ch9141_status += SLAVE_NO_INIT; + } + + return ch9141_status; +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ豸 +// @param *str +// @return void +// @since v1.0 +// Sample usage: +// @note ƳȲܳ18ַ ֻΪӢ +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_set_name(const int8 *str) +{ + bluetooth_ch9141_send_at_command_parameter("NAME", str); + bluetooth_ch9141_send_at_command_parameter("PNAME", str); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ +// @param enable ʹ 0ʹ룬1ʹӱ豸 +// @param *password ַ Ϊ6ַ +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_set_password(uint8 enable, const int8 *password) +{ + if(0 == enable) + { + //ر + bluetooth_ch9141_send_at_command_parameter("PASEN", "OFF"); + } + else + { + //벢ʹ + bluetooth_ch9141_send_at_command_parameter("PASEN", "ON"); + bluetooth_ch9141_send_at_command_parameter("PASS", password); + } +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģָMACַ +// @param *mac_and_password Ҫӵ豸macַ +// @return void +// @since v1.0 +// Sample usage: +// @note bluetooth_ch9141_connect("58:B7:33:E4:C2:84,000000"); +// 58:B7:33:E4:C2:84Ϊmacַ ,Ϊָ 000000Ϊӻ +// ===================رע================== +// ʹֻ鿴macַʹñӵʱ뽫macһ +// ֻ鿴macַΪ61:62:63:64:65:66ʹñӵʱӦд +// bluetooth_ch9141_connect("66:65:64:63:62:61,000000"); +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_connect(const int8 *mac_and_password) +{ + bluetooth_ch9141_send_at_command_parameter("CONN", mac_and_password); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģĬӲãúúÿοԶ豸 +// @param *mac_and_password Ҫӵ豸macַ +// @return void +// @since v1.0 +// Sample usage: +// @note bluetooth_ch9141_default_connect("58:B7:33:E4:C2:84,000000"); +// 58:B7:33:E4:C2:84Ϊmacַ ,Ϊָ 000000Ϊӻ +// ===================رע================== +// ʹֻ鿴CH9141macַCH9141Ϊӻʹֻ +// ʹñӵʱ뽫macһ +// ֻ鿴macַΪ61:62:63:64:65:67ʹñӵʱӦд +// bluetooth_ch9141_default_connect("67:65:64:63:62:61,000000"); +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_default_connect(const int8 *mac_and_password) +{ + bluetooth_ch9141_send_at_command_parameter("CONADD", mac_and_password); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģȡrssi(źǿ) +// @param void +// @return int8 źǿ0-127 +// @since v1.0 +// Sample usage: +// @note ô˺Ҫȵbluetooth_ch9141_enter_at_modeCMD ATģʽ +// Ҫرעbluetooth_ch9141_enter_at_modeڲ500msʱ +//------------------------------------------------------------------------------------------------------------------- +int16 bluetooth_ch9141_get_rssi(void) +{ + uint8 i; + size_t length; + int16 rssi; + bluetooth_ch9141_send_at_command_parameter("RSSI", "ON,0"); + length = strlen((int8 *)at_mode_data); + length -= 12;//RSSI жλ + + rssi = 0; + for(i=0; i30) { - if(gpio_get(RTS_PIN)) - { - return len;//ģæ,ǰʹwhileȴ ʹúע͵whileȴ滻if - } - //while(gpio_get(RTS_PIN)); //RTSΪ͵ƽ +// if(gpio_get(RTS_PIN)) +// { +// return len;//ģæ,ǰʹwhileȴ ʹúע͵whileȴ滻if +// } + while(gpio_get(RTS_PIN)); //RTSΪ͵ƽ uart_putbuff(WIRELESS_UART,buff,30); buff += 30; //ַƫ len -= 30;// } - if(gpio_get(RTS_PIN)) - { - return len;//ģæ,ǰʹwhileȴ ʹúע͵whileȴ滻if - } - //while(gpio_get(RTS_PIN)); //RTSΪ͵ƽ +// if(gpio_get(RTS_PIN)) +// { +// return len;//ģæ,ǰʹwhileȴ ʹúע͵whileȴ滻if +// } + while(gpio_get(RTS_PIN)); //RTSΪ͵ƽ uart_putbuff(WIRELESS_UART,buff,len);// return 0; diff --git a/Example/Specifies_Variable_Or_Code_Location_Demo/Libraries/seekfree_peripheral/SEEKFREE_WIRELESS.h b/Example/Specifies_Variable_Or_Code_Location_Demo/Libraries/seekfree_peripheral/SEEKFREE_WIRELESS.h index 42c0832..d80339d 100644 --- a/Example/Specifies_Variable_Or_Code_Location_Demo/Libraries/seekfree_peripheral/SEEKFREE_WIRELESS.h +++ b/Example/Specifies_Variable_Or_Code_Location_Demo/Libraries/seekfree_peripheral/SEEKFREE_WIRELESS.h @@ -38,8 +38,26 @@ #define WIRELESS_UART_RX UART2_RX_P10_6 #define WIRELESS_UART_BAUD 115200 -#define RTS_PIN P10_2 //λ ָʾǰģǷԽ 0Լ 1Լ +// ------------------------------------ Զ ------------------------------------ +// ע1תģ汾V2.0µ޷Զʵġ +// ע2ԶRTSţῪʧܡ +// ע3ģԶʧܵĻԳԶϵ +// ԶĶ ע +// ԶĶ ע +// ԶĶ ע + +// 0رԶ +// 1Զ Զʵ޸WIRELESS_UART_BAUD֮ҪģãģԶΪӦIJ + +#define WIRELESS_AUTO_UART_BAUD 0 +// ------------------------------------ Զ ------------------------------------ + +#define RTS_PIN P10_2 //λ ָʾǰģǷԽ 0Լ 1Լ +#define WIRELESS_BUFFER_SIZE 16 + +extern uint8 wireless_send_buffer[WIRELESS_BUFFER_SIZE]; +extern uint32 wireless_rx_index; void wireless_uart_callback(void); void seekfree_wireless_init(void); diff --git a/Example/Specifies_Variable_Or_Code_Location_Demo/USER/isr.c b/Example/Specifies_Variable_Or_Code_Location_Demo/USER/isr.c index c55a012..16bff98 100644 --- a/Example/Specifies_Variable_Or_Code_Location_Demo/USER/isr.c +++ b/Example/Specifies_Variable_Or_Code_Location_Demo/USER/isr.c @@ -179,7 +179,20 @@ IFX_INTERRUPT(uart2_rx_isr, 0, UART2_RX_INT_PRIO) { enableInterrupts();//жǶ IfxAsclin_Asc_isrReceive(&uart2_handle); - wireless_uart_callback(); + switch(wireless_type) + { + case WIRELESS_SI24R1: + { + wireless_uart_callback(); + }break; + + case WIRELESS_CH9141: + { + bluetooth_ch9141_uart_callback(); + }break; + default:break; + } + } IFX_INTERRUPT(uart2_er_isr, 0, UART2_ER_INT_PRIO) { diff --git a/Example/Specifies_Variable_Or_Code_Location_Demo/删除临时文件.bat b/Example/Specifies_Variable_Or_Code_Location_Demo/删除临时文件.bat index 5323dd9..fa499b1 100644 --- a/Example/Specifies_Variable_Or_Code_Location_Demo/删除临时文件.bat +++ b/Example/Specifies_Variable_Or_Code_Location_Demo/删除临时文件.bat @@ -1,9 +1,6 @@ -rmdir .settings /s /q rmdir Debug /s /q del *.launch /s - -pause exit diff --git a/Example/Systick_Demo/.cproject b/Example/Systick_Demo/.cproject index c0a0ab0..cfe5340 100644 --- a/Example/Systick_Demo/.cproject +++ b/Example/Systick_Demo/.cproject @@ -3,9 +3,9 @@ - + - + @@ -25,50 +25,76 @@ - + - + - + - + + + + + + @@ -355,9 +371,9 @@ - + - + @@ -377,43 +393,1895 @@ - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -431,13 +2299,37 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + @@ -458,21 +2350,5 @@ - - - - - - - - - - - - - - - - diff --git a/Example/Systick_Demo/.project b/Example/Systick_Demo/.project index 6d93e1a..3a71be3 100644 --- a/Example/Systick_Demo/.project +++ b/Example/Systick_Demo/.project @@ -5,6 +5,18 @@ + + com.infineon.aurix.buildsystem.builders.booster + full,incremental, + + + + + com.infineon.aurix.buildsystem.builders.autodiscovery + full,incremental, + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder clean,full,incremental, diff --git a/Example/Systick_Demo/.settings/com.infineon.aurix.buildsystem.prefs b/Example/Systick_Demo/.settings/com.infineon.aurix.buildsystem.prefs new file mode 100644 index 0000000..be61bc1 --- /dev/null +++ b/Example/Systick_Demo/.settings/com.infineon.aurix.buildsystem.prefs @@ -0,0 +1,10 @@ +AURIX-LIBRARY-PATH=Libraries/iLLD\#Libraries/Infra\#Libraries/Service +DEVICE-ID=TC26B +DEVICE-ID-FULL=TC26xD_B-Step +ILLD-SET=full +IncludesAutodiscovery=true +LIBRARIES-ROOT-PATH=Libraries +NEVER-EXCLUDE-FROM-BUILD=/Libraries/iLLD/TC26B/Tricore/Cpu/CStart\#/Libraries/iLLD/TC26B/Tricore/Cpu/Trap\#/Configurations\#/Configurations/Debug +PROJECT-VERSION=1.0 +aurixDevice=TC26xD_B-Step +eclipse.preferences.version=1 diff --git a/Example/Systick_Demo/Libraries/doc/version.txt b/Example/Systick_Demo/Libraries/doc/version.txt index ab79909..11ab82e 100644 --- a/Example/Systick_Demo/Libraries/doc/version.txt +++ b/Example/Systick_Demo/Libraries/doc/version.txt @@ -1,3 +1,13 @@ +V1.2.0 + CH9141תģ + ͵öٱ + ޸ ɾʱļ.bat ִԶرմ + ޸ ɾʱļ.bat ɾ°汾ļ + ޸ĹĿļ֧°汾 + +V1.1.10 + ޸ͨ#pragma section all "cpux_dsram"ָλʧЧ + V1.1.9 ڵķbuffӵ128ֽ diff --git a/Example/Systick_Demo/Libraries/seekfree_libraries/common/common.c b/Example/Systick_Demo/Libraries/seekfree_libraries/common/common.c index 0b9931e..7620ce6 100644 --- a/Example/Systick_Demo/Libraries/seekfree_libraries/common/common.c +++ b/Example/Systick_Demo/Libraries/seekfree_libraries/common/common.c @@ -27,6 +27,8 @@ CAMERA_TYPE_enum camera_type; //ͷͺ uint8 *camera_buffer_addr; //ͷַ +WIRELESS_TYPE_enum wireless_type;//ת + IFX_ALIGN(4) IfxCpu_syncEvent g_cpuSyncEvent = 0;//¼ͬ App_Cpu0 g_AppCpu0; //ƵϢ diff --git a/Example/Systick_Demo/Libraries/seekfree_libraries/common/common.h b/Example/Systick_Demo/Libraries/seekfree_libraries/common/common.h index 84c43ee..5b741c0 100644 --- a/Example/Systick_Demo/Libraries/seekfree_libraries/common/common.h +++ b/Example/Systick_Demo/Libraries/seekfree_libraries/common/common.h @@ -113,6 +113,12 @@ typedef enum //ö CAMERA_COLOR, //ͫ }CAMERA_TYPE_enum; +typedef enum //ģ +{ + WIRELESS_SI24R1 = 1, //ת + WIRELESS_CH9141, //ת +}WIRELESS_TYPE_enum; + #include #include #include "IfxCpu.h" @@ -120,6 +126,8 @@ typedef enum //ö extern CAMERA_TYPE_enum camera_type; //ͷͺ extern uint8 *camera_buffer_addr; //ͷַ +extern WIRELESS_TYPE_enum wireless_type; + extern IfxCpu_syncEvent g_cpuSyncEvent; void get_clk(void); diff --git a/Example/Systick_Demo/Libraries/seekfree_libraries/headfile.h b/Example/Systick_Demo/Libraries/seekfree_libraries/headfile.h index 404ee0a..b745302 100644 --- a/Example/Systick_Demo/Libraries/seekfree_libraries/headfile.h +++ b/Example/Systick_Demo/Libraries/seekfree_libraries/headfile.h @@ -65,6 +65,7 @@ #include "SEEKFREE_7725.h" #include "SEEKFREE_RDA5807.h" #include "SEEKFREE_7725_UART.h" +#include "SEEKFREE_BLUETOOTH_CH9141.h" #endif diff --git a/Example/Systick_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.c b/Example/Systick_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.c new file mode 100644 index 0000000..b4ec2df --- /dev/null +++ b/Example/Systick_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.c @@ -0,0 +1,509 @@ +/********************************************************************************************************************* + * COPYRIGHT NOTICE + * Copyright (c) 2021,ɿƼ + * All rights reserved. + * QQȺһȺ179029047() Ⱥ244861897 + * + * ݰȨɿƼУδҵ; + * ӭλʹò޸ʱ뱣ɿƼİȨ + * + * @file ɿƼתģ + * @company ɶɿƼ޹˾ + * @author ɿƼ(QQ3184284598) + * @version 鿴docversionļ 汾˵ + * @Software IAR 8.3 or MDK 5.33 + * @Taobao https://seekfree.taobao.com/ + * @date 2021-08-27 + * @note + ߶壺 + ------------------------------------ + ת Ƭ + RX 鿴SEEKFREE_BLUETOOTH_CH9141.hļеBLUETOOTH_CH9141_UART_TX궨 + TX 鿴SEEKFREE_BLUETOOTH_CH9141.hļеBLUETOOTH_CH9141_UART_RX궨 + RTS 鿴SEEKFREE_BLUETOOTH_CH9141.hļеBLUETOOTH_CH9141_RTS_PIN궨 + CTS + CMD ջ + ------------------------------------ + ********************************************************************************************************************/ +#include "zf_stm_systick.h" +#include "zf_gpio.h" +#include "zf_uart.h" +#include "zf_assert.h" +#include "SEEKFREE_BLUETOOTH_CH9141.h" + +uint8 uart_flag; +uint8 uart_data; + +vuint8 at_mode = 0; //0:͸ģʽ 1:ATģʽ 2:ģ鸴λ +vuint8 at_mode_num; //atģʽʱָʾݽյ +vuint8 at_mode_data[30]; //atĻ +vuint8 at_mode_cmd_flag; //OKӦճɹı־λ + +uint8 mac_address[17]; //macַ + + +uint8 bluetooth_ch9141_rx_buffer; + + +void bluetooth_ch9141_check_response(void); + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ жϻص +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note úISRļ 8жϳ򱻵 +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_uart_callback() +{ + while(uart_query(BLUETOOTH_CH9141_UART, &bluetooth_ch9141_rx_buffer)) + { + if(1 == at_mode) + { + //ATģʽ Ӧź ˴ifڴûҪĶ + at_mode_data[at_mode_num++] = bluetooth_ch9141_rx_buffer; + bluetooth_ch9141_check_response(); + } + else if(2 == at_mode) + { + //ģڸλ ˴ifڴûҪĶ + at_mode_num++; + } + else + { + //͸ģʽ ûڴ˴Ե͹Ķ + //ӵһֽںƬ˴ͨڴ˴ȡbluetooth_ch9141_rx_bufferȡ + + // ȡߴڵ λձ־ + uart_flag = 1; + uart_data = bluetooth_ch9141_rx_buffer; + } + + } +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģOKӦź +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note û +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_check_response(void) +{ + if(4 <= at_mode_num) + { + if(0 == strncmp("OK\r\n", (int8 *)&at_mode_data[at_mode_num-4], 4)) + { + at_mode_cmd_flag = 1; + } + } +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ鷢һûвȴӦź +// @param *str Ҫ͵ ַ +// @return void +// @since v1.0 +// Sample usage: +// @note û +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_send_at_command(const int8 *str) +{ + at_mode_num = 0; // + uart_putstr(BLUETOOTH_CH9141_UART, str); + uart_putstr(BLUETOOTH_CH9141_UART, "\r\n"); + + //ȴյӦź + while(!at_mode_cmd_flag); + at_mode_cmd_flag = 0; +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ鷢һвȴӦź +// @param *cmd Ҫ͵ +// @param *data Ҫ͵ +// @return void +// @since v1.0 +// Sample usage: +// @note û +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_send_at_command_parameter(const int8 *cmd, const int8 *data) +{ + at_mode_num = 0; // + uart_putstr(BLUETOOTH_CH9141_UART, "AT+"); + uart_putstr(BLUETOOTH_CH9141_UART, cmd); + uart_putstr(BLUETOOTH_CH9141_UART, "="); + uart_putstr(BLUETOOTH_CH9141_UART, data); + uart_putstr(BLUETOOTH_CH9141_UART, "\r\n"); + + //ȴյӦź + while(!at_mode_cmd_flag); + at_mode_cmd_flag = 0; +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģATģʽ +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_enter_at_mode(void) +{ + systick_delay_ms(STM0, 550); //ͽATģʽǰҪ֤ģ550msûнչκ + at_mode = 1; //ATģʽ + bluetooth_ch9141_send_at_command("AT..."); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ˳ATģʽ +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_exit_at_mode(void) +{ + bluetooth_ch9141_send_at_command("AT+EXIT"); + at_mode = 0; //͸ģʽ + systick_delay_ms(STM0, 300); //ȴɹATģʽ +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ鸴λ +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_reset(void) +{ + bluetooth_ch9141_send_at_command("AT+RESET"); + at_mode = 2; //ɹ + at_mode_num = 0; + while(7 > at_mode_num); //ȴģɸλ + at_mode = 0; //λ֮ģԶ͸ģʽ +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģȡMACַ +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note ô˺Ҫȵbluetooth_ch9141_enter_at_modeCMD ATģʽ +// Ҫرעbluetooth_ch9141_enter_at_modeڲ500msʱ +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_get_mac_address(void) +{ + bluetooth_ch9141_send_at_command("AT+MAC?"); + + //macַΪСθʽmac_address[0]macַλ + memcpy(mac_address, (uint8 *)at_mode_data, 17); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ÷͹ +// @param tx_power ÷͹ʣѡ鿴CH9141_TX_POWEER_enumöٳԱ +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_set_tx_power(CH9141_TX_POWEER_enum tx_power) +{ + int8 tx_power_data; + + tx_power_data = (uint8)tx_power + '0'; + bluetooth_ch9141_send_at_command_parameter("TPL", &tx_power_data); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģģʽ +// @param mode ģʽãѡ鿴CH9141_MODE_enumöٳԱ +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_set_mode(CH9141_MODE_enum mode) +{ + int8 mode_data; + + mode_data = (uint8)mode + '0'; + bluetooth_ch9141_send_at_command_parameter("BLEMODE", &mode_data); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģȡ״̬ +// @param mode ģʽãѡ鿴CH9141_MODE_enumöٳԱ +// @return CH9141_STATUS_enum ״̬Ϣ +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +CH9141_STATUS_enum bluetooth_ch9141_get_status(CH9141_MODE_enum mode) +{ + CH9141_STATUS_enum ch9141_status; + int8 mode_data; + + mode_data = (uint8)mode + '0'; + bluetooth_ch9141_send_at_command_parameter("BLEMODE", &mode_data); + + bluetooth_ch9141_send_at_command("AT+BLESTA?"); + + ch9141_status = (at_mode_data[0] - '0') * 10 + (at_mode_data[1] - '0'); + if(SLAVE_MODE == mode) + { + ch9141_status += SLAVE_NO_INIT; + } + + return ch9141_status; +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ豸 +// @param *str +// @return void +// @since v1.0 +// Sample usage: +// @note ƳȲܳ18ַ ֻΪӢ +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_set_name(const int8 *str) +{ + bluetooth_ch9141_send_at_command_parameter("NAME", str); + bluetooth_ch9141_send_at_command_parameter("PNAME", str); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ +// @param enable ʹ 0ʹ룬1ʹӱ豸 +// @param *password ַ Ϊ6ַ +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_set_password(uint8 enable, const int8 *password) +{ + if(0 == enable) + { + //ر + bluetooth_ch9141_send_at_command_parameter("PASEN", "OFF"); + } + else + { + //벢ʹ + bluetooth_ch9141_send_at_command_parameter("PASEN", "ON"); + bluetooth_ch9141_send_at_command_parameter("PASS", password); + } +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģָMACַ +// @param *mac_and_password Ҫӵ豸macַ +// @return void +// @since v1.0 +// Sample usage: +// @note bluetooth_ch9141_connect("58:B7:33:E4:C2:84,000000"); +// 58:B7:33:E4:C2:84Ϊmacַ ,Ϊָ 000000Ϊӻ +// ===================رע================== +// ʹֻ鿴macַʹñӵʱ뽫macһ +// ֻ鿴macַΪ61:62:63:64:65:66ʹñӵʱӦд +// bluetooth_ch9141_connect("66:65:64:63:62:61,000000"); +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_connect(const int8 *mac_and_password) +{ + bluetooth_ch9141_send_at_command_parameter("CONN", mac_and_password); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģĬӲãúúÿοԶ豸 +// @param *mac_and_password Ҫӵ豸macַ +// @return void +// @since v1.0 +// Sample usage: +// @note bluetooth_ch9141_default_connect("58:B7:33:E4:C2:84,000000"); +// 58:B7:33:E4:C2:84Ϊmacַ ,Ϊָ 000000Ϊӻ +// ===================رע================== +// ʹֻ鿴CH9141macַCH9141Ϊӻʹֻ +// ʹñӵʱ뽫macһ +// ֻ鿴macַΪ61:62:63:64:65:67ʹñӵʱӦд +// bluetooth_ch9141_default_connect("67:65:64:63:62:61,000000"); +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_default_connect(const int8 *mac_and_password) +{ + bluetooth_ch9141_send_at_command_parameter("CONADD", mac_and_password); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģȡrssi(źǿ) +// @param void +// @return int8 źǿ0-127 +// @since v1.0 +// Sample usage: +// @note ô˺Ҫȵbluetooth_ch9141_enter_at_modeCMD ATģʽ +// Ҫرעbluetooth_ch9141_enter_at_modeڲ500msʱ +//------------------------------------------------------------------------------------------------------------------- +int16 bluetooth_ch9141_get_rssi(void) +{ + uint8 i; + size_t length; + int16 rssi; + bluetooth_ch9141_send_at_command_parameter("RSSI", "ON,0"); + length = strlen((int8 *)at_mode_data); + length -= 12;//RSSI жλ + + rssi = 0; + for(i=0; i30) { - if(gpio_get(RTS_PIN)) - { - return len;//ģæ,ǰʹwhileȴ ʹúע͵whileȴ滻if - } - //while(gpio_get(RTS_PIN)); //RTSΪ͵ƽ +// if(gpio_get(RTS_PIN)) +// { +// return len;//ģæ,ǰʹwhileȴ ʹúע͵whileȴ滻if +// } + while(gpio_get(RTS_PIN)); //RTSΪ͵ƽ uart_putbuff(WIRELESS_UART,buff,30); buff += 30; //ַƫ len -= 30;// } - if(gpio_get(RTS_PIN)) - { - return len;//ģæ,ǰʹwhileȴ ʹúע͵whileȴ滻if - } - //while(gpio_get(RTS_PIN)); //RTSΪ͵ƽ +// if(gpio_get(RTS_PIN)) +// { +// return len;//ģæ,ǰʹwhileȴ ʹúע͵whileȴ滻if +// } + while(gpio_get(RTS_PIN)); //RTSΪ͵ƽ uart_putbuff(WIRELESS_UART,buff,len);// return 0; diff --git a/Example/Systick_Demo/Libraries/seekfree_peripheral/SEEKFREE_WIRELESS.h b/Example/Systick_Demo/Libraries/seekfree_peripheral/SEEKFREE_WIRELESS.h index 42c0832..d80339d 100644 --- a/Example/Systick_Demo/Libraries/seekfree_peripheral/SEEKFREE_WIRELESS.h +++ b/Example/Systick_Demo/Libraries/seekfree_peripheral/SEEKFREE_WIRELESS.h @@ -38,8 +38,26 @@ #define WIRELESS_UART_RX UART2_RX_P10_6 #define WIRELESS_UART_BAUD 115200 -#define RTS_PIN P10_2 //λ ָʾǰģǷԽ 0Լ 1Լ +// ------------------------------------ Զ ------------------------------------ +// ע1תģ汾V2.0µ޷Զʵġ +// ע2ԶRTSţῪʧܡ +// ע3ģԶʧܵĻԳԶϵ +// ԶĶ ע +// ԶĶ ע +// ԶĶ ע + +// 0رԶ +// 1Զ Զʵ޸WIRELESS_UART_BAUD֮ҪģãģԶΪӦIJ + +#define WIRELESS_AUTO_UART_BAUD 0 +// ------------------------------------ Զ ------------------------------------ + +#define RTS_PIN P10_2 //λ ָʾǰģǷԽ 0Լ 1Լ +#define WIRELESS_BUFFER_SIZE 16 + +extern uint8 wireless_send_buffer[WIRELESS_BUFFER_SIZE]; +extern uint32 wireless_rx_index; void wireless_uart_callback(void); void seekfree_wireless_init(void); diff --git a/Example/Systick_Demo/USER/isr.c b/Example/Systick_Demo/USER/isr.c index c55a012..16bff98 100644 --- a/Example/Systick_Demo/USER/isr.c +++ b/Example/Systick_Demo/USER/isr.c @@ -179,7 +179,20 @@ IFX_INTERRUPT(uart2_rx_isr, 0, UART2_RX_INT_PRIO) { enableInterrupts();//жǶ IfxAsclin_Asc_isrReceive(&uart2_handle); - wireless_uart_callback(); + switch(wireless_type) + { + case WIRELESS_SI24R1: + { + wireless_uart_callback(); + }break; + + case WIRELESS_CH9141: + { + bluetooth_ch9141_uart_callback(); + }break; + default:break; + } + } IFX_INTERRUPT(uart2_er_isr, 0, UART2_ER_INT_PRIO) { diff --git a/Example/Systick_Demo/删除临时文件.bat b/Example/Systick_Demo/删除临时文件.bat index 5323dd9..fa499b1 100644 --- a/Example/Systick_Demo/删除临时文件.bat +++ b/Example/Systick_Demo/删除临时文件.bat @@ -1,9 +1,6 @@ -rmdir .settings /s /q rmdir Debug /s /q del *.launch /s - -pause exit diff --git a/Example/UART_Demo/.cproject b/Example/UART_Demo/.cproject index b3af179..7d3ced9 100644 --- a/Example/UART_Demo/.cproject +++ b/Example/UART_Demo/.cproject @@ -3,9 +3,9 @@ - + - + @@ -25,50 +25,76 @@ - + - + - + - + + + + + + @@ -355,9 +371,9 @@ - + - + @@ -377,43 +393,1895 @@ - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -431,13 +2299,37 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + @@ -458,21 +2350,5 @@ - - - - - - - - - - - - - - - - diff --git a/Example/UART_Demo/.project b/Example/UART_Demo/.project index 19afa0e..0bb2f85 100644 --- a/Example/UART_Demo/.project +++ b/Example/UART_Demo/.project @@ -5,6 +5,18 @@ + + com.infineon.aurix.buildsystem.builders.booster + full,incremental, + + + + + com.infineon.aurix.buildsystem.builders.autodiscovery + full,incremental, + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder clean,full,incremental, diff --git a/Example/UART_Demo/.settings/com.infineon.aurix.buildsystem.prefs b/Example/UART_Demo/.settings/com.infineon.aurix.buildsystem.prefs new file mode 100644 index 0000000..be61bc1 --- /dev/null +++ b/Example/UART_Demo/.settings/com.infineon.aurix.buildsystem.prefs @@ -0,0 +1,10 @@ +AURIX-LIBRARY-PATH=Libraries/iLLD\#Libraries/Infra\#Libraries/Service +DEVICE-ID=TC26B +DEVICE-ID-FULL=TC26xD_B-Step +ILLD-SET=full +IncludesAutodiscovery=true +LIBRARIES-ROOT-PATH=Libraries +NEVER-EXCLUDE-FROM-BUILD=/Libraries/iLLD/TC26B/Tricore/Cpu/CStart\#/Libraries/iLLD/TC26B/Tricore/Cpu/Trap\#/Configurations\#/Configurations/Debug +PROJECT-VERSION=1.0 +aurixDevice=TC26xD_B-Step +eclipse.preferences.version=1 diff --git a/Example/UART_Demo/Libraries/doc/version.txt b/Example/UART_Demo/Libraries/doc/version.txt index ab79909..11ab82e 100644 --- a/Example/UART_Demo/Libraries/doc/version.txt +++ b/Example/UART_Demo/Libraries/doc/version.txt @@ -1,3 +1,13 @@ +V1.2.0 + CH9141תģ + ͵öٱ + ޸ ɾʱļ.bat ִԶرմ + ޸ ɾʱļ.bat ɾ°汾ļ + ޸ĹĿļ֧°汾 + +V1.1.10 + ޸ͨ#pragma section all "cpux_dsram"ָλʧЧ + V1.1.9 ڵķbuffӵ128ֽ diff --git a/Example/UART_Demo/Libraries/seekfree_libraries/common/common.c b/Example/UART_Demo/Libraries/seekfree_libraries/common/common.c index 0b9931e..7620ce6 100644 --- a/Example/UART_Demo/Libraries/seekfree_libraries/common/common.c +++ b/Example/UART_Demo/Libraries/seekfree_libraries/common/common.c @@ -27,6 +27,8 @@ CAMERA_TYPE_enum camera_type; //ͷͺ uint8 *camera_buffer_addr; //ͷַ +WIRELESS_TYPE_enum wireless_type;//ת + IFX_ALIGN(4) IfxCpu_syncEvent g_cpuSyncEvent = 0;//¼ͬ App_Cpu0 g_AppCpu0; //ƵϢ diff --git a/Example/UART_Demo/Libraries/seekfree_libraries/common/common.h b/Example/UART_Demo/Libraries/seekfree_libraries/common/common.h index 84c43ee..5b741c0 100644 --- a/Example/UART_Demo/Libraries/seekfree_libraries/common/common.h +++ b/Example/UART_Demo/Libraries/seekfree_libraries/common/common.h @@ -113,6 +113,12 @@ typedef enum //ö CAMERA_COLOR, //ͫ }CAMERA_TYPE_enum; +typedef enum //ģ +{ + WIRELESS_SI24R1 = 1, //ת + WIRELESS_CH9141, //ת +}WIRELESS_TYPE_enum; + #include #include #include "IfxCpu.h" @@ -120,6 +126,8 @@ typedef enum //ö extern CAMERA_TYPE_enum camera_type; //ͷͺ extern uint8 *camera_buffer_addr; //ͷַ +extern WIRELESS_TYPE_enum wireless_type; + extern IfxCpu_syncEvent g_cpuSyncEvent; void get_clk(void); diff --git a/Example/UART_Demo/Libraries/seekfree_libraries/headfile.h b/Example/UART_Demo/Libraries/seekfree_libraries/headfile.h index 404ee0a..b745302 100644 --- a/Example/UART_Demo/Libraries/seekfree_libraries/headfile.h +++ b/Example/UART_Demo/Libraries/seekfree_libraries/headfile.h @@ -65,6 +65,7 @@ #include "SEEKFREE_7725.h" #include "SEEKFREE_RDA5807.h" #include "SEEKFREE_7725_UART.h" +#include "SEEKFREE_BLUETOOTH_CH9141.h" #endif diff --git a/Example/UART_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.c b/Example/UART_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.c new file mode 100644 index 0000000..b4ec2df --- /dev/null +++ b/Example/UART_Demo/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.c @@ -0,0 +1,509 @@ +/********************************************************************************************************************* + * COPYRIGHT NOTICE + * Copyright (c) 2021,ɿƼ + * All rights reserved. + * QQȺһȺ179029047() Ⱥ244861897 + * + * ݰȨɿƼУδҵ; + * ӭλʹò޸ʱ뱣ɿƼİȨ + * + * @file ɿƼתģ + * @company ɶɿƼ޹˾ + * @author ɿƼ(QQ3184284598) + * @version 鿴docversionļ 汾˵ + * @Software IAR 8.3 or MDK 5.33 + * @Taobao https://seekfree.taobao.com/ + * @date 2021-08-27 + * @note + ߶壺 + ------------------------------------ + ת Ƭ + RX 鿴SEEKFREE_BLUETOOTH_CH9141.hļеBLUETOOTH_CH9141_UART_TX궨 + TX 鿴SEEKFREE_BLUETOOTH_CH9141.hļеBLUETOOTH_CH9141_UART_RX궨 + RTS 鿴SEEKFREE_BLUETOOTH_CH9141.hļеBLUETOOTH_CH9141_RTS_PIN궨 + CTS + CMD ջ + ------------------------------------ + ********************************************************************************************************************/ +#include "zf_stm_systick.h" +#include "zf_gpio.h" +#include "zf_uart.h" +#include "zf_assert.h" +#include "SEEKFREE_BLUETOOTH_CH9141.h" + +uint8 uart_flag; +uint8 uart_data; + +vuint8 at_mode = 0; //0:͸ģʽ 1:ATģʽ 2:ģ鸴λ +vuint8 at_mode_num; //atģʽʱָʾݽյ +vuint8 at_mode_data[30]; //atĻ +vuint8 at_mode_cmd_flag; //OKӦճɹı־λ + +uint8 mac_address[17]; //macַ + + +uint8 bluetooth_ch9141_rx_buffer; + + +void bluetooth_ch9141_check_response(void); + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ жϻص +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note úISRļ 8жϳ򱻵 +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_uart_callback() +{ + while(uart_query(BLUETOOTH_CH9141_UART, &bluetooth_ch9141_rx_buffer)) + { + if(1 == at_mode) + { + //ATģʽ Ӧź ˴ifڴûҪĶ + at_mode_data[at_mode_num++] = bluetooth_ch9141_rx_buffer; + bluetooth_ch9141_check_response(); + } + else if(2 == at_mode) + { + //ģڸλ ˴ifڴûҪĶ + at_mode_num++; + } + else + { + //͸ģʽ ûڴ˴Ե͹Ķ + //ӵһֽںƬ˴ͨڴ˴ȡbluetooth_ch9141_rx_bufferȡ + + // ȡߴڵ λձ־ + uart_flag = 1; + uart_data = bluetooth_ch9141_rx_buffer; + } + + } +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģOKӦź +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note û +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_check_response(void) +{ + if(4 <= at_mode_num) + { + if(0 == strncmp("OK\r\n", (int8 *)&at_mode_data[at_mode_num-4], 4)) + { + at_mode_cmd_flag = 1; + } + } +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ鷢һûвȴӦź +// @param *str Ҫ͵ ַ +// @return void +// @since v1.0 +// Sample usage: +// @note û +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_send_at_command(const int8 *str) +{ + at_mode_num = 0; // + uart_putstr(BLUETOOTH_CH9141_UART, str); + uart_putstr(BLUETOOTH_CH9141_UART, "\r\n"); + + //ȴյӦź + while(!at_mode_cmd_flag); + at_mode_cmd_flag = 0; +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ鷢һвȴӦź +// @param *cmd Ҫ͵ +// @param *data Ҫ͵ +// @return void +// @since v1.0 +// Sample usage: +// @note û +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_send_at_command_parameter(const int8 *cmd, const int8 *data) +{ + at_mode_num = 0; // + uart_putstr(BLUETOOTH_CH9141_UART, "AT+"); + uart_putstr(BLUETOOTH_CH9141_UART, cmd); + uart_putstr(BLUETOOTH_CH9141_UART, "="); + uart_putstr(BLUETOOTH_CH9141_UART, data); + uart_putstr(BLUETOOTH_CH9141_UART, "\r\n"); + + //ȴյӦź + while(!at_mode_cmd_flag); + at_mode_cmd_flag = 0; +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģATģʽ +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_enter_at_mode(void) +{ + systick_delay_ms(STM0, 550); //ͽATģʽǰҪ֤ģ550msûнչκ + at_mode = 1; //ATģʽ + bluetooth_ch9141_send_at_command("AT..."); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ˳ATģʽ +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_exit_at_mode(void) +{ + bluetooth_ch9141_send_at_command("AT+EXIT"); + at_mode = 0; //͸ģʽ + systick_delay_ms(STM0, 300); //ȴɹATģʽ +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ鸴λ +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_reset(void) +{ + bluetooth_ch9141_send_at_command("AT+RESET"); + at_mode = 2; //ɹ + at_mode_num = 0; + while(7 > at_mode_num); //ȴģɸλ + at_mode = 0; //λ֮ģԶ͸ģʽ +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģȡMACַ +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note ô˺Ҫȵbluetooth_ch9141_enter_at_modeCMD ATģʽ +// Ҫرעbluetooth_ch9141_enter_at_modeڲ500msʱ +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_get_mac_address(void) +{ + bluetooth_ch9141_send_at_command("AT+MAC?"); + + //macַΪСθʽmac_address[0]macַλ + memcpy(mac_address, (uint8 *)at_mode_data, 17); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ÷͹ +// @param tx_power ÷͹ʣѡ鿴CH9141_TX_POWEER_enumöٳԱ +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_set_tx_power(CH9141_TX_POWEER_enum tx_power) +{ + int8 tx_power_data; + + tx_power_data = (uint8)tx_power + '0'; + bluetooth_ch9141_send_at_command_parameter("TPL", &tx_power_data); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģģʽ +// @param mode ģʽãѡ鿴CH9141_MODE_enumöٳԱ +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_set_mode(CH9141_MODE_enum mode) +{ + int8 mode_data; + + mode_data = (uint8)mode + '0'; + bluetooth_ch9141_send_at_command_parameter("BLEMODE", &mode_data); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģȡ״̬ +// @param mode ģʽãѡ鿴CH9141_MODE_enumöٳԱ +// @return CH9141_STATUS_enum ״̬Ϣ +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +CH9141_STATUS_enum bluetooth_ch9141_get_status(CH9141_MODE_enum mode) +{ + CH9141_STATUS_enum ch9141_status; + int8 mode_data; + + mode_data = (uint8)mode + '0'; + bluetooth_ch9141_send_at_command_parameter("BLEMODE", &mode_data); + + bluetooth_ch9141_send_at_command("AT+BLESTA?"); + + ch9141_status = (at_mode_data[0] - '0') * 10 + (at_mode_data[1] - '0'); + if(SLAVE_MODE == mode) + { + ch9141_status += SLAVE_NO_INIT; + } + + return ch9141_status; +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ豸 +// @param *str +// @return void +// @since v1.0 +// Sample usage: +// @note ƳȲܳ18ַ ֻΪӢ +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_set_name(const int8 *str) +{ + bluetooth_ch9141_send_at_command_parameter("NAME", str); + bluetooth_ch9141_send_at_command_parameter("PNAME", str); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ +// @param enable ʹ 0ʹ룬1ʹӱ豸 +// @param *password ַ Ϊ6ַ +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_set_password(uint8 enable, const int8 *password) +{ + if(0 == enable) + { + //ر + bluetooth_ch9141_send_at_command_parameter("PASEN", "OFF"); + } + else + { + //벢ʹ + bluetooth_ch9141_send_at_command_parameter("PASEN", "ON"); + bluetooth_ch9141_send_at_command_parameter("PASS", password); + } +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģָMACַ +// @param *mac_and_password Ҫӵ豸macַ +// @return void +// @since v1.0 +// Sample usage: +// @note bluetooth_ch9141_connect("58:B7:33:E4:C2:84,000000"); +// 58:B7:33:E4:C2:84Ϊmacַ ,Ϊָ 000000Ϊӻ +// ===================رע================== +// ʹֻ鿴macַʹñӵʱ뽫macһ +// ֻ鿴macַΪ61:62:63:64:65:66ʹñӵʱӦд +// bluetooth_ch9141_connect("66:65:64:63:62:61,000000"); +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_connect(const int8 *mac_and_password) +{ + bluetooth_ch9141_send_at_command_parameter("CONN", mac_and_password); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģĬӲãúúÿοԶ豸 +// @param *mac_and_password Ҫӵ豸macַ +// @return void +// @since v1.0 +// Sample usage: +// @note bluetooth_ch9141_default_connect("58:B7:33:E4:C2:84,000000"); +// 58:B7:33:E4:C2:84Ϊmacַ ,Ϊָ 000000Ϊӻ +// ===================رע================== +// ʹֻ鿴CH9141macַCH9141Ϊӻʹֻ +// ʹñӵʱ뽫macһ +// ֻ鿴macַΪ61:62:63:64:65:67ʹñӵʱӦд +// bluetooth_ch9141_default_connect("67:65:64:63:62:61,000000"); +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_default_connect(const int8 *mac_and_password) +{ + bluetooth_ch9141_send_at_command_parameter("CONADD", mac_and_password); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģȡrssi(źǿ) +// @param void +// @return int8 źǿ0-127 +// @since v1.0 +// Sample usage: +// @note ô˺Ҫȵbluetooth_ch9141_enter_at_modeCMD ATģʽ +// Ҫرעbluetooth_ch9141_enter_at_modeڲ500msʱ +//------------------------------------------------------------------------------------------------------------------- +int16 bluetooth_ch9141_get_rssi(void) +{ + uint8 i; + size_t length; + int16 rssi; + bluetooth_ch9141_send_at_command_parameter("RSSI", "ON,0"); + length = strlen((int8 *)at_mode_data); + length -= 12;//RSSI жλ + + rssi = 0; + for(i=0; i30) { - if(gpio_get(RTS_PIN)) - { - return len;//ģæ,ǰʹwhileȴ ʹúע͵whileȴ滻if - } - //while(gpio_get(RTS_PIN)); //RTSΪ͵ƽ +// if(gpio_get(RTS_PIN)) +// { +// return len;//ģæ,ǰʹwhileȴ ʹúע͵whileȴ滻if +// } + while(gpio_get(RTS_PIN)); //RTSΪ͵ƽ uart_putbuff(WIRELESS_UART,buff,30); buff += 30; //ַƫ len -= 30;// } - if(gpio_get(RTS_PIN)) - { - return len;//ģæ,ǰʹwhileȴ ʹúע͵whileȴ滻if - } - //while(gpio_get(RTS_PIN)); //RTSΪ͵ƽ +// if(gpio_get(RTS_PIN)) +// { +// return len;//ģæ,ǰʹwhileȴ ʹúע͵whileȴ滻if +// } + while(gpio_get(RTS_PIN)); //RTSΪ͵ƽ uart_putbuff(WIRELESS_UART,buff,len);// return 0; diff --git a/Example/UART_Demo/Libraries/seekfree_peripheral/SEEKFREE_WIRELESS.h b/Example/UART_Demo/Libraries/seekfree_peripheral/SEEKFREE_WIRELESS.h index 42c0832..d80339d 100644 --- a/Example/UART_Demo/Libraries/seekfree_peripheral/SEEKFREE_WIRELESS.h +++ b/Example/UART_Demo/Libraries/seekfree_peripheral/SEEKFREE_WIRELESS.h @@ -38,8 +38,26 @@ #define WIRELESS_UART_RX UART2_RX_P10_6 #define WIRELESS_UART_BAUD 115200 -#define RTS_PIN P10_2 //λ ָʾǰģǷԽ 0Լ 1Լ +// ------------------------------------ Զ ------------------------------------ +// ע1תģ汾V2.0µ޷Զʵġ +// ע2ԶRTSţῪʧܡ +// ע3ģԶʧܵĻԳԶϵ +// ԶĶ ע +// ԶĶ ע +// ԶĶ ע + +// 0رԶ +// 1Զ Զʵ޸WIRELESS_UART_BAUD֮ҪģãģԶΪӦIJ + +#define WIRELESS_AUTO_UART_BAUD 0 +// ------------------------------------ Զ ------------------------------------ + +#define RTS_PIN P10_2 //λ ָʾǰģǷԽ 0Լ 1Լ +#define WIRELESS_BUFFER_SIZE 16 + +extern uint8 wireless_send_buffer[WIRELESS_BUFFER_SIZE]; +extern uint32 wireless_rx_index; void wireless_uart_callback(void); void seekfree_wireless_init(void); diff --git a/Example/UART_Demo/USER/isr.c b/Example/UART_Demo/USER/isr.c index c55a012..16bff98 100644 --- a/Example/UART_Demo/USER/isr.c +++ b/Example/UART_Demo/USER/isr.c @@ -179,7 +179,20 @@ IFX_INTERRUPT(uart2_rx_isr, 0, UART2_RX_INT_PRIO) { enableInterrupts();//жǶ IfxAsclin_Asc_isrReceive(&uart2_handle); - wireless_uart_callback(); + switch(wireless_type) + { + case WIRELESS_SI24R1: + { + wireless_uart_callback(); + }break; + + case WIRELESS_CH9141: + { + bluetooth_ch9141_uart_callback(); + }break; + default:break; + } + } IFX_INTERRUPT(uart2_er_isr, 0, UART2_ER_INT_PRIO) { diff --git a/Example/UART_Demo/删除临时文件.bat b/Example/UART_Demo/删除临时文件.bat index 5323dd9..fa499b1 100644 --- a/Example/UART_Demo/删除临时文件.bat +++ b/Example/UART_Demo/删除临时文件.bat @@ -1,9 +1,6 @@ -rmdir .settings /s /q rmdir Debug /s /q del *.launch /s - -pause exit diff --git a/Seekfree_TC264_Opensource_Library/.cproject b/Seekfree_TC264_Opensource_Library/.cproject index 0a032ca..69888ae 100644 --- a/Seekfree_TC264_Opensource_Library/.cproject +++ b/Seekfree_TC264_Opensource_Library/.cproject @@ -3,9 +3,9 @@ - + - + @@ -25,50 +25,76 @@ - + - + - + - @@ -354,12 +362,14 @@ + + - + - + @@ -379,43 +389,1895 @@ - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -433,13 +2295,37 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + @@ -463,6 +2349,18 @@ + + + + + + + + + + + + diff --git a/Seekfree_TC264_Opensource_Library/.project b/Seekfree_TC264_Opensource_Library/.project index 0c7e5a1..fef13df 100644 --- a/Seekfree_TC264_Opensource_Library/.project +++ b/Seekfree_TC264_Opensource_Library/.project @@ -5,6 +5,18 @@ + + com.infineon.aurix.buildsystem.builders.booster + full,incremental, + + + + + com.infineon.aurix.buildsystem.builders.autodiscovery + full,incremental, + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder clean,full,incremental, diff --git a/Seekfree_TC264_Opensource_Library/.settings/com.infineon.aurix.buildsystem.prefs b/Seekfree_TC264_Opensource_Library/.settings/com.infineon.aurix.buildsystem.prefs new file mode 100644 index 0000000..be61bc1 --- /dev/null +++ b/Seekfree_TC264_Opensource_Library/.settings/com.infineon.aurix.buildsystem.prefs @@ -0,0 +1,10 @@ +AURIX-LIBRARY-PATH=Libraries/iLLD\#Libraries/Infra\#Libraries/Service +DEVICE-ID=TC26B +DEVICE-ID-FULL=TC26xD_B-Step +ILLD-SET=full +IncludesAutodiscovery=true +LIBRARIES-ROOT-PATH=Libraries +NEVER-EXCLUDE-FROM-BUILD=/Libraries/iLLD/TC26B/Tricore/Cpu/CStart\#/Libraries/iLLD/TC26B/Tricore/Cpu/Trap\#/Configurations\#/Configurations/Debug +PROJECT-VERSION=1.0 +aurixDevice=TC26xD_B-Step +eclipse.preferences.version=1 diff --git a/Seekfree_TC264_Opensource_Library/Libraries/doc/version.txt b/Seekfree_TC264_Opensource_Library/Libraries/doc/version.txt index 59d6b65..11ab82e 100644 --- a/Seekfree_TC264_Opensource_Library/Libraries/doc/version.txt +++ b/Seekfree_TC264_Opensource_Library/Libraries/doc/version.txt @@ -1,3 +1,10 @@ +V1.2.0 + CH9141תģ + ͵öٱ + ޸ ɾʱļ.bat ִԶرմ + ޸ ɾʱļ.bat ɾ°汾ļ + ޸ĹĿļ֧°汾 + V1.1.10 ޸ͨ#pragma section all "cpux_dsram"ָλʧЧ diff --git a/Seekfree_TC264_Opensource_Library/Libraries/seekfree_libraries/common/common.c b/Seekfree_TC264_Opensource_Library/Libraries/seekfree_libraries/common/common.c index 0b9931e..7620ce6 100644 --- a/Seekfree_TC264_Opensource_Library/Libraries/seekfree_libraries/common/common.c +++ b/Seekfree_TC264_Opensource_Library/Libraries/seekfree_libraries/common/common.c @@ -27,6 +27,8 @@ CAMERA_TYPE_enum camera_type; //ͷͺ uint8 *camera_buffer_addr; //ͷַ +WIRELESS_TYPE_enum wireless_type;//ת + IFX_ALIGN(4) IfxCpu_syncEvent g_cpuSyncEvent = 0;//¼ͬ App_Cpu0 g_AppCpu0; //ƵϢ diff --git a/Seekfree_TC264_Opensource_Library/Libraries/seekfree_libraries/common/common.h b/Seekfree_TC264_Opensource_Library/Libraries/seekfree_libraries/common/common.h index 84c43ee..5b741c0 100644 --- a/Seekfree_TC264_Opensource_Library/Libraries/seekfree_libraries/common/common.h +++ b/Seekfree_TC264_Opensource_Library/Libraries/seekfree_libraries/common/common.h @@ -113,6 +113,12 @@ typedef enum //ö CAMERA_COLOR, //ͫ }CAMERA_TYPE_enum; +typedef enum //ģ +{ + WIRELESS_SI24R1 = 1, //ת + WIRELESS_CH9141, //ת +}WIRELESS_TYPE_enum; + #include #include #include "IfxCpu.h" @@ -120,6 +126,8 @@ typedef enum //ö extern CAMERA_TYPE_enum camera_type; //ͷͺ extern uint8 *camera_buffer_addr; //ͷַ +extern WIRELESS_TYPE_enum wireless_type; + extern IfxCpu_syncEvent g_cpuSyncEvent; void get_clk(void); diff --git a/Seekfree_TC264_Opensource_Library/Libraries/seekfree_libraries/headfile.h b/Seekfree_TC264_Opensource_Library/Libraries/seekfree_libraries/headfile.h index 404ee0a..b745302 100644 --- a/Seekfree_TC264_Opensource_Library/Libraries/seekfree_libraries/headfile.h +++ b/Seekfree_TC264_Opensource_Library/Libraries/seekfree_libraries/headfile.h @@ -65,6 +65,7 @@ #include "SEEKFREE_7725.h" #include "SEEKFREE_RDA5807.h" #include "SEEKFREE_7725_UART.h" +#include "SEEKFREE_BLUETOOTH_CH9141.h" #endif diff --git a/Seekfree_TC264_Opensource_Library/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.c b/Seekfree_TC264_Opensource_Library/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.c new file mode 100644 index 0000000..b4ec2df --- /dev/null +++ b/Seekfree_TC264_Opensource_Library/Libraries/seekfree_peripheral/SEEKFREE_BLUETOOTH_CH9141.c @@ -0,0 +1,509 @@ +/********************************************************************************************************************* + * COPYRIGHT NOTICE + * Copyright (c) 2021,ɿƼ + * All rights reserved. + * QQȺһȺ179029047() Ⱥ244861897 + * + * ݰȨɿƼУδҵ; + * ӭλʹò޸ʱ뱣ɿƼİȨ + * + * @file ɿƼתģ + * @company ɶɿƼ޹˾ + * @author ɿƼ(QQ3184284598) + * @version 鿴docversionļ 汾˵ + * @Software IAR 8.3 or MDK 5.33 + * @Taobao https://seekfree.taobao.com/ + * @date 2021-08-27 + * @note + ߶壺 + ------------------------------------ + ת Ƭ + RX 鿴SEEKFREE_BLUETOOTH_CH9141.hļеBLUETOOTH_CH9141_UART_TX궨 + TX 鿴SEEKFREE_BLUETOOTH_CH9141.hļеBLUETOOTH_CH9141_UART_RX궨 + RTS 鿴SEEKFREE_BLUETOOTH_CH9141.hļеBLUETOOTH_CH9141_RTS_PIN궨 + CTS + CMD ջ + ------------------------------------ + ********************************************************************************************************************/ +#include "zf_stm_systick.h" +#include "zf_gpio.h" +#include "zf_uart.h" +#include "zf_assert.h" +#include "SEEKFREE_BLUETOOTH_CH9141.h" + +uint8 uart_flag; +uint8 uart_data; + +vuint8 at_mode = 0; //0:͸ģʽ 1:ATģʽ 2:ģ鸴λ +vuint8 at_mode_num; //atģʽʱָʾݽյ +vuint8 at_mode_data[30]; //atĻ +vuint8 at_mode_cmd_flag; //OKӦճɹı־λ + +uint8 mac_address[17]; //macַ + + +uint8 bluetooth_ch9141_rx_buffer; + + +void bluetooth_ch9141_check_response(void); + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ жϻص +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note úISRļ 8жϳ򱻵 +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_uart_callback() +{ + while(uart_query(BLUETOOTH_CH9141_UART, &bluetooth_ch9141_rx_buffer)) + { + if(1 == at_mode) + { + //ATģʽ Ӧź ˴ifڴûҪĶ + at_mode_data[at_mode_num++] = bluetooth_ch9141_rx_buffer; + bluetooth_ch9141_check_response(); + } + else if(2 == at_mode) + { + //ģڸλ ˴ifڴûҪĶ + at_mode_num++; + } + else + { + //͸ģʽ ûڴ˴Ե͹Ķ + //ӵһֽںƬ˴ͨڴ˴ȡbluetooth_ch9141_rx_bufferȡ + + // ȡߴڵ λձ־ + uart_flag = 1; + uart_data = bluetooth_ch9141_rx_buffer; + } + + } +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģOKӦź +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note û +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_check_response(void) +{ + if(4 <= at_mode_num) + { + if(0 == strncmp("OK\r\n", (int8 *)&at_mode_data[at_mode_num-4], 4)) + { + at_mode_cmd_flag = 1; + } + } +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ鷢һûвȴӦź +// @param *str Ҫ͵ ַ +// @return void +// @since v1.0 +// Sample usage: +// @note û +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_send_at_command(const int8 *str) +{ + at_mode_num = 0; // + uart_putstr(BLUETOOTH_CH9141_UART, str); + uart_putstr(BLUETOOTH_CH9141_UART, "\r\n"); + + //ȴյӦź + while(!at_mode_cmd_flag); + at_mode_cmd_flag = 0; +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ鷢һвȴӦź +// @param *cmd Ҫ͵ +// @param *data Ҫ͵ +// @return void +// @since v1.0 +// Sample usage: +// @note û +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_send_at_command_parameter(const int8 *cmd, const int8 *data) +{ + at_mode_num = 0; // + uart_putstr(BLUETOOTH_CH9141_UART, "AT+"); + uart_putstr(BLUETOOTH_CH9141_UART, cmd); + uart_putstr(BLUETOOTH_CH9141_UART, "="); + uart_putstr(BLUETOOTH_CH9141_UART, data); + uart_putstr(BLUETOOTH_CH9141_UART, "\r\n"); + + //ȴյӦź + while(!at_mode_cmd_flag); + at_mode_cmd_flag = 0; +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģATģʽ +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_enter_at_mode(void) +{ + systick_delay_ms(STM0, 550); //ͽATģʽǰҪ֤ģ550msûнչκ + at_mode = 1; //ATģʽ + bluetooth_ch9141_send_at_command("AT..."); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ˳ATģʽ +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_exit_at_mode(void) +{ + bluetooth_ch9141_send_at_command("AT+EXIT"); + at_mode = 0; //͸ģʽ + systick_delay_ms(STM0, 300); //ȴɹATģʽ +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ鸴λ +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_reset(void) +{ + bluetooth_ch9141_send_at_command("AT+RESET"); + at_mode = 2; //ɹ + at_mode_num = 0; + while(7 > at_mode_num); //ȴģɸλ + at_mode = 0; //λ֮ģԶ͸ģʽ +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģȡMACַ +// @param NULL +// @return void +// @since v1.0 +// Sample usage: +// @note ô˺Ҫȵbluetooth_ch9141_enter_at_modeCMD ATģʽ +// Ҫرעbluetooth_ch9141_enter_at_modeڲ500msʱ +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_get_mac_address(void) +{ + bluetooth_ch9141_send_at_command("AT+MAC?"); + + //macַΪСθʽmac_address[0]macַλ + memcpy(mac_address, (uint8 *)at_mode_data, 17); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ÷͹ +// @param tx_power ÷͹ʣѡ鿴CH9141_TX_POWEER_enumöٳԱ +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_set_tx_power(CH9141_TX_POWEER_enum tx_power) +{ + int8 tx_power_data; + + tx_power_data = (uint8)tx_power + '0'; + bluetooth_ch9141_send_at_command_parameter("TPL", &tx_power_data); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģģʽ +// @param mode ģʽãѡ鿴CH9141_MODE_enumöٳԱ +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_set_mode(CH9141_MODE_enum mode) +{ + int8 mode_data; + + mode_data = (uint8)mode + '0'; + bluetooth_ch9141_send_at_command_parameter("BLEMODE", &mode_data); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģȡ״̬ +// @param mode ģʽãѡ鿴CH9141_MODE_enumöٳԱ +// @return CH9141_STATUS_enum ״̬Ϣ +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +CH9141_STATUS_enum bluetooth_ch9141_get_status(CH9141_MODE_enum mode) +{ + CH9141_STATUS_enum ch9141_status; + int8 mode_data; + + mode_data = (uint8)mode + '0'; + bluetooth_ch9141_send_at_command_parameter("BLEMODE", &mode_data); + + bluetooth_ch9141_send_at_command("AT+BLESTA?"); + + ch9141_status = (at_mode_data[0] - '0') * 10 + (at_mode_data[1] - '0'); + if(SLAVE_MODE == mode) + { + ch9141_status += SLAVE_NO_INIT; + } + + return ch9141_status; +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ豸 +// @param *str +// @return void +// @since v1.0 +// Sample usage: +// @note ƳȲܳ18ַ ֻΪӢ +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_set_name(const int8 *str) +{ + bluetooth_ch9141_send_at_command_parameter("NAME", str); + bluetooth_ch9141_send_at_command_parameter("PNAME", str); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģ +// @param enable ʹ 0ʹ룬1ʹӱ豸 +// @param *password ַ Ϊ6ַ +// @return void +// @since v1.0 +// Sample usage: +// @note +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_set_password(uint8 enable, const int8 *password) +{ + if(0 == enable) + { + //ر + bluetooth_ch9141_send_at_command_parameter("PASEN", "OFF"); + } + else + { + //벢ʹ + bluetooth_ch9141_send_at_command_parameter("PASEN", "ON"); + bluetooth_ch9141_send_at_command_parameter("PASS", password); + } +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģָMACַ +// @param *mac_and_password Ҫӵ豸macַ +// @return void +// @since v1.0 +// Sample usage: +// @note bluetooth_ch9141_connect("58:B7:33:E4:C2:84,000000"); +// 58:B7:33:E4:C2:84Ϊmacַ ,Ϊָ 000000Ϊӻ +// ===================رע================== +// ʹֻ鿴macַʹñӵʱ뽫macһ +// ֻ鿴macַΪ61:62:63:64:65:66ʹñӵʱӦд +// bluetooth_ch9141_connect("66:65:64:63:62:61,000000"); +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_connect(const int8 *mac_and_password) +{ + bluetooth_ch9141_send_at_command_parameter("CONN", mac_and_password); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģĬӲãúúÿοԶ豸 +// @param *mac_and_password Ҫӵ豸macַ +// @return void +// @since v1.0 +// Sample usage: +// @note bluetooth_ch9141_default_connect("58:B7:33:E4:C2:84,000000"); +// 58:B7:33:E4:C2:84Ϊmacַ ,Ϊָ 000000Ϊӻ +// ===================رע================== +// ʹֻ鿴CH9141macַCH9141Ϊӻʹֻ +// ʹñӵʱ뽫macһ +// ֻ鿴macַΪ61:62:63:64:65:67ʹñӵʱӦд +// bluetooth_ch9141_default_connect("67:65:64:63:62:61,000000"); +//------------------------------------------------------------------------------------------------------------------- +void bluetooth_ch9141_default_connect(const int8 *mac_and_password) +{ + bluetooth_ch9141_send_at_command_parameter("CONADD", mac_and_password); +} + +//------------------------------------------------------------------------------------------------------------------- +// @brief תģȡrssi(źǿ) +// @param void +// @return int8 źǿ0-127 +// @since v1.0 +// Sample usage: +// @note ô˺Ҫȵbluetooth_ch9141_enter_at_modeCMD ATģʽ +// Ҫرעbluetooth_ch9141_enter_at_modeڲ500msʱ +//------------------------------------------------------------------------------------------------------------------- +int16 bluetooth_ch9141_get_rssi(void) +{ + uint8 i; + size_t length; + int16 rssi; + bluetooth_ch9141_send_at_command_parameter("RSSI", "ON,0"); + length = strlen((int8 *)at_mode_data); + length -= 12;//RSSI жλ + + rssi = 0; + for(i=0; i30) { - if(gpio_get(RTS_PIN)) - { - return len;//ģæ,ǰʹwhileȴ ʹúע͵whileȴ滻if - } - //while(gpio_get(RTS_PIN)); //RTSΪ͵ƽ +// if(gpio_get(RTS_PIN)) +// { +// return len;//ģæ,ǰʹwhileȴ ʹúע͵whileȴ滻if +// } + while(gpio_get(RTS_PIN)); //RTSΪ͵ƽ uart_putbuff(WIRELESS_UART,buff,30); buff += 30; //ַƫ len -= 30;// } - if(gpio_get(RTS_PIN)) - { - return len;//ģæ,ǰʹwhileȴ ʹúע͵whileȴ滻if - } - //while(gpio_get(RTS_PIN)); //RTSΪ͵ƽ +// if(gpio_get(RTS_PIN)) +// { +// return len;//ģæ,ǰʹwhileȴ ʹúע͵whileȴ滻if +// } + while(gpio_get(RTS_PIN)); //RTSΪ͵ƽ uart_putbuff(WIRELESS_UART,buff,len);// return 0; diff --git a/Seekfree_TC264_Opensource_Library/Libraries/seekfree_peripheral/SEEKFREE_WIRELESS.h b/Seekfree_TC264_Opensource_Library/Libraries/seekfree_peripheral/SEEKFREE_WIRELESS.h index 42c0832..d80339d 100644 --- a/Seekfree_TC264_Opensource_Library/Libraries/seekfree_peripheral/SEEKFREE_WIRELESS.h +++ b/Seekfree_TC264_Opensource_Library/Libraries/seekfree_peripheral/SEEKFREE_WIRELESS.h @@ -38,8 +38,26 @@ #define WIRELESS_UART_RX UART2_RX_P10_6 #define WIRELESS_UART_BAUD 115200 -#define RTS_PIN P10_2 //λ ָʾǰģǷԽ 0Լ 1Լ +// ------------------------------------ Զ ------------------------------------ +// ע1תģ汾V2.0µ޷Զʵġ +// ע2ԶRTSţῪʧܡ +// ע3ģԶʧܵĻԳԶϵ +// ԶĶ ע +// ԶĶ ע +// ԶĶ ע + +// 0رԶ +// 1Զ Զʵ޸WIRELESS_UART_BAUD֮ҪģãģԶΪӦIJ + +#define WIRELESS_AUTO_UART_BAUD 0 +// ------------------------------------ Զ ------------------------------------ + +#define RTS_PIN P10_2 //λ ָʾǰģǷԽ 0Լ 1Լ +#define WIRELESS_BUFFER_SIZE 16 + +extern uint8 wireless_send_buffer[WIRELESS_BUFFER_SIZE]; +extern uint32 wireless_rx_index; void wireless_uart_callback(void); void seekfree_wireless_init(void); diff --git a/Seekfree_TC264_Opensource_Library/USER/isr.c b/Seekfree_TC264_Opensource_Library/USER/isr.c index c55a012..1dded30 100644 --- a/Seekfree_TC264_Opensource_Library/USER/isr.c +++ b/Seekfree_TC264_Opensource_Library/USER/isr.c @@ -179,7 +179,20 @@ IFX_INTERRUPT(uart2_rx_isr, 0, UART2_RX_INT_PRIO) { enableInterrupts();//жǶ IfxAsclin_Asc_isrReceive(&uart2_handle); - wireless_uart_callback(); + switch(wireless_type) + { + case WIRELESS_SI24R1: + { + wireless_uart_callback(); + }break; + + case WIRELESS_CH9141: + { + bluetooth_ch9141_uart_callback(); + }break; + default:break; + } + } IFX_INTERRUPT(uart2_er_isr, 0, UART2_ER_INT_PRIO) { diff --git a/Seekfree_TC264_Opensource_Library/删除临时文件.bat b/Seekfree_TC264_Opensource_Library/删除临时文件.bat index 5323dd9..fa499b1 100644 --- a/Seekfree_TC264_Opensource_Library/删除临时文件.bat +++ b/Seekfree_TC264_Opensource_Library/删除临时文件.bat @@ -1,9 +1,6 @@ -rmdir .settings /s /q rmdir Debug /s /q del *.launch /s - -pause exit diff --git a/Seekfree_TC264_Opensource_Library/尽量不要使用的引脚.txt b/Seekfree_TC264_Opensource_Library/尽量不要使用的引脚.txt index ca712ca..e5bde1c 100644 --- a/Seekfree_TC264_Opensource_Library/尽量不要使用的引脚.txt +++ b/Seekfree_TC264_Opensource_Library/尽量不要使用的引脚.txt @@ -7,4 +7,8 @@ P14.4 P14.5 P14.6 P10.5 -P10.6 \ No newline at end of file +P10.6 + +P20.2 ֻ벻 + +P21.6 TC264DAоƬ޷ʹãTC264Dпʹ \ No newline at end of file