Added control of Elasticity buffer size in PHY
This commit is contained in:
parent
0fe1ed1c56
commit
a39a483b53
|
|
@ -228,6 +228,7 @@ static const TickType_t xSendTimeOut = pdMS_TO_TICKS( 5000 );
|
|||
TickType_t xTimeOnShutdown;
|
||||
uint8_t *pucRxBuffer;
|
||||
|
||||
|
||||
xConnectedSocket = ( Socket_t ) pvParameters;
|
||||
|
||||
/* Attempt to create the buffer used to receive the string to be echoed
|
||||
|
|
@ -253,24 +254,41 @@ uint8_t *pucRxBuffer;
|
|||
if( lBytes >= 0 )
|
||||
{
|
||||
RF_OUT_ENUM state = -1;
|
||||
if (!strcmp("RF01", (char*)pucRxBuffer))
|
||||
state = xSwitchRFOut(&rfSwitchConfig, RF_OUT_01);
|
||||
int8_t enable = -1;
|
||||
|
||||
if (!strcmp("RF_ON", (char*)pucRxBuffer))
|
||||
{
|
||||
vRFSwitchEnable(&rfSwitchConfig);
|
||||
enable = true;
|
||||
}
|
||||
else if (!strcmp("RF_OFF", (char*)pucRxBuffer))
|
||||
{
|
||||
vRFSwitchDisable(&rfSwitchConfig);
|
||||
enable = false;
|
||||
}
|
||||
else if (!strcmp("RF01", (char*)pucRxBuffer))
|
||||
state = xRFSwitchSet(&rfSwitchConfig, RF_OUT_01);
|
||||
else if (!strcmp("RF02", (char*)pucRxBuffer))
|
||||
state = xSwitchRFOut(&rfSwitchConfig, RF_OUT_02);
|
||||
state = xRFSwitchSet(&rfSwitchConfig, RF_OUT_02);
|
||||
else if (!strcmp("RF03", (char*)pucRxBuffer))
|
||||
state = xSwitchRFOut(&rfSwitchConfig, RF_OUT_03);
|
||||
state = xRFSwitchSet(&rfSwitchConfig, RF_OUT_03);
|
||||
else if (!strcmp("RF04", (char*)pucRxBuffer))
|
||||
state = xSwitchRFOut(&rfSwitchConfig, RF_OUT_04);
|
||||
state = xRFSwitchSet(&rfSwitchConfig, RF_OUT_04);
|
||||
else if (!strcmp("RF05", (char*)pucRxBuffer))
|
||||
state = xSwitchRFOut(&rfSwitchConfig, RF_OUT_05);
|
||||
state = xRFSwitchSet(&rfSwitchConfig, RF_OUT_05);
|
||||
else if (!strcmp("RF06", (char*)pucRxBuffer))
|
||||
state = xSwitchRFOut(&rfSwitchConfig, RF_OUT_06);
|
||||
state = xRFSwitchSet(&rfSwitchConfig, RF_OUT_06);
|
||||
else if (!strcmp("RF07", (char*)pucRxBuffer))
|
||||
state = xSwitchRFOut(&rfSwitchConfig, RF_OUT_07);
|
||||
state = xRFSwitchSet(&rfSwitchConfig, RF_OUT_07);
|
||||
else if (!strcmp("RF08", (char*)pucRxBuffer))
|
||||
state = xSwitchRFOut(&rfSwitchConfig, RF_OUT_08);
|
||||
if (RF_OUT_01 <= state && state <= RF_OUT_08)
|
||||
state = xRFSwitchSet(&rfSwitchConfig, 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
|
||||
FreeRTOS_debug_printf(("Wrong command\n"));
|
||||
lSent = 0;
|
||||
|
|
|
|||
|
|
@ -78,6 +78,7 @@
|
|||
#include "Driver_ETH_MAC.h"
|
||||
#include "Driver_ETH_PHY.h"
|
||||
#include "gd32f10x_enet.h"
|
||||
#include "PHY_DP83848C.h"
|
||||
|
||||
//#ifdef RTE_Drivers_PHY_DP83848C /* Driver PHY DP83848C */
|
||||
|
||||
|
|
@ -636,6 +637,9 @@ BaseType_t xNetworkInterfaceInitialise( void )
|
|||
ARM_ETH_MAC_ADDRESS_BROADCAST);
|
||||
mac->Control(ARM_ETH_MAC_CONTROL_TX, 1);
|
||||
mac->Control(ARM_ETH_MAC_CONTROL_RX, 1);
|
||||
|
||||
#warning "mac->Control(0x17, 0x23); check if this configuration fixes DP83848 Elasticity buffer problem. Refer to https://habr.com/ru/post/682172/"
|
||||
mac->Control(REG_RBR, RBR_RMII_MODE | RBR_ELAST_BUF);
|
||||
return pdPASS;
|
||||
}
|
||||
else{
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -157,7 +157,7 @@
|
|||
<Bp>
|
||||
<Number>0</Number>
|
||||
<Type>0</Type>
|
||||
<LineNumber>255</LineNumber>
|
||||
<LineNumber>603</LineNumber>
|
||||
<EnabledFlag>1</EnabledFlag>
|
||||
<Address>0</Address>
|
||||
<ByteObject>0</ByteObject>
|
||||
|
|
@ -166,7 +166,39 @@
|
|||
<SizeOfObject>0</SizeOfObject>
|
||||
<BreakByAccess>0</BreakByAccess>
|
||||
<BreakIfRCount>0</BreakIfRCount>
|
||||
<Filename>.\DemoTasks\SimpleTCPEchoServer.c</Filename>
|
||||
<Filename>.\FreeRTOS\source\portable\NetworkInterface\board_family\NetworkInterface.c</Filename>
|
||||
<ExecCommand></ExecCommand>
|
||||
<Expression></Expression>
|
||||
</Bp>
|
||||
<Bp>
|
||||
<Number>1</Number>
|
||||
<Type>0</Type>
|
||||
<LineNumber>642</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\portable\NetworkInterface\board_family\NetworkInterface.c</Filename>
|
||||
<ExecCommand></ExecCommand>
|
||||
<Expression></Expression>
|
||||
</Bp>
|
||||
<Bp>
|
||||
<Number>2</Number>
|
||||
<Type>0</Type>
|
||||
<LineNumber>602</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\portable\NetworkInterface\board_family\NetworkInterface.c</Filename>
|
||||
<ExecCommand></ExecCommand>
|
||||
<Expression></Expression>
|
||||
</Bp>
|
||||
|
|
@ -252,12 +284,27 @@
|
|||
<WinNumber>1</WinNumber>
|
||||
<ItemText>pvBuffer</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>16</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>pxCurrentTCB</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>17</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>receiveBufferDescriptor</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>18</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>xNetworkEventQueue</ItemText>
|
||||
</Ww>
|
||||
</WatchWindow1>
|
||||
<MemoryWindow1>
|
||||
<Mm>
|
||||
<WinNumber>1</WinNumber>
|
||||
<SubType>0</SubType>
|
||||
<ItemText>0x200083E0</ItemText>
|
||||
<ItemText>frame</ItemText>
|
||||
<AccSizeX>0</AccSizeX>
|
||||
</Mm>
|
||||
</MemoryWindow1>
|
||||
|
|
@ -324,6 +371,12 @@
|
|||
<pszMrulep></pszMrulep>
|
||||
<pSingCmdsp></pSingCmdsp>
|
||||
<pMultCmdsp></pMultCmdsp>
|
||||
<SystemViewers>
|
||||
<Entry>
|
||||
<Name>System Viewer\ENET_DMA</Name>
|
||||
<WinId>35905</WinId>
|
||||
</Entry>
|
||||
</SystemViewers>
|
||||
</TargetOption>
|
||||
</Target>
|
||||
|
||||
|
|
@ -385,7 +438,7 @@
|
|||
<GroupNumber>1</GroupNumber>
|
||||
<FileNumber>5</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.\PHY\PHY_DP83848C.c</PathWithFileName>
|
||||
|
|
@ -721,7 +774,7 @@
|
|||
|
||||
<Group>
|
||||
<GroupName>::Compiler</GroupName>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>1</RteFlg>
|
||||
|
|
@ -737,7 +790,7 @@
|
|||
|
||||
<Group>
|
||||
<GroupName>::RTOS</GroupName>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>1</RteFlg>
|
||||
|
|
|
|||
|
|
@ -341,7 +341,7 @@
|
|||
<MiscControls>-D DEBUG -Wno-pragma-pack -Wno-macro-redefined</MiscControls>
|
||||
<Define></Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath>.\FreeRTOS\source\portable\NetworkInterface\include;.\FreeRTOS\source\include;.\FreeRTOS\source\portable\Compiler\Keil;.\DemoTasks\include;..\GigaDevice_test;.\include</IncludePath>
|
||||
<IncludePath>.\FreeRTOS\source\portable\NetworkInterface\include;.\FreeRTOS\source\include;.\FreeRTOS\source\portable\Compiler\Keil;.\DemoTasks\include;..\GigaDevice_test;.\include;.\PHY</IncludePath>
|
||||
</VariousControls>
|
||||
</Cads>
|
||||
<Aads>
|
||||
|
|
|
|||
|
|
@ -31,12 +31,23 @@ struct rf_switch_config
|
|||
uint32_t pinB;
|
||||
uint32_t portC;
|
||||
uint32_t pinC;
|
||||
uint32_t portEn;
|
||||
uint32_t pinEn;
|
||||
};
|
||||
|
||||
void vRFSwitchInit(struct rf_switch_config *config, uint32_t portA, uint32_t pinA, uint32_t portB, uint32_t pinB, uint32_t portC, uint32_t pinC);
|
||||
void vRFSwitchEnable(struct rf_switch_config *config);
|
||||
void vRFSwitchDisable(struct rf_switch_config *config);
|
||||
RF_OUT_ENUM xSwitchRFOut(struct rf_switch_config *config, RF_OUT_ENUM state);
|
||||
RF_OUT_ENUM xGetRFSwitchState(struct rf_switch_config *config);
|
||||
void vRFSwitchInit(struct rf_switch_config *pConfig,
|
||||
uint32_t portA,
|
||||
uint32_t pinA,
|
||||
uint32_t portB,
|
||||
uint32_t pinB,
|
||||
uint32_t portC,
|
||||
uint32_t pinC,
|
||||
uint32_t portEn,
|
||||
uint32_t pinEn);
|
||||
|
||||
void vRFSwitchEnable(struct rf_switch_config *pConfig);
|
||||
void vRFSwitchDisable(struct rf_switch_config *pConfig);
|
||||
RF_OUT_ENUM xRFSwitchSet(struct rf_switch_config *pConfig, RF_OUT_ENUM state);
|
||||
RF_OUT_ENUM xRFSwitchGetState(struct rf_switch_config *pConfig);
|
||||
|
||||
#endif /*RF_SWITCH_DRIVER_H_*/
|
||||
|
|
|
|||
4
main.c
4
main.c
|
|
@ -26,6 +26,7 @@
|
|||
#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 LED2_USER GPIO_PIN_0
|
||||
#define LED5_TICK GPIO_PIN_1
|
||||
|
|
@ -242,6 +243,7 @@ static void vInitMCU(void)
|
|||
gpio_init(LED5_TICK_PORT, GPIO_MODE_OUT_PP, GPIO_OSPEED_2MHZ, LED5_TICK);
|
||||
gpio_bit_set(LED5_TICK_PORT, LED5_TICK);
|
||||
|
||||
|
||||
/* Enable PLL2 to generate 50MHz clocks */
|
||||
if (ERROR == xInitPLL2()) FreeRTOS_debug_printf(("PLL2 initialization failed\n"));
|
||||
|
||||
|
|
@ -355,7 +357,7 @@ 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);
|
||||
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);
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -5,62 +5,81 @@
|
|||
/**! \func void vRFSwitchInit(struct rf_switch_config *config)
|
||||
* \brief Initialize RF Switch
|
||||
*/
|
||||
void vRFSwitchInit(struct rf_switch_config *config, uint32_t portA, uint32_t pinA, uint32_t portB, uint32_t pinB, uint32_t portC, uint32_t pinC)
|
||||
void vRFSwitchInit(struct rf_switch_config *pConfig,
|
||||
uint32_t portA,
|
||||
uint32_t pinA,
|
||||
uint32_t portB,
|
||||
uint32_t pinB,
|
||||
uint32_t portC,
|
||||
uint32_t pinC,
|
||||
uint32_t portEn,
|
||||
uint32_t pinEn)
|
||||
{
|
||||
config->enable = 0;
|
||||
config->rfOutState = xSwitchRFOut(config, RF_OUT_01);
|
||||
config->portA = portA;
|
||||
config->portB = portB;
|
||||
config->portC = portC;
|
||||
config->pinA = pinA;
|
||||
config->pinB = pinB;
|
||||
config->pinC = pinC;
|
||||
/* Configure GPIO Output function for RF Switch interface */
|
||||
gpio_init(portA, GPIO_MODE_OUT_PP, GPIO_OSPEED_2MHZ, pinA);
|
||||
gpio_init(portB, GPIO_MODE_OUT_PP, GPIO_OSPEED_2MHZ, pinB);
|
||||
gpio_init(portC, GPIO_MODE_OUT_PP, GPIO_OSPEED_2MHZ, pinC);
|
||||
gpio_init(portEn, GPIO_MODE_OUT_PP, GPIO_OSPEED_2MHZ, pinEn);
|
||||
|
||||
vRFSwitchDisable(pConfig);
|
||||
pConfig->rfOutState = xRFSwitchSet(pConfig, RF_OUT_01);
|
||||
pConfig->portA = portA;
|
||||
pConfig->portB = portB;
|
||||
pConfig->portC = portC;
|
||||
pConfig->portEn = portEn;
|
||||
pConfig->pinA = pinA;
|
||||
pConfig->pinB = pinB;
|
||||
pConfig->pinC = pinC;
|
||||
pConfig->pinEn = pinEn;
|
||||
}
|
||||
|
||||
/**! \func void vRFSwitchEnable(struct rf_switch_config *config)
|
||||
* \brief Enable RF Switch
|
||||
*/
|
||||
void vRFSwitchEnable(struct rf_switch_config *config)
|
||||
void vRFSwitchEnable(struct rf_switch_config *pConfig)
|
||||
{
|
||||
config->enable = 1;
|
||||
pConfig->enable = 1;
|
||||
gpio_bit_set(pConfig->portEn, pConfig->pinEn);
|
||||
}
|
||||
|
||||
/**! \func void vRFSwitchDisable(struct rf_switch_config *config)
|
||||
* \brief Disable RF Switch
|
||||
*/
|
||||
void vRFSwitchDisable(struct rf_switch_config *config)
|
||||
void vRFSwitchDisable(struct rf_switch_config *pConfig)
|
||||
{
|
||||
config->enable = 0;
|
||||
pConfig->enable = 0;
|
||||
gpio_bit_reset(pConfig->portEn, pConfig->pinEn);
|
||||
}
|
||||
|
||||
/**! \func void vSwitchRFOut(struct rf_switch_config *config, RF_OUT_ENUM state)
|
||||
/**! \func void xRFSwitchSet(struct rf_switch_config *config, RF_OUT_ENUM state)
|
||||
* \brief Switch between RF out state
|
||||
*/
|
||||
RF_OUT_ENUM xSwitchRFOut(struct rf_switch_config *config, RF_OUT_ENUM state)
|
||||
RF_OUT_ENUM xRFSwitchSet(struct rf_switch_config *pConfig, RF_OUT_ENUM state)
|
||||
{
|
||||
config->rfOutState = state;
|
||||
pConfig->rfOutState = state;
|
||||
|
||||
if (state & 0x01)
|
||||
gpio_bit_set(config->portA, config->pinA);
|
||||
gpio_bit_set(pConfig->portA, pConfig->pinA);
|
||||
else
|
||||
gpio_bit_reset(config->portA, config->pinA);
|
||||
gpio_bit_reset(pConfig->portA, pConfig->pinA);
|
||||
|
||||
if (state & 0x02)
|
||||
gpio_bit_set(config->portB, config->pinB);
|
||||
gpio_bit_set(pConfig->portB, pConfig->pinB);
|
||||
else
|
||||
gpio_bit_reset(config->portB, config->pinB);
|
||||
gpio_bit_reset(pConfig->portB, pConfig->pinB);
|
||||
|
||||
if (state & 0x04)
|
||||
gpio_bit_set(config->portC, config->pinC);
|
||||
gpio_bit_set(pConfig->portC, pConfig->pinC);
|
||||
else
|
||||
gpio_bit_reset(config->portC, config->pinC);
|
||||
gpio_bit_reset(pConfig->portC, pConfig->pinC);
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
/**! \func RF_OUT_ENUM xGetRFSwitchState(struct rf_switch_config *config)
|
||||
/**! \func RF_OUT_ENUM xRFSwitchGetState(struct rf_switch_config *config)
|
||||
* \brief Get RF Switch State
|
||||
*/
|
||||
RF_OUT_ENUM xGetRFSwitchState(struct rf_switch_config *config)
|
||||
RF_OUT_ENUM xRFSwitchGetState(struct rf_switch_config *pConfig)
|
||||
{
|
||||
return config->rfOutState;
|
||||
return pConfig->rfOutState;
|
||||
}
|
||||
Loading…
Reference in New Issue