Added rf switch 2

This commit is contained in:
Alexey Bazlaev 2023-05-24 17:39:59 +07:00
parent 9240291fb1
commit e92f44a3d8
7 changed files with 1112 additions and 1086 deletions

View File

@ -90,7 +90,7 @@
#include "FreeRTOS_Sockets.h" #include "FreeRTOS_Sockets.h"
#include "rf_switch_driver.h" #include "rf_switch_driver.h"
extern struct rf_switch_config rfSwitchConfig; extern struct rf_switch_config rfSwitch1Config, rfSwitch2Config;
/* Remove the whole file if FreeRTOSIPConfig.h is set to exclude TCP. */ /* Remove the whole file if FreeRTOSIPConfig.h is set to exclude TCP. */
#if( ipconfigUSE_TCP == 1 ) #if( ipconfigUSE_TCP == 1 )
@ -310,44 +310,78 @@ uint8_t *pucRxBuffer;
/* If data was received, echo it back. */ /* If data was received, echo it back. */
if( lBytes > 0 ) if( lBytes > 0 )
{ {
RF_OUT_ENUM state = -1; RF_OUT_ENUM state1 = -1, state2 = -1;
int8_t enable = -1; int8_t enable1 = -1, enable2 = -1;
if (!strcmp("RF_ON", (char*)pucRxBuffer)) if (!strcmp("RF1_ON", (char*)pucRxBuffer))
{ {
vRFSwitchEnable(&rfSwitchConfig); vRFSwitchEnable(&rfSwitch1Config);
enable = pdTRUE; enable1 = pdTRUE;
} }
else if (!strcmp("RF_OFF", (char*)pucRxBuffer)) else if (!strcmp("RF1_OFF", (char*)pucRxBuffer))
{ {
vRFSwitchDisable(&rfSwitchConfig); vRFSwitchDisable(&rfSwitch1Config);
enable = pdFALSE; enable1 = pdFALSE;
} }
else if (!strcmp("RF01", (char*)pucRxBuffer)) else if (!strcmp("RF2_ON", (char*)pucRxBuffer))
state = xRFSwitchSet(&rfSwitchConfig, RF_OUT_01); {
else if (!strcmp("RF02", (char*)pucRxBuffer)) vRFSwitchEnable(&rfSwitch2Config);
state = xRFSwitchSet(&rfSwitchConfig, RF_OUT_02); enable2 = pdTRUE;
else if (!strcmp("RF03", (char*)pucRxBuffer)) }
state = xRFSwitchSet(&rfSwitchConfig, RF_OUT_03); else if (!strcmp("RF2_OFF", (char*)pucRxBuffer))
else if (!strcmp("RF04", (char*)pucRxBuffer)) {
state = xRFSwitchSet(&rfSwitchConfig, RF_OUT_04); vRFSwitchDisable(&rfSwitch2Config);
else if (!strcmp("RF05", (char*)pucRxBuffer)) enable2 = pdFALSE;
state = xRFSwitchSet(&rfSwitchConfig, RF_OUT_05); }
else if (!strcmp("RF06", (char*)pucRxBuffer)) else if (!strcmp("RF101", (char*)pucRxBuffer))
state = xRFSwitchSet(&rfSwitchConfig, RF_OUT_06); state1 = xRFSwitchSet(&rfSwitch1Config, RF_OUT_01);
else if (!strcmp("RF07", (char*)pucRxBuffer)) else if (!strcmp("RF102", (char*)pucRxBuffer))
state = xRFSwitchSet(&rfSwitchConfig, RF_OUT_07); state1 = xRFSwitchSet(&rfSwitch1Config, RF_OUT_02);
else if (!strcmp("RF08", (char*)pucRxBuffer)) else if (!strcmp("RF103", (char*)pucRxBuffer))
state = xRFSwitchSet(&rfSwitchConfig, RF_OUT_08); state1 = xRFSwitchSet(&rfSwitch1Config, RF_OUT_03);
else if (!strcmp("RF104", (char*)pucRxBuffer))
state1 = xRFSwitchSet(&rfSwitch1Config, RF_OUT_04);
else if (!strcmp("RF105", (char*)pucRxBuffer))
state1 = xRFSwitchSet(&rfSwitch1Config, RF_OUT_05);
else if (!strcmp("RF106", (char*)pucRxBuffer))
state1 = xRFSwitchSet(&rfSwitch1Config, RF_OUT_06);
else if (!strcmp("RF107", (char*)pucRxBuffer))
state1 = xRFSwitchSet(&rfSwitch1Config, RF_OUT_07);
else if (!strcmp("RF108", (char*)pucRxBuffer))
state1 = xRFSwitchSet(&rfSwitch1Config, RF_OUT_08);
else if (!strcmp("RF201", (char*)pucRxBuffer))
state2 = xRFSwitchSet(&rfSwitch2Config, RF_OUT_01);
else if (!strcmp("RF202", (char*)pucRxBuffer))
state2 = xRFSwitchSet(&rfSwitch2Config, RF_OUT_02);
else if (!strcmp("RF203", (char*)pucRxBuffer))
state2 = xRFSwitchSet(&rfSwitch2Config, RF_OUT_03);
else if (!strcmp("RF204", (char*)pucRxBuffer))
state2 = xRFSwitchSet(&rfSwitch2Config, RF_OUT_04);
else if (!strcmp("RF205", (char*)pucRxBuffer))
state2 = xRFSwitchSet(&rfSwitch2Config, RF_OUT_05);
else if (!strcmp("RF206", (char*)pucRxBuffer))
state2 = xRFSwitchSet(&rfSwitch2Config, RF_OUT_06);
else if (!strcmp("RF207", (char*)pucRxBuffer))
state2 = xRFSwitchSet(&rfSwitch2Config, RF_OUT_07);
else if (!strcmp("RF208", (char*)pucRxBuffer))
state2 = xRFSwitchSet(&rfSwitch2Config, RF_OUT_08);
if ( RF_OUT_01 <= state && state <= RF_OUT_08 ) if ( RF_OUT_01 <= state1 && state1 <= RF_OUT_08 )
FreeRTOS_debug_printf(("Switched to %s\n", (char*)pucRxBuffer)); FreeRTOS_debug_printf(("RF switch1 switched to %s\n", (char*)pucRxBuffer));
else if ( enable == 1 ) else if ( enable1 == 1 )
FreeRTOS_debug_printf(("RF switch ON\n")); FreeRTOS_debug_printf(("RF switch1 ON\n"));
else if ( enable == 0 ) else if ( enable1 == 0 )
FreeRTOS_debug_printf(("RF switch OFF\n")); FreeRTOS_debug_printf(("RF switch1 OFF\n"));
else if ( RF_OUT_01 <= state2 && state2 <= RF_OUT_08 )
FreeRTOS_debug_printf(("RF switch2 switched to %s\n", (char*)pucRxBuffer));
else if ( enable2 == 1 )
FreeRTOS_debug_printf(("RF switch2 ON\n"));
else if ( enable2 == 0 )
FreeRTOS_debug_printf(("RF switch2 OFF\n"));
else else
FreeRTOS_debug_printf(("Wrong command\n")); FreeRTOS_debug_printf(("Wrong command\n"));
lSent = 0; lSent = 0;
lTotalSent = 0; lTotalSent = 0;

View File

@ -28,7 +28,7 @@
#ifndef NETWORK_INTERFACE_H #ifndef NETWORK_INTERFACE_H
#define NETWORK_INTERFACE_H #define NETWORK_INTERFACE_H
#ifndef STM32_PORT //#ifndef STM32_PORT
//#include "FreeRTOS.h" //#include "FreeRTOS.h"
//#include "FreeRTOSIPConfig.h" //#include "FreeRTOSIPConfig.h"
//#include "stdio.h" //#include "stdio.h"
@ -42,7 +42,7 @@
BaseType_t xNetworkInterfaceInitialise( void ); BaseType_t xNetworkInterfaceInitialise( void );
BaseType_t xNetworkInterfaceOutput( NetworkBufferDescriptor_t * const pxDescriptor,BaseType_t xReleaseAfterSend ); BaseType_t xNetworkInterfaceOutput( NetworkBufferDescriptor_t * const pxDescriptor,BaseType_t xReleaseAfterSend );
#else /*STM32_PORT*/ //#else /*STM32_PORT*/
#include "stdint.h" #include "stdint.h"
#include "FreeRTOS.h" #include "FreeRTOS.h"
#include "FreeRTOS_IP.h" #include "FreeRTOS_IP.h"
@ -353,5 +353,5 @@ BaseType_t xGetPhyLinkStatus( void );
} /* extern "C" */ } /* extern "C" */
#endif #endif
/* *INDENT-ON* */ /* *INDENT-ON* */
#endif /*STM32_PORT*/ //#endif /*STM32_PORT*/
#endif /* NETWORK_INTERFACE_H */ #endif /* NETWORK_INTERFACE_H */

File diff suppressed because one or more lines are too long

View File

@ -140,7 +140,7 @@
<SetRegEntry> <SetRegEntry>
<Number>0</Number> <Number>0</Number>
<Key>CMSIS_AGDI</Key> <Key>CMSIS_AGDI</Key>
<Name>-X"Any" -UAny -O1230 -S0 -C0 -P00000000 -N00("ARM CoreSight SW-DP") -D00(1BA01477) -L00(0) -TO65554 -TC10000000 -TT10000000 -TP20 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO23 -FD20000000 -FC1000 -FN1 -FF0GD32F10x_CL.FLM -FS08000000 -FL040000 -FP0($$Device:GD32F107VC$Flash\GD32F10x_CL.FLM)</Name> <Name>-X"Any" -UAny -O1230 -S8 -C0 -P00000000 -N00("ARM CoreSight SW-DP") -D00(1BA01477) -L00(0) -TO65554 -TC10000000 -TT10000000 -TP20 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO23 -FD20000000 -FC1000 -FN1 -FF0GD32F10x_CL.FLM -FS08000000 -FL040000 -FP0($$Device:GD32F107VC$Flash\GD32F10x_CL.FLM)</Name>
</SetRegEntry> </SetRegEntry>
<SetRegEntry> <SetRegEntry>
<Number>0</Number> <Number>0</Number>
@ -153,24 +153,7 @@
<Name>UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0GD32F10x_CL -FS08000000 -FL040000 -FP0($$Device:GD32F107VC$Flash\GD32F10x_CL.FLM))</Name> <Name>UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0GD32F10x_CL -FS08000000 -FL040000 -FP0($$Device:GD32F107VC$Flash\GD32F10x_CL.FLM))</Name>
</SetRegEntry> </SetRegEntry>
</TargetDriverDllRegistry> </TargetDriverDllRegistry>
<Breakpoint> <Breakpoint/>
<Bp>
<Number>0</Number>
<Type>0</Type>
<LineNumber>323</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>0</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>0</BreakIfRCount>
<Filename>.\FreeRTOS\source\FreeRTOS_IP.c</Filename>
<ExecCommand></ExecCommand>
<Expression></Expression>
</Bp>
</Breakpoint>
<WatchWindow1> <WatchWindow1>
<Ww> <Ww>
<count>0</count> <count>0</count>
@ -308,7 +291,7 @@
</Mm> </Mm>
</MemoryWindow3> </MemoryWindow3>
<ScvdPack> <ScvdPack>
<Filename>E:\Arm\Packs\ARM\CMSIS-FreeRTOS\10.5.1\CMSIS\RTOS2\FreeRTOS\FreeRTOS.scvd</Filename> <Filename>C:\Users\User\AppData\Local\Arm\Packs\ARM\CMSIS-FreeRTOS\10.5.1\CMSIS\RTOS2\FreeRTOS\FreeRTOS.scvd</Filename>
<Type>ARM.CMSIS-FreeRTOS.10.5.1</Type> <Type>ARM.CMSIS-FreeRTOS.10.5.1</Type>
<SubType>1</SubType> <SubType>1</SubType>
</ScvdPack> </ScvdPack>
@ -320,7 +303,7 @@
<periodic>1</periodic> <periodic>1</periodic>
<aLwin>1</aLwin> <aLwin>1</aLwin>
<aCover>0</aCover> <aCover>0</aCover>
<aSer1>0</aSer1> <aSer1>1</aSer1>
<aSer2>0</aSer2> <aSer2>0</aSer2>
<aPa>0</aPa> <aPa>0</aPa>
<viewmode>1</viewmode> <viewmode>1</viewmode>
@ -354,6 +337,12 @@
<pszMrulep></pszMrulep> <pszMrulep></pszMrulep>
<pSingCmdsp></pSingCmdsp> <pSingCmdsp></pSingCmdsp>
<pMultCmdsp></pMultCmdsp> <pMultCmdsp></pMultCmdsp>
<SystemViewers>
<Entry>
<Name>System Viewer\ENET_DMA</Name>
<WinId>35905</WinId>
</Entry>
</SystemViewers>
</TargetOption> </TargetOption>
</Target> </Target>
@ -451,7 +440,7 @@
<Group> <Group>
<GroupName>FreeRTOS</GroupName> <GroupName>FreeRTOS</GroupName>
<tvExp>1</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel> <cbSel>0</cbSel>
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>
@ -771,7 +760,7 @@
<Group> <Group>
<GroupName>::Device</GroupName> <GroupName>::Device</GroupName>
<tvExp>0</tvExp> <tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel> <cbSel>0</cbSel>
<RteFlg>1</RteFlg> <RteFlg>1</RteFlg>

View File

@ -338,7 +338,7 @@
<v6WtE>0</v6WtE> <v6WtE>0</v6WtE>
<v6Rtti>0</v6Rtti> <v6Rtti>0</v6Rtti>
<VariousControls> <VariousControls>
<MiscControls>-D DEBUG -D STM32_PORT -Wno-pragma-pack -Wno-macro-redefined -U CENTRALISED_DEFERRED_IRQ_HADLING</MiscControls> <MiscControls>-D DEBUG -U STM32_PORT -Wno-pragma-pack -Wno-macro-redefined -U CENTRALISED_DEFERRED_IRQ_HADLING</MiscControls>
<Define>DEBUG_LISTEN_SOCK</Define> <Define>DEBUG_LISTEN_SOCK</Define>
<Undefine></Undefine> <Undefine></Undefine>
<IncludePath>.\FreeRTOS\source\portable\NetworkInterface\include;.\FreeRTOS\source\include;.\FreeRTOS\source\portable\Compiler\Keil;.\DemoTasks\include;..\GigaDevice_test;.\include;.\PHY</IncludePath> <IncludePath>.\FreeRTOS\source\portable\NetworkInterface\include;.\FreeRTOS\source\include;.\FreeRTOS\source\portable\Compiler\Keil;.\DemoTasks\include;..\GigaDevice_test;.\include;.\PHY</IncludePath>

25
main.c
View File

@ -22,11 +22,18 @@
#define LED2_USER_PORT GPIOC #define LED2_USER_PORT GPIOC
#define LED5_TICK_PORT GPIOE #define LED5_TICK_PORT GPIOE
#define RF_SWITCH_PORT GPIOE
#define RF_SWITCH_PIN_A GPIO_PIN_10 #define RF_SWITCH1_PORT GPIOE
#define RF_SWITCH_PIN_B GPIO_PIN_11 #define RF_SWITCH1_PIN_A GPIO_PIN_7
#define RF_SWITCH_PIN_C GPIO_PIN_12 #define RF_SWITCH1_PIN_B GPIO_PIN_8
#define RF_SWITCH_PIN_EN GPIO_PIN_13 #define RF_SWITCH1_PIN_C GPIO_PIN_9
#define RF_SWITCH1_PIN_EN GPIO_PIN_10
#define RF_SWITCH2_PORT GPIOE
#define RF_SWITCH2_PIN_A GPIO_PIN_11
#define RF_SWITCH2_PIN_B GPIO_PIN_12
#define RF_SWITCH2_PIN_C GPIO_PIN_13
#define RF_SWITCH2_PIN_EN GPIO_PIN_14
#define LED2_USER GPIO_PIN_0 #define LED2_USER GPIO_PIN_0
#define LED5_TICK GPIO_PIN_1 #define LED5_TICK GPIO_PIN_1
@ -146,7 +153,7 @@ static const uint8_t ucDNSServerAddress[ 4 ] =
/* Use by the pseudo random number generator. */ /* Use by the pseudo random number generator. */
static UBaseType_t ulNextRand; static UBaseType_t ulNextRand;
struct rf_switch_config rfSwitchConfig; struct rf_switch_config rfSwitch1Config, rfSwitch2Config;
/* /*
* Just seeds the simple pseudo random number generator. * Just seeds the simple pseudo random number generator.
*/ */
@ -279,8 +286,9 @@ static void vInitMCU(void)
#ifndef STM32_PORT #ifndef STM32_PORT
enet_descriptors_chain_init(ENET_DMA_TX); enet_descriptors_chain_init(ENET_DMA_TX);
enet_descriptors_chain_init(ENET_DMA_RX); enet_descriptors_chain_init(ENET_DMA_RX);
enet_enable();
#endif #endif
enet_enable();
//nvic_irq_enable(ENET_IRQn, ipconfigMAC_INTERRUPT_PRIORITY, 0xFF); //nvic_irq_enable(ENET_IRQn, ipconfigMAC_INTERRUPT_PRIORITY, 0xFF);
__disable_irq(); __disable_irq();
NVIC_ClearPendingIRQ(ENET_IRQn); NVIC_ClearPendingIRQ(ENET_IRQn);
@ -367,7 +375,8 @@ static void prvMiscInitialisation( void )
int main(void) int main(void)
{ {
vInitMCU(); vInitMCU();
vRFSwitchInit(&rfSwitchConfig, RF_SWITCH_PORT, RF_SWITCH_PIN_A, RF_SWITCH_PORT, RF_SWITCH_PIN_B, RF_SWITCH_PORT, RF_SWITCH_PIN_C, RF_SWITCH_PORT, RF_SWITCH_PIN_EN); vRFSwitchInit(&rfSwitch1Config, RF_SWITCH1_PORT, RF_SWITCH1_PIN_A, RF_SWITCH1_PORT, RF_SWITCH1_PIN_B, RF_SWITCH1_PORT, RF_SWITCH1_PIN_C, RF_SWITCH1_PORT, RF_SWITCH1_PIN_EN);
vRFSwitchInit(&rfSwitch2Config, RF_SWITCH2_PORT, RF_SWITCH2_PIN_A, RF_SWITCH2_PORT, RF_SWITCH2_PIN_B, RF_SWITCH2_PORT, RF_SWITCH2_PIN_C, RF_SWITCH2_PORT, RF_SWITCH2_PIN_EN);
prvMiscInitialisation(); prvMiscInitialisation();
xTaskCreate( vTaskToggleLed, "ToggleLed", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 1, &vTaskToggleLed_Handle); xTaskCreate( vTaskToggleLed, "ToggleLed", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 1, &vTaskToggleLed_Handle);
xTaskCreate( vTaskHelloWorld, "HelloWorld", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 1, &vTaskHelloWorld_Handle); xTaskCreate( vTaskHelloWorld, "HelloWorld", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 1, &vTaskHelloWorld_Handle);