reformat to following codeing style rules

pull/8668/head
Qinghao Shi 2018-11-12 13:54:11 +00:00
parent 25e8f89567
commit d157e59267
4 changed files with 76 additions and 88 deletions

View File

@ -51,8 +51,7 @@ fvp_EMAC::fvp_EMAC() : _thread(THREAD_PRIORITY,THREAD_STACKSIZE,NULL,"fvp_emac_t
void fvp_EMAC::ethernet_callback(lan91_event_t event, void *param)
{
fvp_EMAC *enet = static_cast<fvp_EMAC *>(param);
switch (event)
{
switch (event) {
case LAN91_RxEvent:
enet->rx_isr();
break;
@ -110,8 +109,7 @@ void fvp_EMAC::thread_function(void* pvParameters)
*/
void fvp_EMAC::packet_rx()
{
while(!LAN91_RxFIFOEmpty())
{
while (!LAN91_RxFIFOEmpty()) {
emac_mem_buf_t *temp_rxbuf = NULL;
uint32_t *rx_payload_ptr;
uint32_t rx_length = 0;
@ -134,13 +132,10 @@ void fvp_EMAC::packet_rx()
#ifdef LOCK_RX_THREAD
_TXLockMutex.unlock();
#endif
if(!state)
{
if (!state) {
_memory_manager->free(temp_rxbuf);
continue;
}
else
{
} else {
_memory_manager->set_len(temp_rxbuf, rx_length);
}
_emac_link_input_cb(temp_rxbuf);
@ -306,13 +301,15 @@ void fvp_EMAC::set_memory_manager(EMACMemoryManager &mem_mngr)
}
fvp_EMAC &fvp_EMAC::get_instance() {
fvp_EMAC &fvp_EMAC::get_instance()
{
static fvp_EMAC emac;
return emac;
}
// Weak so a module can override
MBED_WEAK EMAC &EMAC::get_default_instance() {
MBED_WEAK EMAC &EMAC::get_default_instance()
{
return fvp_EMAC::get_instance();
}

View File

@ -113,8 +113,7 @@ bool LAN91_send_frame(uint32_t *buff, uint32_t *size)
LREG(uint16_t, B2_MMUCR) = MMU_ALLOC_TX;
/* Check if Interrupt Status Register been set for MMU Allocate Ready */
if (!(LREG(uint16_t, B2_IST) & IST_ALLOC_INT))
{
if (!(LREG(uint16_t, B2_IST) & IST_ALLOC_INT)) {
/* Failed, Reset MMU */
LREG(uint16_t, B2_MMUCR) = MMU_RESET;
while (LREG(uint16_t, B2_MMUCR) & MMUCR_BUSY);
@ -214,8 +213,7 @@ bool LAN91_receive_frame(uint32_t *buff, uint32_t *size)
void ETHERNET_Handler(void)
{
LAN91_SelectBank(2);
if((LREG(uint8_t, B2_IST) & IST_RCV) !=0)
{
if ((LREG(uint8_t, B2_IST) & IST_RCV) != 0) {
LREG(uint8_t, B2_MSK) = 0;
/* Callback function. */
if (lan91c111_handle->callback) {
@ -227,12 +225,9 @@ void ETHERNET_Handler(void)
lan91_phy_status_t LAN91_GetLinkStatus(void)
{
if (read_PHY(0x2u) & 0x4u)
{
if (read_PHY(0x2u) & 0x4u) {
return STATE_LINK_UP;
}
else
{
} else {
return STATE_LINK_DOWN;
}
}

View File

@ -259,16 +259,14 @@ extern "C" {
* members. Members usually map to interrupt enable bits in one or more
* peripheral registers.
*/
typedef enum _lan91_phy_status
{
typedef enum _lan91_phy_status {
STATE_UNKNOWN = (-1), /* PHY MI Register 18 change status interrupt*/
STATE_LINK_DOWN = (0), /* EPH Type interrupt */
STATE_LINK_UP = (1) /* Receive Overrun interrupt */
} lan91_phy_status_t;
/*! @brief Defines the common interrupt event for callback use. */
typedef enum _lan91_event
{
typedef enum _lan91_event {
LAN91_RxEvent, /*!< Receive event. */
LAN91_TxEvent, /*!< Transmit event. */
LAN91_ErrEvent /*!< Error event: BABR/BABT/EBERR/LC/RL/UN/PLR . */
@ -285,8 +283,7 @@ typedef void (*lan91_callback_t)( lan91_event_t event, void *userData);
/*! @brief Defines the ENET handler structure. */
struct _lan91_handle
{
struct _lan91_handle {
lan91_callback_t callback; /*!< Callback function. */
void *userData; /*!< Callback function parameter.*/
};
@ -342,8 +339,7 @@ static uint16_t read_PHY (uint32_t PhyReg);
static inline void LAN91_SelectBank(uint8_t bank)
{
uint16_t current_bank = (LREG(uint16_t, BSR) & BSR_MASK);
if ( (bank & BSR_MASK) != current_bank )
{
if ((bank & BSR_MASK) != current_bank) {
LREG(uint16_t, BSR) = (bank & BSR_MASK);
}