mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #14926 from katherrafi/hal_callback_override
Eth: STM32: Overriding HAL callbacks in stm32xxpull/15025/head
commit
43a060fe7c
|
@ -19,4 +19,5 @@ target_include_directories(mbed-emac
|
||||||
target_sources(mbed-emac
|
target_sources(mbed-emac
|
||||||
INTERFACE
|
INTERFACE
|
||||||
stm32xx_emac.cpp
|
stm32xx_emac.cpp
|
||||||
|
stm32xx_eth_irq_callback.cpp
|
||||||
)
|
)
|
||||||
|
|
|
@ -144,8 +144,8 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void _eth_config_mac(ETH_HandleTypeDef *heth);
|
void _eth_config_mac(ETH_HandleTypeDef *heth);
|
||||||
void HAL_ETH_RxCpltCallback(ETH_HandleTypeDef *heth);
|
|
||||||
void ETH_IRQHandler(void);
|
void ETH_IRQHandler(void);
|
||||||
|
MBED_WEAK void STM_HAL_ETH_Handler(ETH_HandleTypeDef *heth);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -242,20 +242,14 @@ static void MPU_Config(void)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ethernet Rx Transfer completed callback
|
* IRQ Handler
|
||||||
*
|
*
|
||||||
* @param heth: ETH handle
|
* @param heth: ETH handle
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
void HAL_ETH_RxCpltCallback(ETH_HandleTypeDef *heth)
|
MBED_WEAK void STM_HAL_ETH_Handler()
|
||||||
{
|
{
|
||||||
STM32_EMAC &emac = STM32_EMAC::get_instance();
|
|
||||||
if (emac.thread) {
|
|
||||||
osThreadFlagsSet(emac.thread, FLAG_RX);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -266,8 +260,7 @@ void HAL_ETH_RxCpltCallback(ETH_HandleTypeDef *heth)
|
||||||
*/
|
*/
|
||||||
void ETH_IRQHandler(void)
|
void ETH_IRQHandler(void)
|
||||||
{
|
{
|
||||||
STM32_EMAC &emac = STM32_EMAC::get_instance();
|
STM_HAL_ETH_Handler();
|
||||||
HAL_ETH_IRQHandler(&emac.EthHandle);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
STM32_EMAC::STM32_EMAC()
|
STM32_EMAC::STM32_EMAC()
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
/* Copyright (c) 2017-2019 ARM Limited
|
||||||
|
* Copyright (c) 2017-2019 STMicroelectronics
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef USE_USER_DEFINED_HAL_ETH_IRQ_CALLBACK
|
||||||
|
|
||||||
|
#if DEVICE_EMAC
|
||||||
|
|
||||||
|
#include "stm32xx_emac.h"
|
||||||
|
#define FLAG_RX 1
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Override Ethernet Rx Transfer completed callback
|
||||||
|
* @param heth: ETH handle
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
void HAL_ETH_RxCpltCallback(ETH_HandleTypeDef *heth)
|
||||||
|
{
|
||||||
|
STM32_EMAC &emac = STM32_EMAC::get_instance();
|
||||||
|
if (emac.thread) {
|
||||||
|
osThreadFlagsSet(emac.thread, FLAG_RX);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Override the IRQ Handler
|
||||||
|
* @param None
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
void STM_HAL_ETH_Handler()
|
||||||
|
{
|
||||||
|
STM32_EMAC &emac = STM32_EMAC::get_instance();
|
||||||
|
HAL_ETH_IRQHandler(&emac.EthHandle);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* DEVICE_EMAC */
|
||||||
|
|
||||||
|
#endif /* USE_USER_DEFINED_HAL_ETH_IRQ_CALLBACK */
|
|
@ -503,6 +503,22 @@ https://github.com/ARMmbed/mbed-os/blob/master/connectivity/drivers/emac/TARGET_
|
||||||
Option is also to define your own `HAL_ETH_MspInit` function,
|
Option is also to define your own `HAL_ETH_MspInit` function,
|
||||||
you then have to add **USE_USER_DEFINED_HAL_ETH_MSPINIT** macro.
|
you then have to add **USE_USER_DEFINED_HAL_ETH_MSPINIT** macro.
|
||||||
|
|
||||||
|
#### Custom IRQ Handler and Callback from user application
|
||||||
|
To use the custom IRQ Handler and the callbacks, you need to add
|
||||||
|
**USE_USER_DEFINED_HAL_ETH_IRQ_CALLBACK** macro
|
||||||
|
inside any of the JASON file in either targets.json or in mbed_app.json file.
|
||||||
|
|
||||||
|
For example in the targets.json,
|
||||||
|
you need to add this line in your target:
|
||||||
|
```"macros_add": ["USE_USER_DEFINED_HAL_ETH_IRQ_CALLBACK"],```
|
||||||
|
or for example in the mbed_app.json, you need to add:
|
||||||
|
``` "macros": ["USE_USER_DEFINED_HAL_ETH_IRQ_CALLBACK"]```
|
||||||
|
|
||||||
|
By doing the any of the above json files, the corresponding user defined custom apis like
|
||||||
|
HAL_ETH_RxCpltCallback() and STM_HAL_ETH_Handler() can be called from
|
||||||
|
the user application.
|
||||||
|
|
||||||
|
#### Changing default MAC address in STM32
|
||||||
To change the default MAC address in STM32,
|
To change the default MAC address in STM32,
|
||||||
If we have the function mbed_otp_mac_address() in the user application,the default ethernet address
|
If we have the function mbed_otp_mac_address() in the user application,the default ethernet address
|
||||||
can be changed.
|
can be changed.
|
||||||
|
|
Loading…
Reference in New Issue