initial working (stm32f4-discovery)

This commit is contained in:
2026-07-31 19:07:15 +03:00
commit ce6632f48c
2214 changed files with 1264937 additions and 0 deletions
@@ -0,0 +1,37 @@
---
name: 'Bug report'
about: 'Create a report to help us improve the quality of our software'
title: ''
labels: ''
assignees: ''
---
**Caution**
The Issues are strictly limited for the reporting of problem encountered with the software provided in this project.
For any other problem related to the STM32 product, the performance, the hardware characteristics and boards, the tools the environment in general, please post your report to the **ST Community** in the STM32 MCUs dedicated [page](https://community.st.com/s/group/0F90X000000AXsASAW/stm32-mcus).
**Describe the set-up**
* The board (either ST RPN reference or your custom board)
* IDE or at least the compiler and its version
**Describe the bug (skip if none)**
A clear and concise description of what the bug is.
**How to reproduce the bug (skip if none)**
1. Indicate the global behavior of your application project
2. List the modules that you suspect to be the cause of the problem (Drivers, BSP, MW...)
3. Describe the use case that generates the problem
4. How we can reproduce the problem
**Additional context**
If you have a first analysis, an enhancement, a fix or a patch, thank you to share your proposal.
**Screenshots**
If applicable, add screenshots to help explain your problem.
@@ -0,0 +1,3 @@
## IMPORTANT INFORMATION
Pull-requests are **not** accepted on this repository. Please use issues to report any bug or request.
@@ -0,0 +1,73 @@
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment
include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team via this [link](https://www.st.com/content/st_com/en/contact-us.html).
All complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org), version 1.4,
available [here](https://www.contributor-covenant.org/version/1/4/code-of-conduct.html).
For answers to common questions about this code of conduct, see the [FAQ section](https://www.contributor-covenant.org/faq).
@@ -0,0 +1,38 @@
## Contributing guide
This document serves as a checklist before contributing to this repository.
It includes links to read up on if topics are unclear to you.
This guide mainly focuses on steps to be followed to submit an issue or a pull-request.
### 1. Before opening an issue
To report a bug or a request please file an issue in the right repository
(example for [stm32-dp83848](https://github.com/STMicroelectronics/stm32-dp83848/issues/new/choose)).
Please check the following boxes before posting an issue:
- [ ] `Make sure you are using the latest commit (major releases are tagged, but corrections are available as new commits).`
- [ ] `Make sure your issue is a question/feedback/suggestions RELATED TO the software provided in this repository.` Otherwise, it should be submitted to the **ST Community** on the appropriate topic [page](https://community.st.com/s/topiccatalog).
- [ ] `Make sure your issue is not already reported/fixed on GitHub or discussed on a previous issue.` Please refer to this [dashboard](https://github.com/orgs/STMicroelectronics/projects/2) for the list of issues and pull-requests. Do not forget to browse into the **closed** issues.
### 2. Posting the issue
When you have checked the previous boxes, create a new report from the **Issues** tab of the repository. A template is available to help you report the issue you are facing or the enhancement you would like to propose.
### 3. Pull Requests
STMicrolectronics is happy to receive contributions from the community, based on an initial Contributor License Agreement (CLA) procedure.
* If you are an individual writing original source code and you are sure **you own the intellectual property**, then you need to sign an Individual [CLA](https://cla.st.com).
* If you work for a company that wants also to allow you to contribute with your work, your company needs to provide a Corporate [CLA](https://cla.st.com) mentioning your GitHub account name.
* If you are not sure that a CLA (Individual or Corporate) has been signed for your GitHub account you can check the [CLA](https://cla.st.com) dedicated page.
Please note that:
* The Corporate CLA will always take precedence over the Individual CLA.
* One CLA submission is sufficient, for any project proposed by STMicroelectronics.
### 4. How to proceed
* We recommend to engage first a communication thru an issue, in order to present your proposal, just to confirm that it corresponds to STMicroelectronics' domain or scope.
* Then fork the project to your GitHub account to further develop your contribution. Please use the latest commit version.
* Please, submit one pull-request per new feature or proposal. This will ease the analysis and the final merge if accepted.
+27
View File
@@ -0,0 +1,27 @@
Copyright 2017 STMicroelectronics.
All rights reserved.
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.
+34
View File
@@ -0,0 +1,34 @@
# BSP stm32-dp83848 Component
## Overview
**STM32Cube** is an STMicroelectronics original initiative to ease developers' life by reducing efforts, time and cost.
**STM32Cube** covers the overall STM32 products portfolio. It includes a comprehensive embedded software platform delivered for each STM32 series.
* The CMSIS modules (core and device) corresponding to the ARM(tm) core implemented in this STM32 product.
* The STM32 HAL-LL drivers, an abstraction layer offering a set of APIs ensuring maximized portability across the STM32 portfolio.
* The BSP drivers of each evaluation, demonstration or nucleo board provided for this STM32 series.
* A consistent set of middleware libraries such as RTOS, USB, FatFS, graphics, touch sensing library...
* A full set of software projects (basic examples, applications, and demonstrations) for each board provided for this STM32 series.
Two models of publication are proposed for the STM32Cube embedded software:
* The monolithic **MCU Package**: all STM32Cube software modules of one STM32 series are present (Drivers, Middleware, Projects, Utilities) in the repository (usual name **STM32Cubexx**, xx corresponding to the STM32 series).
* The **MCU component**: each STM32Cube software module being part of the STM32Cube MCU Package, is delivered as an individual repository, allowing the user to select and get only the required software functions.
## Description
This **stm32-dp83848** MCU component repository is one element **common to all** STM32Cube MCU embedded software packages, providing the **STM32-DP83848** BSP PHY component part.
## Release note
Details about the content of this release are available in the release note [here](https://htmlpreview.github.io/?https://github.com/STMicroelectronics/stm32-dp83848/blob/main/Release_Notes.html).
## Compatibility information
Below is the list of the BSP *component* drivers to be used with this BSP *board* driver. It is **crucial** that you use a consistent set of CMSIS - HAL - BSP versions, as mentioned in [this](https://htmlpreview.github.io/?https://github.com/STMicroelectronics/STM32CubeALL/blob/master/Release_Notes.html) release note.
## Troubleshooting
If you have any issue with the **software content** of this repository, you can file an issue [here](https://github.com/STMicroelectronics/stm32-dp83848/issues/new).
For any other question related to the product, the tools, the environment, you can submit a post to the **ST Community** on the appropriate topic [page](https://community.st.com/s/topiccatalog).
@@ -0,0 +1,31 @@
# Report potential product security vulnerabilities
ST places a high priority on security, and our Product Security Incident
Response Team (PSIRT) is committed to rapidly addressing potential security
vulnerabilities affecting our products. PSIRT's long history and vast experience
in security allows ST to perform clear analyses and provide appropriate guidance
on mitigations and solutions when applicable.
If you wish to report potential security vulnerabilities regarding our products,
**please do not report them through public GitHub issues.** Instead, we
encourage you to report them to our ST PSIRT following the process described at:
**https://www.st.com/content/st_com/en/security/report-vulnerabilities.html**
### IMPORTANT - READ CAREFULLY:
STMicroelectronics International N.V., on behalf of itself, its affiliates and
subsidiaries, (collectively “ST”) takes all potential security vulnerability
reports or other related communications (“Report(s)”) seriously. In order to
review Your Report (the terms “You” and “Yours” include your employer, and all
affiliates, subsidiaries and related persons or entities) and take actions as
deemed appropriate, ST requires that we have the rights and Your permission to
do so.
As such, by submitting Your Report to ST, You agree that You have the right to
do so, and You grant to ST the rights to use the Report for purposes related to
security vulnerability analysis, testing, correction, patching, reporting and
any other related purpose or function.
By submitting Your Report, You agree that ST’s
[Privacy Policy](https://www.st.com/content/st_com/en/common/privacy-portal.html)
applies to all related communications.
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 200"><g fill="#13254a"><path d="M100 .212C44.868.212 0 44.889 0 99.788c0 55.132 44.868 100 100 100s100-44.868 100-100C200 44.889 155.132.212 100 .212zm0 181.164c-44.974 0-81.587-36.614-81.587-81.587 0-44.762 36.614-81.164 81.587-81.164 44.995 0 81.587 36.402 81.587 81.164 0 44.973-36.592 81.587-81.587 81.587z" style="fill: #e6007e;"/><path d="M141.1 88.127h-29.439V58.688c0-6.392-5.185-11.598-11.598-11.598-6.413 0-11.619 5.206-11.619 11.598v29.439H58.476c-6.392 0-11.598 5.185-11.598 11.598 0 6.413 5.206 11.619 11.598 11.619h29.968v29.968c0 6.392 5.206 11.598 11.619 11.598 6.413 0 11.598-5.206 11.598-11.598v-29.968H141.1c6.392 0 11.598-5.206 11.598-11.619 0-6.413-5.206-11.598-11.598-11.598z" style="fill: #e6007e;"/></g></svg>

After

Width:  |  Height:  |  Size: 830 B

@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 200"><g fill="#03234b"><path d="M170.934 64.569l-.04-.055-29.049 40.038-.057.079h14.867a59.366 59.366 0 0 1-1.488 15.615c-1.158 5.318-3.807 13.448-9.848 21.977-2.766 4.118-6.375 7.726-9.208 10.408-3.426 2.857-7.461 6.095-12 8.376-8.121 4.568-17.881 7.138-28.225 7.432-10.907.248-20.201-2.61-26.072-5.052-8.283-3.479-14.111-7.807-16.85-10.078-1.254-.956-2.25-1.907-3.057-2.676a28.662 28.662 0 0 0-1.157-1.069 158.874 158.874 0 0 0-1.479-1.362l-4.435-3.956 3.569 4.81.183.243c.2.263.548.722 1.048 1.389.276.334.579.747.93 1.226l.008.01c.689.939 1.546 2.107 2.664 3.322 3 3.536 8.178 8.801 15.808 13.801 5.969 3.866 15.672 8.901 28.001 10.935a79.05 79.05 0 0 0 12.485.998c7.97 0 15.651-1.228 22.828-3.649 6.366-1.877 12.192-4.981 17.053-7.771 6.16-3.936 10.817-7.586 14.654-11.488 8.084-7.899 14.884-17.913 19.15-28.199 3.259-7.594 5.456-15.727 6.529-24.175l.055-.425.083-.641H200l-29.066-40.063zM58.159 99.232l-12.655.563c-.097-.881-.159-1.986-.227-3.474a59.184 59.184 0 0 1 1.446-16.56c1.157-5.316 3.804-13.444 9.848-21.977 2.168-3.228 5.009-6.44 9.208-10.415 3.41-2.849 7.432-6.08 12.005-8.375 8.114-4.568 17.87-7.138 28.213-7.432 10.9-.25 20.196 2.607 26.072 5.045 8.258 3.473 14.105 7.812 16.857 10.091 1.257.951 2.253 1.904 3.057 2.673l.017.016c.43.411.801.766 1.136 1.051.475.438.841.777 1.091 1.01l.138.128.248.229 4.04 3.613-3.165-4.456c-.058-.083-.312-.417-.73-.971l-.507-.67a28.922 28.922 0 0 1-.901-1.192l-.02-.027c-.69-.945-1.548-2.121-2.677-3.346-3.002-3.537-8.182-8.803-15.813-13.801-5.964-3.865-15.662-8.9-27.997-10.935-8.484-1.363-21.496-2.009-35.313 2.651-6.355 1.88-12.186 4.983-17.054 7.772-6.163 3.944-10.82 7.595-14.654 11.488-8.079 7.894-14.882 17.909-19.155 28.2-3.268 7.624-5.463 15.757-6.523 24.173-.436 3.281-.642 5.421-.664 6.926L0 101.831l30.683 38.727.042.053 27.38-41.298.054-.081z" style="fill: #e6007e;"/></g></svg>

After

Width:  |  Height:  |  Size: 1.9 KiB

+613
View File
@@ -0,0 +1,613 @@
/**
******************************************************************************
* @file dp83848.c
* @author MCD Application Team
* @brief This file provides a set of functions needed to manage the DP83848
* PHY devices.
******************************************************************************
* @attention
*
* Copyright (c) 2021 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "dp83848.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Component
* @{
*/
/** @defgroup DP83848 DP83848
* @{
*/
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/** @defgroup DP83848_Private_Defines DP83848 Private Defines
* @{
*/
#define DP83848_MAX_DEV_ADDR ((uint32_t)31U)
/**
* @}
*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
/** @defgroup DP83848_Private_Functions DP83848 Private Functions
* @{
*/
/**
* @brief Register IO functions to component object
* @param pObj: device object of DP83848_Object_t.
* @param ioctx: holds device IO functions.
* @retval DP83848_STATUS_OK if OK
* DP83848_STATUS_ERROR if missing mandatory function
*/
int32_t DP83848_RegisterBusIO(dp83848_Object_t *pObj, dp83848_IOCtx_t *ioctx)
{
if(!pObj || !ioctx->ReadReg || !ioctx->WriteReg || !ioctx->GetTick)
{
return DP83848_STATUS_ERROR;
}
pObj->IO.Init = ioctx->Init;
pObj->IO.DeInit = ioctx->DeInit;
pObj->IO.ReadReg = ioctx->ReadReg;
pObj->IO.WriteReg = ioctx->WriteReg;
pObj->IO.GetTick = ioctx->GetTick;
return DP83848_STATUS_OK;
}
/**
* @brief Initialize the DP83848 and configure the needed hardware resources
* @param pObj: device object DP83848_Object_t.
* @retval DP83848_STATUS_OK if OK
* DP83848_STATUS_ADDRESS_ERROR if cannot find device address
* DP83848_STATUS_READ_ERROR if connot read register
*/
int32_t DP83848_Init(dp83848_Object_t *pObj)
{
uint32_t regvalue = 0, addr = 0;
int32_t status = DP83848_STATUS_OK;
if(pObj->Is_Initialized == 0)
{
if(pObj->IO.Init != 0)
{
/* GPIO and Clocks initialization */
pObj->IO.Init();
}
/* for later check */
pObj->DevAddr = DP83848_MAX_DEV_ADDR + 1;
/* Get the device address from special mode register */
for(addr = 0; addr <= DP83848_MAX_DEV_ADDR; addr ++)
{
if(pObj->IO.ReadReg(addr, DP83848_SMR, &regvalue) < 0)
{
status = DP83848_STATUS_READ_ERROR;
/* Can't read from this device address
continue with next address */
continue;
}
if((regvalue & DP83848_SMR_PHY_ADDR) == addr)
{
pObj->DevAddr = addr;
status = DP83848_STATUS_OK;
break;
}
}
if(pObj->DevAddr > DP83848_MAX_DEV_ADDR)
{
status = DP83848_STATUS_ADDRESS_ERROR;
}
/* if device address is matched */
if(status == DP83848_STATUS_OK)
{
pObj->Is_Initialized = 1;
}
}
return status;
}
/**
* @brief De-Initialize the dp83848 and it's hardware resources
* @param pObj: device object DP83848_Object_t.
* @retval None
*/
int32_t DP83848_DeInit(dp83848_Object_t *pObj)
{
if(pObj->Is_Initialized)
{
if(pObj->IO.DeInit != 0)
{
if(pObj->IO.DeInit() < 0)
{
return DP83848_STATUS_ERROR;
}
}
pObj->Is_Initialized = 0;
}
return DP83848_STATUS_OK;
}
/**
* @brief Disable the DP83848 power down mode.
* @param pObj: device object DP83848_Object_t.
* @retval DP83848_STATUS_OK if OK
* DP83848_STATUS_READ_ERROR if connot read register
* DP83848_STATUS_WRITE_ERROR if connot write to register
*/
int32_t DP83848_DisablePowerDownMode(dp83848_Object_t *pObj)
{
uint32_t readval = 0;
int32_t status = DP83848_STATUS_OK;
if(pObj->IO.ReadReg(pObj->DevAddr, DP83848_BCR, &readval) >= 0)
{
readval &= ~DP83848_BCR_POWER_DOWN;
/* Apply configuration */
if(pObj->IO.WriteReg(pObj->DevAddr, DP83848_BCR, readval) < 0)
{
status = DP83848_STATUS_WRITE_ERROR;
}
}
else
{
status = DP83848_STATUS_READ_ERROR;
}
return status;
}
/**
* @brief Enable the DP83848 power down mode.
* @param pObj: device object DP83848_Object_t.
* @retval DP83848_STATUS_OK if OK
* DP83848_STATUS_READ_ERROR if connot read register
* DP83848_STATUS_WRITE_ERROR if connot write to register
*/
int32_t DP83848_EnablePowerDownMode(dp83848_Object_t *pObj)
{
uint32_t readval = 0;
int32_t status = DP83848_STATUS_OK;
if(pObj->IO.ReadReg(pObj->DevAddr, DP83848_BCR, &readval) >= 0)
{
readval |= DP83848_BCR_POWER_DOWN;
/* Apply configuration */
if(pObj->IO.WriteReg(pObj->DevAddr, DP83848_BCR, readval) < 0)
{
status = DP83848_STATUS_WRITE_ERROR;
}
}
else
{
status = DP83848_STATUS_READ_ERROR;
}
return status;
}
/**
* @brief Start the auto negotiation process.
* @param pObj: device object DP83848_Object_t.
* @retval DP83848_STATUS_OK if OK
* DP83848_STATUS_READ_ERROR if connot read register
* DP83848_STATUS_WRITE_ERROR if connot write to register
*/
int32_t DP83848_StartAutoNego(dp83848_Object_t *pObj)
{
uint32_t readval = 0;
int32_t status = DP83848_STATUS_OK;
if(pObj->IO.ReadReg(pObj->DevAddr, DP83848_BCR, &readval) >= 0)
{
readval |= DP83848_BCR_AUTONEGO_EN;
/* Apply configuration */
if(pObj->IO.WriteReg(pObj->DevAddr, DP83848_BCR, readval) < 0)
{
status = DP83848_STATUS_WRITE_ERROR;
}
}
else
{
status = DP83848_STATUS_READ_ERROR;
}
return status;
}
/**
* @brief Get the link state of DP83848 device.
* @param pObj: Pointer to device object.
* @param pLinkState: Pointer to link state
* @retval DP83848_STATUS_LINK_DOWN if link is down
* DP83848_STATUS_AUTONEGO_NOTDONE if Auto nego not completed
* DP83848_STATUS_100MBITS_FULLDUPLEX if 100Mb/s FD
* DP83848_STATUS_100MBITS_HALFDUPLEX if 100Mb/s HD
* DP83848_STATUS_10MBITS_FULLDUPLEX if 10Mb/s FD
* DP83848_STATUS_10MBITS_HALFDUPLEX if 10Mb/s HD
* DP83848_STATUS_READ_ERROR if connot read register
* DP83848_STATUS_WRITE_ERROR if connot write to register
*/
int32_t DP83848_GetLinkState(dp83848_Object_t *pObj)
{
uint32_t readval = 0;
/* Read Status register */
if(pObj->IO.ReadReg(pObj->DevAddr, DP83848_BSR, &readval) < 0)
{
return DP83848_STATUS_READ_ERROR;
}
/* Read Status register again */
if(pObj->IO.ReadReg(pObj->DevAddr, DP83848_BSR, &readval) < 0)
{
return DP83848_STATUS_READ_ERROR;
}
if((readval & DP83848_BSR_LINK_STATUS) == 0)
{
/* Return Link Down status */
return DP83848_STATUS_LINK_DOWN;
}
/* Check Auto negotiaition */
if(pObj->IO.ReadReg(pObj->DevAddr, DP83848_BCR, &readval) < 0)
{
return DP83848_STATUS_READ_ERROR;
}
if((readval & DP83848_BCR_AUTONEGO_EN) != DP83848_BCR_AUTONEGO_EN)
{
if(((readval & DP83848_BCR_SPEED_SELECT) == DP83848_BCR_SPEED_SELECT) && ((readval & DP83848_BCR_DUPLEX_MODE) == DP83848_BCR_DUPLEX_MODE))
{
return DP83848_STATUS_100MBITS_FULLDUPLEX;
}
else if ((readval & DP83848_BCR_SPEED_SELECT) == DP83848_BCR_SPEED_SELECT)
{
return DP83848_STATUS_100MBITS_HALFDUPLEX;
}
else if ((readval & DP83848_BCR_DUPLEX_MODE) == DP83848_BCR_DUPLEX_MODE)
{
return DP83848_STATUS_10MBITS_FULLDUPLEX;
}
else
{
return DP83848_STATUS_10MBITS_HALFDUPLEX;
}
}
else /* Auto Nego enabled */
{
if(pObj->IO.ReadReg(pObj->DevAddr, DP83848_PHYSCSR, &readval) < 0)
{
return DP83848_STATUS_READ_ERROR;
}
/* Check if auto nego not done */
if((readval & DP83848_PHYSCSR_AUTONEGO_DONE) == 0)
{
return DP83848_STATUS_AUTONEGO_NOTDONE;
}
if((readval & DP83848_PHYSCSR_HCDSPEEDMASK) == DP83848_PHYSCSR_100BTX_FD)
{
return DP83848_STATUS_100MBITS_FULLDUPLEX;
}
else if ((readval & DP83848_PHYSCSR_HCDSPEEDMASK) == DP83848_PHYSCSR_100BTX_HD)
{
return DP83848_STATUS_100MBITS_HALFDUPLEX;
}
else if ((readval & DP83848_PHYSCSR_HCDSPEEDMASK) == DP83848_PHYSCSR_10BT_FD)
{
return DP83848_STATUS_10MBITS_FULLDUPLEX;
}
else
{
return DP83848_STATUS_10MBITS_HALFDUPLEX;
}
}
}
/**
* @brief Set the link state of DP83848 device.
* @param pObj: Pointer to device object.
* @param pLinkState: link state can be one of the following
* DP83848_STATUS_100MBITS_FULLDUPLEX if 100Mb/s FD
* DP83848_STATUS_100MBITS_HALFDUPLEX if 100Mb/s HD
* DP83848_STATUS_10MBITS_FULLDUPLEX if 10Mb/s FD
* DP83848_STATUS_10MBITS_HALFDUPLEX if 10Mb/s HD
* @retval DP83848_STATUS_OK if OK
* DP83848_STATUS_ERROR if parameter error
* DP83848_STATUS_READ_ERROR if connot read register
* DP83848_STATUS_WRITE_ERROR if connot write to register
*/
int32_t DP83848_SetLinkState(dp83848_Object_t *pObj, uint32_t LinkState)
{
uint32_t bcrvalue = 0;
int32_t status = DP83848_STATUS_OK;
if(pObj->IO.ReadReg(pObj->DevAddr, DP83848_BCR, &bcrvalue) >= 0)
{
/* Disable link config (Auto nego, speed and duplex) */
bcrvalue &= ~(DP83848_BCR_AUTONEGO_EN | DP83848_BCR_SPEED_SELECT | DP83848_BCR_DUPLEX_MODE);
if(LinkState == DP83848_STATUS_100MBITS_FULLDUPLEX)
{
bcrvalue |= (DP83848_BCR_SPEED_SELECT | DP83848_BCR_DUPLEX_MODE);
}
else if (LinkState == DP83848_STATUS_100MBITS_HALFDUPLEX)
{
bcrvalue |= DP83848_BCR_SPEED_SELECT;
}
else if (LinkState == DP83848_STATUS_10MBITS_FULLDUPLEX)
{
bcrvalue |= DP83848_BCR_DUPLEX_MODE;
}
else
{
/* Wrong link status parameter */
status = DP83848_STATUS_ERROR;
}
}
else
{
status = DP83848_STATUS_READ_ERROR;
}
if(status == DP83848_STATUS_OK)
{
/* Apply configuration */
if(pObj->IO.WriteReg(pObj->DevAddr, DP83848_BCR, bcrvalue) < 0)
{
status = DP83848_STATUS_WRITE_ERROR;
}
}
return status;
}
/**
* @brief Enable loopback mode.
* @param pObj: Pointer to device object.
* @retval DP83848_STATUS_OK if OK
* DP83848_STATUS_READ_ERROR if connot read register
* DP83848_STATUS_WRITE_ERROR if connot write to register
*/
int32_t DP83848_EnableLoopbackMode(dp83848_Object_t *pObj)
{
uint32_t readval = 0;
int32_t status = DP83848_STATUS_OK;
if(pObj->IO.ReadReg(pObj->DevAddr, DP83848_BCR, &readval) >= 0)
{
readval |= DP83848_BCR_LOOPBACK;
/* Apply configuration */
if(pObj->IO.WriteReg(pObj->DevAddr, DP83848_BCR, readval) < 0)
{
status = DP83848_STATUS_WRITE_ERROR;
}
}
else
{
status = DP83848_STATUS_READ_ERROR;
}
return status;
}
/**
* @brief Disable loopback mode.
* @param pObj: Pointer to device object.
* @retval DP83848_STATUS_OK if OK
* DP83848_STATUS_READ_ERROR if connot read register
* DP83848_STATUS_WRITE_ERROR if connot write to register
*/
int32_t DP83848_DisableLoopbackMode(dp83848_Object_t *pObj)
{
uint32_t readval = 0;
int32_t status = DP83848_STATUS_OK;
if(pObj->IO.ReadReg(pObj->DevAddr, DP83848_BCR, &readval) >= 0)
{
readval &= ~DP83848_BCR_LOOPBACK;
/* Apply configuration */
if(pObj->IO.WriteReg(pObj->DevAddr, DP83848_BCR, readval) < 0)
{
status = DP83848_STATUS_WRITE_ERROR;
}
}
else
{
status = DP83848_STATUS_READ_ERROR;
}
return status;
}
/**
* @brief Enable IT source.
* @param pObj: Pointer to device object.
* @param Interrupt: IT source to be enabled
* should be a value or a combination of the following:
* DP83848_WOL_IT
* DP83848_ENERGYON_IT
* DP83848_AUTONEGO_COMPLETE_IT
* DP83848_REMOTE_FAULT_IT
* DP83848_LINK_DOWN_IT
* DP83848_AUTONEGO_LP_ACK_IT
* DP83848_PARALLEL_DETECTION_FAULT_IT
* DP83848_AUTONEGO_PAGE_RECEIVED_IT
* @retval DP83848_STATUS_OK if OK
* DP83848_STATUS_READ_ERROR if connot read register
* DP83848_STATUS_WRITE_ERROR if connot write to register
*/
int32_t DP83848_EnableIT(dp83848_Object_t *pObj, uint32_t Interrupt)
{
uint32_t readval = 0;
int32_t status = DP83848_STATUS_OK;
if(pObj->IO.ReadReg(pObj->DevAddr, DP83848_IMR, &readval) >= 0)
{
readval |= Interrupt;
/* Apply configuration */
if(pObj->IO.WriteReg(pObj->DevAddr, DP83848_IMR, readval) < 0)
{
status = DP83848_STATUS_WRITE_ERROR;
}
}
else
{
status = DP83848_STATUS_READ_ERROR;
}
return status;
}
/**
* @brief Disable IT source.
* @param pObj: Pointer to device object.
* @param Interrupt: IT source to be disabled
* should be a value or a combination of the following:
* DP83848_WOL_IT
* DP83848_ENERGYON_IT
* DP83848_AUTONEGO_COMPLETE_IT
* DP83848_REMOTE_FAULT_IT
* DP83848_LINK_DOWN_IT
* DP83848_AUTONEGO_LP_ACK_IT
* DP83848_PARALLEL_DETECTION_FAULT_IT
* DP83848_AUTONEGO_PAGE_RECEIVED_IT
* @retval DP83848_STATUS_OK if OK
* DP83848_STATUS_READ_ERROR if connot read register
* DP83848_STATUS_WRITE_ERROR if connot write to register
*/
int32_t DP83848_DisableIT(dp83848_Object_t *pObj, uint32_t Interrupt)
{
uint32_t readval = 0;
int32_t status = DP83848_STATUS_OK;
if(pObj->IO.ReadReg(pObj->DevAddr, DP83848_IMR, &readval) >= 0)
{
readval &= ~Interrupt;
/* Apply configuration */
if(pObj->IO.WriteReg(pObj->DevAddr, DP83848_IMR, readval) < 0)
{
status = DP83848_STATUS_WRITE_ERROR;
}
}
else
{
status = DP83848_STATUS_READ_ERROR;
}
return status;
}
/**
* @brief Clear IT flag.
* @param pObj: Pointer to device object.
* @param Interrupt: IT flag to be cleared
* should be a value or a combination of the following:
* DP83848_WOL_IT
* DP83848_ENERGYON_IT
* DP83848_AUTONEGO_COMPLETE_IT
* DP83848_REMOTE_FAULT_IT
* DP83848_LINK_DOWN_IT
* DP83848_AUTONEGO_LP_ACK_IT
* DP83848_PARALLEL_DETECTION_FAULT_IT
* DP83848_AUTONEGO_PAGE_RECEIVED_IT
* @retval DP83848_STATUS_OK if OK
* DP83848_STATUS_READ_ERROR if connot read register
*/
int32_t DP83848_ClearIT(dp83848_Object_t *pObj, uint32_t Interrupt)
{
uint32_t readval = 0;
int32_t status = DP83848_STATUS_OK;
if(pObj->IO.ReadReg(pObj->DevAddr, DP83848_ISFR, &readval) < 0)
{
status = DP83848_STATUS_READ_ERROR;
}
return status;
}
/**
* @brief Get IT Flag status.
* @param pObj: Pointer to device object.
* @param Interrupt: IT Flag to be checked,
* should be a value or a combination of the following:
* DP83848_WOL_IT
* DP83848_ENERGYON_IT
* DP83848_AUTONEGO_COMPLETE_IT
* DP83848_REMOTE_FAULT_IT
* DP83848_LINK_DOWN_IT
* DP83848_AUTONEGO_LP_ACK_IT
* DP83848_PARALLEL_DETECTION_FAULT_IT
* DP83848_AUTONEGO_PAGE_RECEIVED_IT
* @retval 1 IT flag is SET
* 0 IT flag is RESET
* DP83848_STATUS_READ_ERROR if connot read register
*/
int32_t DP83848_GetITStatus(dp83848_Object_t *pObj, uint32_t Interrupt)
{
uint32_t readval = 0;
int32_t status = 0;
if(pObj->IO.ReadReg(pObj->DevAddr, DP83848_ISFR, &readval) >= 0)
{
status = ((readval & Interrupt) == Interrupt);
}
else
{
status = DP83848_STATUS_READ_ERROR;
}
return status;
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
+434
View File
@@ -0,0 +1,434 @@
/**
******************************************************************************
* @file dp83848.h
* @author MCD Application Team
* @brief This file contains all the functions prototypes for the
* dp83848.c PHY driver.
******************************************************************************
* @attention
*
* Copyright (c) 2021 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef DP83848_H
#define DP83848_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include <stdint.h>
/** @addtogroup BSP
* @{
*/
/** @addtogroup Component
* @{
*/
/** @defgroup DP83848
* @{
*/
/* Exported constants --------------------------------------------------------*/
/** @defgroup DP83848_Exported_Constants DP83848 Exported Constants
* @{
*/
/** @defgroup DP83848_Registers_Mapping DP83848 Registers Mapping
* @{
*/
#define DP83848_BCR ((uint16_t)0x0000U)
#define DP83848_BSR ((uint16_t)0x0001U)
#define DP83848_PHYI1R ((uint16_t)0x0002U)
#define DP83848_PHYI2R ((uint16_t)0x0003U)
#define DP83848_ANAR ((uint16_t)0x0004U)
#define DP83848_ANLPAR ((uint16_t)0x0005U)
#define DP83848_ANER ((uint16_t)0x0006U)
#define DP83848_ANNPTR ((uint16_t)0x0007U)
#define DP83848_SMR ((uint16_t)0x0019U)
#define DP83848_ISFR ((uint16_t)0x0012U)
#define DP83848_IMR ((uint16_t)0x0011U)
#define DP83848_PHYSCSR ((uint16_t)0x0010U)
/**
* @}
*/
/** @defgroup DP83848_BCR_Bit_Definition DP83848 BCR Bit Definition
* @{
*/
#define DP83848_BCR_SOFT_RESET ((uint16_t)0x8000U)
#define DP83848_BCR_LOOPBACK ((uint16_t)0x4000U)
#define DP83848_BCR_SPEED_SELECT ((uint16_t)0x2000U)
#define DP83848_BCR_AUTONEGO_EN ((uint16_t)0x1000U)
#define DP83848_BCR_POWER_DOWN ((uint16_t)0x0800U)
#define DP83848_BCR_ISOLATE ((uint16_t)0x0400U)
#define DP83848_BCR_RESTART_AUTONEGO ((uint16_t)0x0200U)
#define DP83848_BCR_DUPLEX_MODE ((uint16_t)0x0100U)
/**
* @}
*/
/** @defgroup DP83848_BSR_Bit_Definition DP83848 BSR Bit Definition
* @{
*/
#define DP83848_BSR_100BASE_T4 ((uint16_t)0x8000U)
#define DP83848_BSR_100BASE_TX_FD ((uint16_t)0x4000U)
#define DP83848_BSR_100BASE_TX_HD ((uint16_t)0x2000U)
#define DP83848_BSR_10BASE_T_FD ((uint16_t)0x1000U)
#define DP83848_BSR_10BASE_T_HD ((uint16_t)0x0800U)
#define DP83848_BSR_MF_PREAMBLE ((uint16_t)0x0040U)
#define DP83848_BSR_AUTONEGO_CPLT ((uint16_t)0x0020U)
#define DP83848_BSR_REMOTE_FAULT ((uint16_t)0x0010U)
#define DP83848_BSR_AUTONEGO_ABILITY ((uint16_t)0x0008U)
#define DP83848_BSR_LINK_STATUS ((uint16_t)0x0004U)
#define DP83848_BSR_JABBER_DETECT ((uint16_t)0x0002U)
#define DP83848_BSR_EXTENDED_CAP ((uint16_t)0x0001U)
/**
* @}
*/
/** @defgroup DP83848_PHYI1R_Bit_Definition DP83848 PHYI1R Bit Definition
* @{
*/
#define DP83848_PHYI1R_OUI_3_18 ((uint16_t)0xFFFFU)
/**
* @}
*/
/** @defgroup DP83848_PHYI2R_Bit_Definition DP83848 PHYI2R Bit Definition
* @{
*/
#define DP83848_PHYI2R_OUI_19_24 ((uint16_t)0xFC00U)
#define DP83848_PHYI2R_MODEL_NBR ((uint16_t)0x03F0U)
#define DP83848_PHYI2R_REVISION_NBR ((uint16_t)0x000FU)
/**
* @}
*/
/** @defgroup DP83848_ANAR_Bit_Definition DP83848 ANAR Bit Definition
* @{
*/
#define DP83848_ANAR_NEXT_PAGE ((uint16_t)0x8000U)
#define DP83848_ANAR_REMOTE_FAULT ((uint16_t)0x2000U)
#define DP83848_ANAR_PAUSE_OPERATION ((uint16_t)0x0C00U)
#define DP83848_ANAR_PO_NOPAUSE ((uint16_t)0x0000U)
#define DP83848_ANAR_PO_SYMMETRIC_PAUSE ((uint16_t)0x0400U)
#define DP83848_ANAR_PO_ASYMMETRIC_PAUSE ((uint16_t)0x0800U)
#define DP83848_ANAR_PO_ADVERTISE_SUPPORT ((uint16_t)0x0C00U)
#define DP83848_ANAR_100BASE_TX_FD ((uint16_t)0x0100U)
#define DP83848_ANAR_100BASE_TX ((uint16_t)0x0080U)
#define DP83848_ANAR_10BASE_T_FD ((uint16_t)0x0040U)
#define DP83848_ANAR_10BASE_T ((uint16_t)0x0020U)
#define DP83848_ANAR_SELECTOR_FIELD ((uint16_t)0x000FU)
/**
* @}
*/
/** @defgroup DP83848_ANLPAR_Bit_Definition DP83848 ANLPAR Bit Definition
* @{
*/
#define DP83848_ANLPAR_NEXT_PAGE ((uint16_t)0x8000U)
#define DP83848_ANLPAR_REMOTE_FAULT ((uint16_t)0x2000U)
#define DP83848_ANLPAR_PAUSE_OPERATION ((uint16_t)0x0C00U)
#define DP83848_ANLPAR_PO_NOPAUSE ((uint16_t)0x0000U)
#define DP83848_ANLPAR_PO_SYMMETRIC_PAUSE ((uint16_t)0x0400U)
#define DP83848_ANLPAR_PO_ASYMMETRIC_PAUSE ((uint16_t)0x0800U)
#define DP83848_ANLPAR_PO_ADVERTISE_SUPPORT ((uint16_t)0x0C00U)
#define DP83848_ANLPAR_100BASE_TX_FD ((uint16_t)0x0100U)
#define DP83848_ANLPAR_100BASE_TX ((uint16_t)0x0080U)
#define DP83848_ANLPAR_10BASE_T_FD ((uint16_t)0x0040U)
#define DP83848_ANLPAR_10BASE_T ((uint16_t)0x0020U)
#define DP83848_ANLPAR_SELECTOR_FIELD ((uint16_t)0x000FU)
/**
* @}
*/
/** @defgroup DP83848_ANER_Bit_Definition DP83848 ANER Bit Definition
* @{
*/
#define DP83848_ANER_RX_NP_LOCATION_ABLE ((uint16_t)0x0040U)
#define DP83848_ANER_RX_NP_STORAGE_LOCATION ((uint16_t)0x0020U)
#define DP83848_ANER_PARALLEL_DETECT_FAULT ((uint16_t)0x0010U)
#define DP83848_ANER_LP_NP_ABLE ((uint16_t)0x0008U)
#define DP83848_ANER_NP_ABLE ((uint16_t)0x0004U)
#define DP83848_ANER_PAGE_RECEIVED ((uint16_t)0x0002U)
#define DP83848_ANER_LP_AUTONEG_ABLE ((uint16_t)0x0001U)
/**
* @}
*/
/** @defgroup DP83848_ANNPTR_Bit_Definition DP83848 ANNPTR Bit Definition
* @{
*/
#define DP83848_ANNPTR_NEXT_PAGE ((uint16_t)0x8000U)
#define DP83848_ANNPTR_MESSAGE_PAGE ((uint16_t)0x2000U)
#define DP83848_ANNPTR_ACK2 ((uint16_t)0x1000U)
#define DP83848_ANNPTR_TOGGLE ((uint16_t)0x0800U)
#define DP83848_ANNPTR_MESSAGE_CODE ((uint16_t)0x07FFU)
/**
* @}
*/
/** @defgroup DP83848_ANNPRR_Bit_Definition DP83848 ANNPRR Bit Definition
* @{
*/
#define DP83848_ANNPRR_NEXT_PAGE ((uint16_t)0x8000U)
#define DP83848_ANNPRR_ACK ((uint16_t)0x4000U)
#define DP83848_ANNPRR_MESSAGE_PAGE ((uint16_t)0x2000U)
#define DP83848_ANNPRR_ACK2 ((uint16_t)0x1000U)
#define DP83848_ANNPRR_TOGGLE ((uint16_t)0x0800U)
#define DP83848_ANNPRR_MESSAGE_CODE ((uint16_t)0x07FFU)
/**
* @}
*/
/** @defgroup DP83848_MMDACR_Bit_Definition DP83848 MMDACR Bit Definition
* @{
*/
#define DP83848_MMDACR_MMD_FUNCTION ((uint16_t)0xC000U)
#define DP83848_MMDACR_MMD_FUNCTION_ADDR ((uint16_t)0x0000U)
#define DP83848_MMDACR_MMD_FUNCTION_DATA ((uint16_t)0x4000U)
#define DP83848_MMDACR_MMD_DEV_ADDR ((uint16_t)0x001FU)
/**
* @}
*/
/** @defgroup DP83848_ENCTR_Bit_Definition DP83848 ENCTR Bit Definition
* @{
*/
#define DP83848_ENCTR_TX_ENABLE ((uint16_t)0x8000U)
#define DP83848_ENCTR_TX_TIMER ((uint16_t)0x6000U)
#define DP83848_ENCTR_TX_TIMER_1S ((uint16_t)0x0000U)
#define DP83848_ENCTR_TX_TIMER_768MS ((uint16_t)0x2000U)
#define DP83848_ENCTR_TX_TIMER_512MS ((uint16_t)0x4000U)
#define DP83848_ENCTR_TX_TIMER_265MS ((uint16_t)0x6000U)
#define DP83848_ENCTR_RX_ENABLE ((uint16_t)0x1000U)
#define DP83848_ENCTR_RX_MAX_INTERVAL ((uint16_t)0x0C00U)
#define DP83848_ENCTR_RX_MAX_INTERVAL_64MS ((uint16_t)0x0000U)
#define DP83848_ENCTR_RX_MAX_INTERVAL_256MS ((uint16_t)0x0400U)
#define DP83848_ENCTR_RX_MAX_INTERVAL_512MS ((uint16_t)0x0800U)
#define DP83848_ENCTR_RX_MAX_INTERVAL_1S ((uint16_t)0x0C00U)
#define DP83848_ENCTR_EX_CROSS_OVER ((uint16_t)0x0002U)
#define DP83848_ENCTR_EX_MANUAL_CROSS_OVER ((uint16_t)0x0001U)
/**
* @}
*/
/** @defgroup DP83848_MCSR_Bit_Definition DP83848 MCSR Bit Definition
* @{
*/
#define DP83848_MCSR_EDPWRDOWN ((uint16_t)0x2000U)
#define DP83848_MCSR_FARLOOPBACK ((uint16_t)0x0200U)
#define DP83848_MCSR_ALTINT ((uint16_t)0x0040U)
#define DP83848_MCSR_ENERGYON ((uint16_t)0x0002U)
/**
* @}
*/
/** @defgroup DP83848_SMR_Bit_Definition DP83848 SMR Bit Definition
* @{
*/
#define DP83848_SMR_MODE ((uint16_t)0x00E0U)
#define DP83848_SMR_PHY_ADDR ((uint16_t)0x001FU)
/**
* @}
*/
/** @defgroup DP83848_TPDCR_Bit_Definition DP83848 TPDCR Bit Definition
* @{
*/
#define DP83848_TPDCR_DELAY_IN ((uint16_t)0x8000U)
#define DP83848_TPDCR_LINE_BREAK_COUNTER ((uint16_t)0x7000U)
#define DP83848_TPDCR_PATTERN_HIGH ((uint16_t)0x0FC0U)
#define DP83848_TPDCR_PATTERN_LOW ((uint16_t)0x003FU)
/**
* @}
*/
/** @defgroup DP83848_TCSR_Bit_Definition DP83848 TCSR Bit Definition
* @{
*/
#define DP83848_TCSR_TDR_ENABLE ((uint16_t)0x8000U)
#define DP83848_TCSR_TDR_AD_FILTER_ENABLE ((uint16_t)0x4000U)
#define DP83848_TCSR_TDR_CH_CABLE_TYPE ((uint16_t)0x0600U)
#define DP83848_TCSR_TDR_CH_CABLE_DEFAULT ((uint16_t)0x0000U)
#define DP83848_TCSR_TDR_CH_CABLE_SHORTED ((uint16_t)0x0200U)
#define DP83848_TCSR_TDR_CH_CABLE_OPEN ((uint16_t)0x0400U)
#define DP83848_TCSR_TDR_CH_CABLE_MATCH ((uint16_t)0x0600U)
#define DP83848_TCSR_TDR_CH_STATUS ((uint16_t)0x0100U)
#define DP83848_TCSR_TDR_CH_LENGTH ((uint16_t)0x00FFU)
/**
* @}
*/
/** @defgroup DP83848_SCSIR_Bit_Definition DP83848 SCSIR Bit Definition
* @{
*/
#define DP83848_SCSIR_AUTO_MDIX_ENABLE ((uint16_t)0x8000U)
#define DP83848_SCSIR_CHANNEL_SELECT ((uint16_t)0x2000U)
#define DP83848_SCSIR_SQE_DISABLE ((uint16_t)0x0800U)
#define DP83848_SCSIR_XPOLALITY ((uint16_t)0x0010U)
/**
* @}
*/
/** @defgroup DP83848_CLR_Bit_Definition DP83848 CLR Bit Definition
* @{
*/
#define DP83848_CLR_CABLE_LENGTH ((uint16_t)0xF000U)
/**
* @}
*/
/** @defgroup DP83848_IMR_ISFR_Bit_Definition DP83848 IMR ISFR Bit Definition
* @{
*/
#define DP83848_INT_8 ((uint16_t)0x0100U)
#define DP83848_INT_7 ((uint16_t)0x0080U)
#define DP83848_INT_6 ((uint16_t)0x0040U)
#define DP83848_INT_5 ((uint16_t)0x0020U)
#define DP83848_INT_4 ((uint16_t)0x0010U)
#define DP83848_INT_3 ((uint16_t)0x0008U)
#define DP83848_INT_2 ((uint16_t)0x0004U)
#define DP83848_INT_1 ((uint16_t)0x0002U)
/**
* @}
*/
/** @defgroup DP83848_PHYSCSR_Bit_Definition DP83848 PHYSCSR Bit Definition
* @{
*/
#define DP83848_PHYSCSR_AUTONEGO_DONE ((uint16_t)0x010U)
#define DP83848_PHYSCSR_HCDSPEEDMASK ((uint16_t)0x006U)
#define DP83848_PHYSCSR_10BT_HD ((uint16_t)0x002U)
#define DP83848_PHYSCSR_10BT_FD ((uint16_t)0x006U)
#define DP83848_PHYSCSR_100BTX_HD ((uint16_t)0x000U)
#define DP83848_PHYSCSR_100BTX_FD ((uint16_t)0x004U)
/**
* @}
*/
/** @defgroup DP83848_Status DP83848 Status
* @{
*/
#define DP83848_STATUS_READ_ERROR ((int32_t)-5)
#define DP83848_STATUS_WRITE_ERROR ((int32_t)-4)
#define DP83848_STATUS_ADDRESS_ERROR ((int32_t)-3)
#define DP83848_STATUS_RESET_TIMEOUT ((int32_t)-2)
#define DP83848_STATUS_ERROR ((int32_t)-1)
#define DP83848_STATUS_OK ((int32_t) 0)
#define DP83848_STATUS_LINK_DOWN ((int32_t) 1)
#define DP83848_STATUS_100MBITS_FULLDUPLEX ((int32_t) 2)
#define DP83848_STATUS_100MBITS_HALFDUPLEX ((int32_t) 3)
#define DP83848_STATUS_10MBITS_FULLDUPLEX ((int32_t) 4)
#define DP83848_STATUS_10MBITS_HALFDUPLEX ((int32_t) 5)
#define DP83848_STATUS_AUTONEGO_NOTDONE ((int32_t) 6)
/**
* @}
*/
/** @defgroup DP83848_IT_Flags DP83848 IT Flags
* @{
*/
#define DP83848_WOL_IT DP83848_INT_8
#define DP83848_ENERGYON_IT DP83848_INT_7
#define DP83848_AUTONEGO_COMPLETE_IT DP83848_INT_6
#define DP83848_REMOTE_FAULT_IT DP83848_INT_5
#define DP83848_LINK_DOWN_IT DP83848_INT_4
#define DP83848_AUTONEGO_LP_ACK_IT DP83848_INT_3
#define DP83848_PARALLEL_DETECTION_FAULT_IT DP83848_INT_2
#define DP83848_AUTONEGO_PAGE_RECEIVED_IT DP83848_INT_1
/**
* @}
*/
/**
* @}
*/
/* Exported types ------------------------------------------------------------*/
/** @defgroup DP83848_Exported_Types DP83848 Exported Types
* @{
*/
typedef int32_t (*dp83848_Init_Func) (void);
typedef int32_t (*dp83848_DeInit_Func) (void);
typedef int32_t (*dp83848_ReadReg_Func) (uint32_t, uint32_t, uint32_t *);
typedef int32_t (*dp83848_WriteReg_Func) (uint32_t, uint32_t, uint32_t);
typedef int32_t (*dp83848_GetTick_Func) (void);
typedef struct
{
dp83848_Init_Func Init;
dp83848_DeInit_Func DeInit;
dp83848_WriteReg_Func WriteReg;
dp83848_ReadReg_Func ReadReg;
dp83848_GetTick_Func GetTick;
} dp83848_IOCtx_t;
typedef struct
{
uint32_t DevAddr;
uint32_t Is_Initialized;
dp83848_IOCtx_t IO;
void *pData;
}dp83848_Object_t;
/**
* @}
*/
/* Exported macro ------------------------------------------------------------*/
/* Exported functions --------------------------------------------------------*/
/** @defgroup DP83848_Exported_Functions DP83848 Exported Functions
* @{
*/
int32_t DP83848_RegisterBusIO(dp83848_Object_t *pObj, dp83848_IOCtx_t *ioctx);
int32_t DP83848_Init(dp83848_Object_t *pObj);
int32_t DP83848_DeInit(dp83848_Object_t *pObj);
int32_t DP83848_DisablePowerDownMode(dp83848_Object_t *pObj);
int32_t DP83848_EnablePowerDownMode(dp83848_Object_t *pObj);
int32_t DP83848_StartAutoNego(dp83848_Object_t *pObj);
int32_t DP83848_GetLinkState(dp83848_Object_t *pObj);
int32_t DP83848_SetLinkState(dp83848_Object_t *pObj, uint32_t LinkState);
int32_t DP83848_EnableLoopbackMode(dp83848_Object_t *pObj);
int32_t DP83848_DisableLoopbackMode(dp83848_Object_t *pObj);
int32_t DP83848_EnableIT(dp83848_Object_t *pObj, uint32_t Interrupt);
int32_t DP83848_DisableIT(dp83848_Object_t *pObj, uint32_t Interrupt);
int32_t DP83848_ClearIT(dp83848_Object_t *pObj, uint32_t Interrupt);
int32_t DP83848_GetITStatus(dp83848_Object_t *pObj, uint32_t Interrupt);
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* DP83848_H */
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/