Danke für die Info, ich denke das FreeRTOS (V4.8.0) ist eine gute
Vorlage. Der Umbau auf den Micrel war recht einfach:
Datei: emac.c
1 | unsigned int PHY_id; // ID from PHY
|
2 |
|
3 | : : : : :
|
4 | //--- in der Routine "Init_EMAC" ein paar Zeilen ändern (//<<<):
|
5 |
|
6 | PHY_id = (id1 << 16) | (id2 & 0xFFF0); //<<<
|
7 | if ((PHY_id == DP83848C_ID) || //<<<
|
8 | (PHY_id == MII_KS8721_ID)) //<<<
|
9 | {
|
10 | /* Configure the PHY device */
|
11 |
|
12 | /* Use autonegotiation about the link speed. */
|
13 | write_PHY (PHY_REG_BMCR, PHY_AUTO_NEG);
|
14 | /* Wait to complete Auto_Negotiation. */
|
15 | for (tout = 0; tout < 10; tout++) {
|
16 | vTaskDelay( 100 );
|
17 | regv = read_PHY (PHY_REG_BMSR);
|
18 | if (regv & 0x0020) {
|
19 | /* Autonegotiation Complete. */
|
20 | break;
|
21 | }
|
22 | }
|
23 | }
|
24 | else
|
25 | {
|
26 | xReturn = pdFAIL;
|
27 | }
|
28 |
|
29 | /* Check the link status. */
|
30 | if( xReturn == pdPASS )
|
31 | {
|
32 | xReturn = pdFAIL;
|
33 | for (tout = 0; tout < 10; tout++) {
|
34 | vTaskDelay( 100 );
|
35 | regv = read_PHY (PHY_REG_BMSR); // Bit exists in both PHY's //<<<
|
36 | if (regv & 0x0004) { //<<<
|
37 | /* Link is on. */
|
38 | xReturn = pdPASS;
|
39 | break;
|
40 | }
|
41 | }
|
42 | }
|
Datei: emac.h
1 | #define MII_KS8721_ID 0x00221610 /* PHY Identifier */
|
2 |
|
3 | extern unsigned int PHY_id; // ID from PHY (DP83848C_ID Or MII_KS8721_ID), read from Device
|
Die unteren Register sind bei beiden gleich daher gibt es keine
Komplikationen. Nur musste ich bei "/* Link is on. */" ein anderes
Register verwenden, da das der Micrel nicht hatte. Also der Code sollte
bei beiden PHY's funktionieren. Hat jemand ein Keil Demo-Bord der das
mal Testen kann?
Funktionieren tuts bei meinem Micrel dennoch nicht. :(
Kann mir jemand einen bitte Tipp geben?