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 "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. */
#if( ipconfigUSE_TCP == 1 )
@ -310,44 +310,78 @@ uint8_t *pucRxBuffer;
/* If data was received, echo it back. */
if( lBytes > 0 )
{
RF_OUT_ENUM state = -1;
int8_t enable = -1;
RF_OUT_ENUM state1 = -1, state2 = -1;
int8_t enable1 = -1, enable2 = -1;
if (!strcmp("RF_ON", (char*)pucRxBuffer))
if (!strcmp("RF1_ON", (char*)pucRxBuffer))
{
vRFSwitchEnable(&rfSwitchConfig);
enable = pdTRUE;
vRFSwitchEnable(&rfSwitch1Config);
enable1 = pdTRUE;
}
else if (!strcmp("RF_OFF", (char*)pucRxBuffer))
else if (!strcmp("RF1_OFF", (char*)pucRxBuffer))
{
vRFSwitchDisable(&rfSwitchConfig);
enable = pdFALSE;
vRFSwitchDisable(&rfSwitch1Config);
enable1 = pdFALSE;
}
else if (!strcmp("RF01", (char*)pucRxBuffer))
state = xRFSwitchSet(&rfSwitchConfig, RF_OUT_01);
else if (!strcmp("RF02", (char*)pucRxBuffer))
state = xRFSwitchSet(&rfSwitchConfig, RF_OUT_02);
else if (!strcmp("RF03", (char*)pucRxBuffer))
state = xRFSwitchSet(&rfSwitchConfig, RF_OUT_03);
else if (!strcmp("RF04", (char*)pucRxBuffer))
state = xRFSwitchSet(&rfSwitchConfig, RF_OUT_04);
else if (!strcmp("RF05", (char*)pucRxBuffer))
state = xRFSwitchSet(&rfSwitchConfig, RF_OUT_05);
else if (!strcmp("RF06", (char*)pucRxBuffer))
state = xRFSwitchSet(&rfSwitchConfig, RF_OUT_06);
else if (!strcmp("RF07", (char*)pucRxBuffer))
state = xRFSwitchSet(&rfSwitchConfig, RF_OUT_07);
else if (!strcmp("RF08", (char*)pucRxBuffer))
state = xRFSwitchSet(&rfSwitchConfig, RF_OUT_08);
else if (!strcmp("RF2_ON", (char*)pucRxBuffer))
{
vRFSwitchEnable(&rfSwitch2Config);
enable2 = pdTRUE;
}
else if (!strcmp("RF2_OFF", (char*)pucRxBuffer))
{
vRFSwitchDisable(&rfSwitch2Config);
enable2 = pdFALSE;
}
else if (!strcmp("RF101", (char*)pucRxBuffer))
state1 = xRFSwitchSet(&rfSwitch1Config, RF_OUT_01);
else if (!strcmp("RF102", (char*)pucRxBuffer))
state1 = xRFSwitchSet(&rfSwitch1Config, RF_OUT_02);
else if (!strcmp("RF103", (char*)pucRxBuffer))
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);
if ( RF_OUT_01 <= state && state <= RF_OUT_08 )
FreeRTOS_debug_printf(("Switched to %s\n", (char*)pucRxBuffer));
else if ( enable == 1 )
FreeRTOS_debug_printf(("RF switch ON\n"));
else if ( enable == 0 )
FreeRTOS_debug_printf(("RF switch OFF\n"));
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 <= state1 && state1 <= RF_OUT_08 )
FreeRTOS_debug_printf(("RF switch1 switched to %s\n", (char*)pucRxBuffer));
else if ( enable1 == 1 )
FreeRTOS_debug_printf(("RF switch1 ON\n"));
else if ( enable1 == 0 )
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
FreeRTOS_debug_printf(("Wrong command\n"));
lSent = 0;
lTotalSent = 0;

View File

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

File diff suppressed because one or more lines are too long

View File

@ -140,7 +140,7 @@
<SetRegEntry>
<Number>0</Number>
<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>
<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>
</SetRegEntry>
</TargetDriverDllRegistry>
<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>
<Breakpoint/>
<WatchWindow1>
<Ww>
<count>0</count>
@ -308,7 +291,7 @@
</Mm>
</MemoryWindow3>
<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>
<SubType>1</SubType>
</ScvdPack>
@ -320,7 +303,7 @@
<periodic>1</periodic>
<aLwin>1</aLwin>
<aCover>0</aCover>
<aSer1>0</aSer1>
<aSer1>1</aSer1>
<aSer2>0</aSer2>
<aPa>0</aPa>
<viewmode>1</viewmode>
@ -354,6 +337,12 @@
<pszMrulep></pszMrulep>
<pSingCmdsp></pSingCmdsp>
<pMultCmdsp></pMultCmdsp>
<SystemViewers>
<Entry>
<Name>System Viewer\ENET_DMA</Name>
<WinId>35905</WinId>
</Entry>
</SystemViewers>
</TargetOption>
</Target>
@ -451,7 +440,7 @@
<Group>
<GroupName>FreeRTOS</GroupName>
<tvExp>1</tvExp>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
@ -771,7 +760,7 @@
<Group>
<GroupName>::Device</GroupName>
<tvExp>0</tvExp>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>1</RteFlg>

View File

@ -338,7 +338,7 @@
<v6WtE>0</v6WtE>
<v6Rtti>0</v6Rtti>
<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>
<Undefine></Undefine>
<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 LED5_TICK_PORT GPIOE
#define RF_SWITCH_PORT GPIOE
#define RF_SWITCH_PIN_A GPIO_PIN_10
#define RF_SWITCH_PIN_B GPIO_PIN_11
#define RF_SWITCH_PIN_C GPIO_PIN_12
#define RF_SWITCH_PIN_EN GPIO_PIN_13
#define RF_SWITCH1_PORT GPIOE
#define RF_SWITCH1_PIN_A GPIO_PIN_7
#define RF_SWITCH1_PIN_B GPIO_PIN_8
#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 LED5_TICK GPIO_PIN_1
@ -146,7 +153,7 @@ static const uint8_t ucDNSServerAddress[ 4 ] =
/* Use by the pseudo random number generator. */
static UBaseType_t ulNextRand;
struct rf_switch_config rfSwitchConfig;
struct rf_switch_config rfSwitch1Config, rfSwitch2Config;
/*
* Just seeds the simple pseudo random number generator.
*/
@ -279,8 +286,9 @@ static void vInitMCU(void)
#ifndef STM32_PORT
enet_descriptors_chain_init(ENET_DMA_TX);
enet_descriptors_chain_init(ENET_DMA_RX);
enet_enable();
#endif
enet_enable();
//nvic_irq_enable(ENET_IRQn, ipconfigMAC_INTERRUPT_PRIORITY, 0xFF);
__disable_irq();
NVIC_ClearPendingIRQ(ENET_IRQn);
@ -367,7 +375,8 @@ static void prvMiscInitialisation( void )
int main(void)
{
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();
xTaskCreate( vTaskToggleLed, "ToggleLed", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 1, &vTaskToggleLed_Handle);
xTaskCreate( vTaskHelloWorld, "HelloWorld", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 1, &vTaskHelloWorld_Handle);