Added rf_switch_driver

This commit is contained in:
Alexey Bazlaev 2023-03-01 18:17:49 +07:00
parent 411afb72ab
commit 160ed6fc8c
9 changed files with 776 additions and 147 deletions

View File

@ -190,7 +190,7 @@ Socket_t xListeningSocket;
/* Error check. */ /* Error check. */
configASSERT( lBytes == ( BaseType_t ) strlen( ( const char * ) cReceivedString ) ); configASSERT( lBytes == ( BaseType_t ) strlen( ( const char * ) cReceivedString ) );
FreeRTOS_debug_printf( ("Received string: %s, on port %d\r\n", cReceivedString, xBindAddress.sin_port ) ); FreeRTOS_debug_printf( ("Received on port %d a string: %s\r\n", FreeRTOS_htons( xBindAddress.sin_port ), cReceivedString) );
} }
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
@ -342,9 +342,9 @@ Socket_t xListeningSocket;
{ {
/* It is expected to receive one more byte than the string length as /* It is expected to receive one more byte than the string length as
the NULL terminator is also transmitted. */ the NULL terminator is also transmitted. */
configASSERT( lBytes == ( ( BaseType_t ) strlen( ( const char * ) pucUDPPayloadBuffer ) + 1 ) ); configASSERT( lBytes == ( ( BaseType_t ) strlen( ( const char * ) pucUDPPayloadBuffer ) ) );
} }
FreeRTOS_debug_printf( ("Received string: %s, with ZERO_COPY on port %d\r\n", pucUDPPayloadBuffer, xBindAddress.sin_port ) ); FreeRTOS_debug_printf( ("Received on port %d with ZERO_COPY a string: %s\r\n", FreeRTOS_htons( xBindAddress.sin_port ), pucUDPPayloadBuffer) );
if( lBytes >= 0 ) if( lBytes >= 0 )
{ {
/* The buffer *must* be freed once it is no longer needed. */ /* The buffer *must* be freed once it is no longer needed. */

View File

@ -0,0 +1,295 @@
/*!
\file gd32f10x_bkp.c
\brief BKP driver
\version 2014-12-26, V1.0.0, firmware for GD32F10x
\version 2017-06-20, V2.0.0, firmware for GD32F10x
\version 2018-07-31, V2.1.0, firmware for GD32F10x
\version 2020-09-30, V2.2.0, firmware for GD32F10x
*/
/*
Copyright (c) 2020, GigaDevice Semiconductor Inc.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
#include "gd32f10x_bkp.h"
/* BKP register bits offset */
#define BKP_TAMPER_BITS_OFFSET ((uint32_t)8U)
/*!
\brief reset BKP registers
\param[in] none
\param[out] none
\retval none
*/
void bkp_deinit(void)
{
/* reset BKP domain register*/
rcu_bkp_reset_enable();
rcu_bkp_reset_disable();
}
/*!
\brief write BKP data register
\param[in] register_number: refer to bkp_data_register_enum
only one parameter can be selected which is shown as below:
\arg BKP_DATA_x(x = 0..41): bkp data register number x
\param[in] data: the data to be write in BKP data register
\param[out] none
\retval none
*/
void bkp_data_write(bkp_data_register_enum register_number, uint16_t data)
{
if((register_number >= BKP_DATA_10) && (register_number <= BKP_DATA_41)){
BKP_DATA10_41(register_number - 1U) = data;
}else if((register_number >= BKP_DATA_0) && (register_number <= BKP_DATA_9)){
BKP_DATA0_9(register_number - 1U) = data;
}else{
/* illegal parameters */
}
}
/*!
\brief read BKP data register
\param[in] register_number: refer to bkp_data_register_enum
only one parameter can be selected which is shown as below:
\arg BKP_DATA_x(x = 0..41): bkp data register number x
\param[out] none
\retval data of BKP data register
*/
uint16_t bkp_data_read(bkp_data_register_enum register_number)
{
uint16_t data = 0U;
/* get the data from the BKP data register */
if((register_number >= BKP_DATA_10) && (register_number <= BKP_DATA_41)){
data = BKP_DATA10_41(register_number - 1U);
}else if((register_number >= BKP_DATA_0) && (register_number <= BKP_DATA_9)){
data = BKP_DATA0_9(register_number - 1U);
}else{
/* illegal parameters */
}
return data;
}
/*!
\brief enable RTC clock calibration output
\param[in] none
\param[out] none
\retval none
*/
void bkp_rtc_calibration_output_enable(void)
{
BKP_OCTL |= (uint16_t)BKP_OCTL_COEN;
}
/*!
\brief disable RTC clock calibration output
\param[in] none
\param[out] none
\retval none
*/
void bkp_rtc_calibration_output_disable(void)
{
BKP_OCTL &= (uint16_t)~BKP_OCTL_COEN;
}
/*!
\brief enable RTC alarm or second signal output
\param[in] none
\param[out] none
\retval none
*/
void bkp_rtc_signal_output_enable(void)
{
BKP_OCTL |= (uint16_t)BKP_OCTL_ASOEN;
}
/*!
\brief disable RTC alarm or second signal output
\param[in] none
\param[out] none
\retval none
*/
void bkp_rtc_signal_output_disable(void)
{
BKP_OCTL &= (uint16_t)~BKP_OCTL_ASOEN;
}
/*!
\brief select RTC output
\param[in] outputsel: RTC output selection
only one parameter can be selected which is shown as below:
\arg RTC_OUTPUT_ALARM_PULSE: RTC alarm pulse is selected as the RTC output
\arg RTC_OUTPUT_SECOND_PULSE: RTC second pulse is selected as the RTC output
\param[out] none
\retval none
*/
void bkp_rtc_output_select(uint16_t outputsel)
{
uint16_t ctl = 0U;
/* configure BKP_OCTL_ROSEL with outputsel */
ctl = BKP_OCTL;
ctl &= (uint16_t)~BKP_OCTL_ROSEL;
ctl |= outputsel;
BKP_OCTL = ctl;
}
/*!
\brief set RTC clock calibration value
\param[in] value: RTC clock calibration value
\arg 0x00 - 0x7F
\param[out] none
\retval none
*/
void bkp_rtc_calibration_value_set(uint8_t value)
{
uint16_t ctl;
/* configure BKP_OCTL_RCCV with value */
ctl = BKP_OCTL;
ctl &= (uint16_t)~BKP_OCTL_RCCV;
ctl |= (uint16_t)OCTL_RCCV(value);
BKP_OCTL = ctl;
}
/*!
\brief enable tamper detection
\param[in] none
\param[out] none
\retval none
*/
void bkp_tamper_detection_enable(void)
{
BKP_TPCTL |= (uint16_t)BKP_TPCTL_TPEN;
}
/*!
\brief disable tamper detection
\param[in] none
\param[out] none
\retval none
*/
void bkp_tamper_detection_disable(void)
{
BKP_TPCTL &= (uint16_t)~BKP_TPCTL_TPEN;
}
/*!
\brief set tamper pin active level
\param[in] level: tamper active level
only one parameter can be selected which is shown as below:
\arg TAMPER_PIN_ACTIVE_HIGH: the tamper pin is active high
\arg TAMPER_PIN_ACTIVE_LOW: the tamper pin is active low
\param[out] none
\retval none
*/
void bkp_tamper_active_level_set(uint16_t level)
{
uint16_t ctl = 0U;
/* configure BKP_TPCTL_TPAL with level */
ctl = BKP_TPCTL;
ctl &= (uint16_t)~BKP_TPCTL_TPAL;
ctl |= level;
BKP_TPCTL = ctl;
}
/*!
\brief enable tamper interrupt
\param[in] none
\param[out] none
\retval none
*/
void bkp_interrupt_enable(void)
{
BKP_TPCS |= (uint16_t)BKP_TPCS_TPIE;
}
/*!
\brief disable tamper interrupt
\param[in] none
\param[out] none
\retval none
*/
void bkp_interrupt_disable(void)
{
BKP_TPCS &= (uint16_t)~BKP_TPCS_TPIE;
}
/*!
\brief get tamper flag state
\param[in] none
\param[out] none
\retval FlagStatus: SET or RESET
*/
FlagStatus bkp_flag_get(void)
{
if(RESET != (BKP_TPCS & BKP_FLAG_TAMPER)){
return SET;
}else{
return RESET;
}
}
/*!
\brief clear tamper flag state
\param[in] none
\param[out] none
\retval none
*/
void bkp_flag_clear(void)
{
BKP_TPCS |= (uint16_t)(BKP_FLAG_TAMPER >> BKP_TAMPER_BITS_OFFSET);
}
/*!
\brief get tamper interrupt flag state
\param[in] none
\param[out] none
\retval FlagStatus: SET or RESET
*/
FlagStatus bkp_interrupt_flag_get(void)
{
if(RESET != (BKP_TPCS & BKP_INT_FLAG_TAMPER)){
return SET;
}else{
return RESET;
}
}
/*!
\brief clear tamper interrupt flag state
\param[in] none
\param[out] none
\retval none
*/
void bkp_interrupt_flag_clear(void)
{
BKP_TPCS |= (uint16_t)(BKP_INT_FLAG_TAMPER >> BKP_TAMPER_BITS_OFFSET);
}

View File

@ -0,0 +1,276 @@
/*!
\file gd32f10x_rtc.c
\brief RTC driver
\version 2014-12-26, V1.0.0, firmware for GD32F10x
\version 2017-06-20, V2.0.0, firmware for GD32F10x
\version 2018-07-31, V2.1.0, firmware for GD32F10x
\version 2020-09-30, V2.2.0, firmware for GD32F10x
*/
/*
Copyright (c) 2020, GigaDevice Semiconductor Inc.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
#include "gd32f10x_rtc.h"
/* RTC register high / low bits mask */
#define RTC_HIGH_BITS_MASK ((uint32_t)0x000F0000U) /* RTC high bits mask */
#define RTC_LOW_BITS_MASK ((uint32_t)0x0000FFFFU) /* RTC low bits mask */
/* RTC register high bits offset */
#define RTC_HIGH_BITS_OFFSET ((uint32_t)16U)
/*!
\brief enter RTC configuration mode
\param[in] none
\param[out] none
\retval none
*/
void rtc_configuration_mode_enter(void)
{
RTC_CTL |= RTC_CTL_CMF;
}
/*!
\brief exit RTC configuration mode
\param[in] none
\param[out] none
\retval none
*/
void rtc_configuration_mode_exit(void)
{
RTC_CTL &= ~RTC_CTL_CMF;
}
/*!
\brief set RTC counter value
\param[in] cnt: RTC counter value
\param[out] none
\retval none
*/
void rtc_counter_set(uint32_t cnt)
{
rtc_configuration_mode_enter();
/* set the RTC counter high bits */
RTC_CNTH = (cnt >> RTC_HIGH_BITS_OFFSET);
/* set the RTC counter low bits */
RTC_CNTL = (cnt & RTC_LOW_BITS_MASK);
rtc_configuration_mode_exit();
}
/*!
\brief set RTC prescaler value
\param[in] psc: RTC prescaler value
\param[out] none
\retval none
*/
void rtc_prescaler_set(uint32_t psc)
{
rtc_configuration_mode_enter();
/* set the RTC prescaler high bits */
RTC_PSCH = ((psc & RTC_HIGH_BITS_MASK) >> RTC_HIGH_BITS_OFFSET);
/* set the RTC prescaler low bits */
RTC_PSCL = (psc & RTC_LOW_BITS_MASK);
rtc_configuration_mode_exit();
}
/*!
\brief wait RTC last write operation finished flag set
\param[in] none
\param[out] none
\retval none
*/
void rtc_lwoff_wait(void)
{
/* loop until LWOFF flag is set */
while(RESET == (RTC_CTL & RTC_CTL_LWOFF)){
}
}
/*!
\brief wait RTC registers synchronized flag set
\param[in] none
\param[out] none
\retval none
*/
void rtc_register_sync_wait(void)
{
/* clear RSYNF flag */
RTC_CTL &= ~RTC_CTL_RSYNF;
/* loop until RSYNF flag is set */
while(RESET == (RTC_CTL & RTC_CTL_RSYNF)){
}
}
/*!
\brief set RTC alarm value
\param[in] alarm: RTC alarm value
\param[out] none
\retval none
*/
void rtc_alarm_config(uint32_t alarm)
{
rtc_configuration_mode_enter();
/* set the alarm high bits */
RTC_ALRMH = (alarm >> RTC_HIGH_BITS_OFFSET);
/* set the alarm low bits */
RTC_ALRML = (alarm & RTC_LOW_BITS_MASK);
rtc_configuration_mode_exit();
}
/*!
\brief get RTC counter value
\param[in] none
\param[out] none
\retval RTC counter value
*/
uint32_t rtc_counter_get(void)
{
uint32_t temp = 0x0U;
temp = RTC_CNTL;
temp |= (RTC_CNTH << RTC_HIGH_BITS_OFFSET);
return temp;
}
/*!
\brief get RTC divider value
\param[in] none
\param[out] none
\retval RTC divider value
*/
uint32_t rtc_divider_get(void)
{
uint32_t temp = 0x00U;
temp = ((RTC_DIVH & RTC_DIVH_DIV) << RTC_HIGH_BITS_OFFSET);
temp |= RTC_DIVL;
return temp;
}
/*!
\brief get RTC flag status
\param[in] flag: specify which flag status to get
only one parameter can be selected which is shown as below:
\arg RTC_FLAG_SECOND: second interrupt flag
\arg RTC_FLAG_ALARM: alarm interrupt flag
\arg RTC_FLAG_OVERFLOW: overflow interrupt flag
\arg RTC_FLAG_RSYN: registers synchronized flag
\arg RTC_FLAG_LWOF: last write operation finished flag
\param[out] none
\retval SET or RESET
*/
FlagStatus rtc_flag_get(uint32_t flag)
{
if(RESET != (RTC_CTL & flag)){
return SET;
}else{
return RESET;
}
}
/*!
\brief clear RTC flag status
\param[in] flag: specify which flag status to clear
one or more parameters can be selected which are shown as below:
\arg RTC_FLAG_SECOND: second interrupt flag
\arg RTC_FLAG_ALARM: alarm interrupt flag
\arg RTC_FLAG_OVERFLOW: overflow interrupt flag
\arg RTC_FLAG_RSYN: registers synchronized flag
\param[out] none
\retval none
*/
void rtc_flag_clear(uint32_t flag)
{
/* clear RTC flag */
RTC_CTL &= ~flag;
}
/*!
\brief get RTC interrupt flag status
\param[in] flag: specify which flag status to get
only one parameter can be selected which is shown as below:
\arg RTC_INT_FLAG_SECOND: second interrupt flag
\arg RTC_INT_FLAG_ALARM: alarm interrupt flag
\arg RTC_INT_FLAG_OVERFLOW: overflow interrupt flag
\param[out] none
\retval SET or RESET
*/
FlagStatus rtc_interrupt_flag_get(uint32_t flag)
{
if(RESET != (RTC_CTL & flag)){
return SET;
}else{
return RESET;
}
}
/*!
\brief clear RTC interrupt flag status
\param[in] flag: specify which flag status to clear
one or more parameters can be selected which are shown as below:
\arg RTC_INT_FLAG_SECOND: second interrupt flag
\arg RTC_INT_FLAG_ALARM: alarm interrupt flag
\arg RTC_INT_FLAG_OVERFLOW: overflow interrupt flag
\param[out] none
\retval none
*/
void rtc_interrupt_flag_clear(uint32_t flag)
{
/* clear RTC interrupt flag */
RTC_CTL &= ~flag;
}
/*!
\brief enable RTC interrupt
\param[in] interrupt: specify which interrupt to enbale
one or more parameters can be selected which are shown as below:
\arg RTC_INT_SECOND: second interrupt
\arg RTC_INT_ALARM: alarm interrupt
\arg RTC_INT_OVERFLOW: overflow interrupt
\param[out] none
\retval none
*/
void rtc_interrupt_enable(uint32_t interrupt)
{
RTC_INTEN |= interrupt;
}
/*!
\brief disable RTC interrupt
\param[in] interrupt: specify which interrupt to disbale
one or more parameters can be selected which are shown as below:
\arg RTC_INT_SECOND: second interrupt
\arg RTC_INT_ALARM: alarm interrupt
\arg RTC_INT_OVERFLOW: overflow interrupt
\param[out] none
\retval none
*/
void rtc_interrupt_disable(uint32_t interrupt)
{
RTC_INTEN &= ~interrupt;
}

File diff suppressed because one or more lines are too long

View File

@ -235,7 +235,7 @@
<Mm> <Mm>
<WinNumber>1</WinNumber> <WinNumber>1</WinNumber>
<SubType>0</SubType> <SubType>0</SubType>
<ItemText>EP_DHCPData</ItemText> <ItemText>pucUDPPayloadBuffer</ItemText>
<AccSizeX>0</AccSizeX> <AccSizeX>0</AccSizeX>
</Mm> </Mm>
</MemoryWindow1> </MemoryWindow1>
@ -256,7 +256,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>
@ -371,6 +371,18 @@
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>
<bShared>0</bShared> <bShared>0</bShared>
</File> </File>
<File>
<GroupNumber>1</GroupNumber>
<FileNumber>6</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>.\rf_switch_driver.c</PathWithFileName>
<FilenameWithoutPath>rf_switch_driver.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
</Group> </Group>
<Group> <Group>
@ -381,7 +393,7 @@
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>
<File> <File>
<GroupNumber>2</GroupNumber> <GroupNumber>2</GroupNumber>
<FileNumber>6</FileNumber> <FileNumber>7</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -393,7 +405,7 @@
</File> </File>
<File> <File>
<GroupNumber>2</GroupNumber> <GroupNumber>2</GroupNumber>
<FileNumber>7</FileNumber> <FileNumber>8</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -405,7 +417,7 @@
</File> </File>
<File> <File>
<GroupNumber>2</GroupNumber> <GroupNumber>2</GroupNumber>
<FileNumber>8</FileNumber> <FileNumber>9</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -417,7 +429,7 @@
</File> </File>
<File> <File>
<GroupNumber>2</GroupNumber> <GroupNumber>2</GroupNumber>
<FileNumber>9</FileNumber> <FileNumber>10</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -429,7 +441,7 @@
</File> </File>
<File> <File>
<GroupNumber>2</GroupNumber> <GroupNumber>2</GroupNumber>
<FileNumber>10</FileNumber> <FileNumber>11</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -441,7 +453,7 @@
</File> </File>
<File> <File>
<GroupNumber>2</GroupNumber> <GroupNumber>2</GroupNumber>
<FileNumber>11</FileNumber> <FileNumber>12</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -453,7 +465,7 @@
</File> </File>
<File> <File>
<GroupNumber>2</GroupNumber> <GroupNumber>2</GroupNumber>
<FileNumber>12</FileNumber> <FileNumber>13</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -465,7 +477,7 @@
</File> </File>
<File> <File>
<GroupNumber>2</GroupNumber> <GroupNumber>2</GroupNumber>
<FileNumber>13</FileNumber> <FileNumber>14</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -477,7 +489,7 @@
</File> </File>
<File> <File>
<GroupNumber>2</GroupNumber> <GroupNumber>2</GroupNumber>
<FileNumber>14</FileNumber> <FileNumber>15</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -489,7 +501,7 @@
</File> </File>
<File> <File>
<GroupNumber>2</GroupNumber> <GroupNumber>2</GroupNumber>
<FileNumber>15</FileNumber> <FileNumber>16</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -501,7 +513,7 @@
</File> </File>
<File> <File>
<GroupNumber>2</GroupNumber> <GroupNumber>2</GroupNumber>
<FileNumber>16</FileNumber> <FileNumber>17</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -513,7 +525,7 @@
</File> </File>
<File> <File>
<GroupNumber>2</GroupNumber> <GroupNumber>2</GroupNumber>
<FileNumber>17</FileNumber> <FileNumber>18</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -525,7 +537,7 @@
</File> </File>
<File> <File>
<GroupNumber>2</GroupNumber> <GroupNumber>2</GroupNumber>
<FileNumber>18</FileNumber> <FileNumber>19</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -537,7 +549,7 @@
</File> </File>
<File> <File>
<GroupNumber>2</GroupNumber> <GroupNumber>2</GroupNumber>
<FileNumber>19</FileNumber> <FileNumber>20</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -549,7 +561,7 @@
</File> </File>
<File> <File>
<GroupNumber>2</GroupNumber> <GroupNumber>2</GroupNumber>
<FileNumber>20</FileNumber> <FileNumber>21</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -561,7 +573,7 @@
</File> </File>
<File> <File>
<GroupNumber>2</GroupNumber> <GroupNumber>2</GroupNumber>
<FileNumber>21</FileNumber> <FileNumber>22</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -573,7 +585,7 @@
</File> </File>
<File> <File>
<GroupNumber>2</GroupNumber> <GroupNumber>2</GroupNumber>
<FileNumber>22</FileNumber> <FileNumber>23</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -585,7 +597,7 @@
</File> </File>
<File> <File>
<GroupNumber>2</GroupNumber> <GroupNumber>2</GroupNumber>
<FileNumber>23</FileNumber> <FileNumber>24</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -597,7 +609,7 @@
</File> </File>
<File> <File>
<GroupNumber>2</GroupNumber> <GroupNumber>2</GroupNumber>
<FileNumber>24</FileNumber> <FileNumber>25</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -609,7 +621,7 @@
</File> </File>
<File> <File>
<GroupNumber>2</GroupNumber> <GroupNumber>2</GroupNumber>
<FileNumber>25</FileNumber> <FileNumber>26</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -621,7 +633,7 @@
</File> </File>
<File> <File>
<GroupNumber>2</GroupNumber> <GroupNumber>2</GroupNumber>
<FileNumber>26</FileNumber> <FileNumber>27</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -633,7 +645,7 @@
</File> </File>
<File> <File>
<GroupNumber>2</GroupNumber> <GroupNumber>2</GroupNumber>
<FileNumber>27</FileNumber> <FileNumber>28</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -645,7 +657,7 @@
</File> </File>
<File> <File>
<GroupNumber>2</GroupNumber> <GroupNumber>2</GroupNumber>
<FileNumber>28</FileNumber> <FileNumber>29</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -657,7 +669,7 @@
</File> </File>
<File> <File>
<GroupNumber>2</GroupNumber> <GroupNumber>2</GroupNumber>
<FileNumber>29</FileNumber> <FileNumber>30</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -695,7 +707,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

@ -341,7 +341,7 @@
<MiscControls>-D DEBUG -Wno-pragma-pack -Wno-macro-redefined</MiscControls> <MiscControls>-D DEBUG -Wno-pragma-pack -Wno-macro-redefined</MiscControls>
<Define></Define> <Define></Define>
<Undefine></Undefine> <Undefine></Undefine>
<IncludePath>.\FreeRTOS\source\portable\NetworkInterface\include;.\FreeRTOS\source\include;.\FreeRTOS\source\portable\Compiler\Keil;.\DemoTasks\include;..\GigaDevice_test</IncludePath> <IncludePath>.\FreeRTOS\source\portable\NetworkInterface\include;.\FreeRTOS\source\include;.\FreeRTOS\source\portable\Compiler\Keil;.\DemoTasks\include;..\GigaDevice_test;.\include</IncludePath>
</VariousControls> </VariousControls>
</Cads> </Cads>
<Aads> <Aads>
@ -410,6 +410,11 @@
<FileType>1</FileType> <FileType>1</FileType>
<FilePath>.\PHY\PHY_DP83848C.c</FilePath> <FilePath>.\PHY\PHY_DP83848C.c</FilePath>
</File> </File>
<File>
<FileName>rf_switch_driver.c</FileName>
<FileType>1</FileType>
<FilePath>.\rf_switch_driver.c</FilePath>
</File>
</Files> </Files>
</Group> </Group>
<Group> <Group>

View File

@ -0,0 +1,42 @@
#ifndef RF_SWITCH_DRIVER_H_
#define RF_SWITCH_DRIVER_H_
#include "stdint.h"
#include "stdio.h"
#ifndef RF_SWITCH_MODEL
#define RF_SWITCH_MODEL HMC253
#endif
typedef enum
{
#if RF_SWITCH_MODEL == HMC253
RF_OUT_01 = 0,
RF_OUT_02 = 1,
RF_OUT_03 = 2,
RF_OUT_04 = 3,
RF_OUT_05 = 4,
RF_OUT_06 = 5,
RF_OUT_07 = 6,
RF_OUT_08 = 7
#endif
} RF_OUT_ENUM;
struct rf_switch_config
{
uint8_t enable;
RF_OUT_ENUM rfOutState;
uint32_t portA;
uint32_t pinA;
uint32_t portB;
uint32_t pinB;
uint32_t portC;
uint32_t pinC;
};
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);
void vSwitchRFOut(struct rf_switch_config *config, RF_OUT_ENUM state);
RF_OUT_ENUM xGetRFSwitchState(struct rf_switch_config *config);
#endif /*RF_SWITCH_DRIVER_H_*/

9
main.c
View File

@ -16,11 +16,16 @@
#include "SimpleUDPClientAndServer.h" #include "SimpleUDPClientAndServer.h"
#include "SimpleTCPEchoServer.h" #include "SimpleTCPEchoServer.h"
#include "TCPEchoClient_SingleTasks.h" #include "TCPEchoClient_SingleTasks.h"
#include "rf_switch_driver.h"
#define BUTTON_USER GPIO_PIN_14 #define BUTTON_USER GPIO_PIN_14
#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_SWITCH_PIN_B GPIO_PIN_11
#define RF_SWITCH_PIN_C GPIO_PIN_12
#define LED2_USER GPIO_PIN_0 #define LED2_USER GPIO_PIN_0
#define LED5_TICK GPIO_PIN_1 #define LED5_TICK GPIO_PIN_1
@ -140,7 +145,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;
/* /*
* Just seeds the simple pseudo random number generator. * Just seeds the simple pseudo random number generator.
*/ */
@ -206,7 +211,6 @@ static void vInitMCU(void)
rcu_periph_clock_enable(RCU_PMU); rcu_periph_clock_enable(RCU_PMU);
rcu_periph_clock_enable(RCU_RTC); rcu_periph_clock_enable(RCU_RTC);
/* Configure RTC */ /* Configure RTC */
gpio_init(OSC32_PORT, GPIO_MODE_AF_PP, GPIO_OSPEED_2MHZ, OSC32_IN); gpio_init(OSC32_PORT, GPIO_MODE_AF_PP, GPIO_OSPEED_2MHZ, OSC32_IN);
gpio_init(OSC32_PORT, GPIO_MODE_AF_PP, GPIO_OSPEED_2MHZ, OSC32_OUT); gpio_init(OSC32_PORT, GPIO_MODE_AF_PP, GPIO_OSPEED_2MHZ, OSC32_OUT);
@ -351,6 +355,7 @@ 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);
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);

66
rf_switch_driver.c Normal file
View File

@ -0,0 +1,66 @@
#include "rf_switch_driver.h"
#include "gd32f10x_gpio.h"
/**! \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)
{
config->enable = 0;
config->rfOutState = RF_OUT_01;
config->portA = portA;
config->portB = portB;
config->portC = portC;
config->pinA = pinA;
config->pinB = pinB;
config->pinC = pinC;
vSwitchRFOut(config, config->rfOutState);
}
/**! \func void vRFSwitchEnable(struct rf_switch_config *config)
* \brief Enable RF Switch
*/
void vRFSwitchEnable(struct rf_switch_config *config)
{
config->enable = 1;
}
/**! \func void vRFSwitchDisable(struct rf_switch_config *config)
* \brief Disable RF Switch
*/
void vRFSwitchDisable(struct rf_switch_config *config)
{
config->enable = 0;
}
/**! \func void vSwitchRFOut(struct rf_switch_config *config, RF_OUT_ENUM state)
* \brief Switch between RF out state
*/
void vSwitchRFOut(struct rf_switch_config *config, RF_OUT_ENUM state)
{
config->rfOutState = state;
if (state & 0x01)
gpio_bit_set(config->portA, config->pinA);
else
gpio_bit_reset(config->portA, config->pinA);
if (state & 0x02)
gpio_bit_set(config->portB, config->pinB);
else
gpio_bit_reset(config->portB, config->pinB);
if (state & 0x04)
gpio_bit_set(config->portC, config->pinC);
else
gpio_bit_reset(config->portC, config->pinC);
}
/**! \func RF_OUT_ENUM xGetRFSwitchState(struct rf_switch_config *config)
* \brief Get RF Switch State
*/
RF_OUT_ENUM xGetRFSwitchState(struct rf_switch_config *config)
{
return config->rfOutState;
}