|
| 1 | +/*********************************************************************************************************************** |
| 2 | + * DISCLAIMER |
| 3 | + * This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No |
| 4 | + * other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all |
| 5 | + * applicable laws, including copyright laws. |
| 6 | + * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING |
| 7 | + * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, |
| 8 | + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM |
| 9 | + * EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES |
| 10 | + * SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS |
| 11 | + * SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. |
| 12 | + * Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of |
| 13 | + * this software. By using this software, you agree to the additional terms and conditions found by accessing the |
| 14 | + * following link: |
| 15 | + * http://www.renesas.com/disclaimer |
| 16 | + * |
| 17 | + * Copyright (C) 2018-2020 Renesas Electronics Corporation. All rights reserved. |
| 18 | + ***********************************************************************************************************************/ |
| 19 | +/* Copyright (c) 2018-2020 Renesas Electronics Corporation. |
| 20 | + * SPDX-License-Identifier: Apache-2.0 |
| 21 | + * |
| 22 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 23 | + * you may not use this file except in compliance with the License. |
| 24 | + * You may obtain a copy of the License at |
| 25 | + * |
| 26 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 27 | + * |
| 28 | + * Unless required by applicable law or agreed to in writing, software |
| 29 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 30 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 31 | + * See the License for the specific language governing permissions and |
| 32 | + * limitations under the License. |
| 33 | + */ |
| 34 | +/*********************************************************************************************************************** |
| 35 | + * File Name : r_ether_rza2_if.h |
| 36 | + * Version : 1.00 |
| 37 | + * Description : Ethernet module device driver |
| 38 | + ***********************************************************************************************************************/ |
| 39 | + |
| 40 | +/* Guards against multiple inclusion */ |
| 41 | +#ifndef R_ETHER_RZA2_IF_H |
| 42 | + #define R_ETHER_RZA2_IF_H |
| 43 | + |
| 44 | +/*********************************************************************************************************************** |
| 45 | + Includes <System Includes> , "Project Includes" |
| 46 | + ***********************************************************************************************************************/ |
| 47 | + #include <stdint.h> |
| 48 | + |
| 49 | + #include "r_ether_rza2_config.h" |
| 50 | + #include "src/phy/phy.h" |
| 51 | + |
| 52 | +#ifdef __cplusplus |
| 53 | +extern "C" { |
| 54 | +#endif |
| 55 | +/*********************************************************************************************************************** |
| 56 | + Macro definitions |
| 57 | + ***********************************************************************************************************************/ |
| 58 | +/* Version Number of API. */ |
| 59 | + #define ETHER_RZA2_VERSION_MAJOR (1) |
| 60 | + #define ETHER_RZA2_VERSION_MINOR (0) |
| 61 | + |
| 62 | +/* When using the Read functions, ETHER_NO_DATA is the return value that indicates that no received data. */ |
| 63 | + #define ETHER_NO_DATA (0) |
| 64 | + |
| 65 | +/* The value of flag which indicates that the interrupt of Ethernet occur. */ |
| 66 | + #define ETHER_FLAG_OFF (0) |
| 67 | + #define ETHER_FLAG_ON (1) |
| 68 | + #define ETHER_FLAG_ON_LINK_ON (3) |
| 69 | + #define ETHER_FLAG_ON_LINK_OFF (2) |
| 70 | + |
| 71 | +/* Channel definition of Ethernet */ |
| 72 | + #define ETHER_CHANNEL_0 (0) |
| 73 | + #define ETHER_CHANNEL_1 (1) |
| 74 | + |
| 75 | + #define ETHER_CHANNEL_MAX (ETHER_CH0_EN + ETHER_CH1_EN) |
| 76 | + |
| 77 | +/*********************************************************************************************************************** |
| 78 | + Typedef definitions |
| 79 | + ***********************************************************************************************************************/ |
| 80 | +/* ETHER API error codes */ |
| 81 | +typedef enum |
| 82 | +{ |
| 83 | + ETHER_SUCCESS = 0, /* Processing completed successfully */ |
| 84 | + ETHER_ERR_INVALID_PTR = -1, /* Value of the pointer is NULL */ |
| 85 | + ETHER_ERR_INVALID_DATA = -2, /* Value of the argument is out of range */ |
| 86 | + ETHER_ERR_INVALID_CHAN = -3, /* Nonexistent channel number */ |
| 87 | + ETHER_ERR_INVALID_ARG = -4, /* Invalid argument */ |
| 88 | + ETHER_ERR_LINK = -5, /* Auto-negotiation is not completed, and transmission/reception is not enabled. */ |
| 89 | + ETHER_ERR_MPDE = -6, /* As a Magic Packet is being detected, and transmission/reception is not enabled. */ |
| 90 | + ETHER_ERR_TACT = -7, /* Transmit buffer is not empty. */ |
| 91 | + ETHER_ERR_CHAN_OPEN = -8, /* Indicates the Ethernet cannot be opened because it is being used by another application */ |
| 92 | + ETHER_ERR_MC_FRAME = -9, /* Detect multicast frame when multicast frame filtering enable */ |
| 93 | + ETHER_ERR_RECV_ENABLE = -10, /* Enable receive function in ETHERC */ |
| 94 | + ETHER_ERR_OTHER = -11 /* Other error */ |
| 95 | +} ether_return_t; |
| 96 | + |
| 97 | +/* Event code of callback function */ |
| 98 | +typedef enum |
| 99 | +{ |
| 100 | + ETHER_CB_EVENT_ID_WAKEON_LAN, /* Magic packet detection */ |
| 101 | + ETHER_CB_EVENT_ID_LINK_ON, /* Link up detection */ |
| 102 | + ETHER_CB_EVENT_ID_LINK_OFF, /* Link down detection */ |
| 103 | +} ether_cb_event_t; |
| 104 | + |
| 105 | +/* Structure of the callback function pointer */ |
| 106 | +typedef struct |
| 107 | +{ |
| 108 | + void (*pcb_func) (void *); /* Callback function pointer */ |
| 109 | + void (*pcb_int_hnd) (void*); /* Interrupt handler function pointer */ |
| 110 | +} ether_cb_t; |
| 111 | + |
| 112 | +/* Structure to be used when decoding the argument of the callback function */ |
| 113 | +typedef struct |
| 114 | +{ |
| 115 | + uint32_t channel; /* ETHERC channel */ |
| 116 | + ether_cb_event_t event_id; /* Event code for callback function */ |
| 117 | + uint32_t status_ecsr; /* ETHERC status register for interrupt handler */ |
| 118 | + uint32_t status_eesr; /* ETHERC/EDMAC status register for interrupt handler */ |
| 119 | +} ether_cb_arg_t; |
| 120 | + |
| 121 | +/* Parameters of the control function (1st argument) */ |
| 122 | +typedef enum |
| 123 | +{ |
| 124 | + CONTROL_SET_CALLBACK, /* Callback function registration */ |
| 125 | + CONTROL_SET_PROMISCUOUS_MODE, /* Promiscuous mode setting */ |
| 126 | + CONTROL_SET_INT_HANDLER, /* Interrupt handler function registration */ |
| 127 | + CONTROL_POWER_ON, /* Cancel ETHERC/EDMAC module stop */ |
| 128 | + CONTROL_POWER_OFF, /* Transition to ETHERC/EDMAC module stop */ |
| 129 | + CONTROL_MULTICASTFRAME_FILTER,/* Multicast frame filter setting*/ |
| 130 | + CONTROL_BROADCASTFRAME_FILTER /* Broadcast frame filter setting*/ |
| 131 | +} ether_cmd_t; |
| 132 | + |
| 133 | +typedef enum |
| 134 | +{ |
| 135 | + ETHER_PROMISCUOUS_OFF, /* ETHERC operates in standard mode */ |
| 136 | + ETHER_PROMISCUOUS_ON /* ETHERC operates in promiscuous mode */ |
| 137 | +} ether_promiscuous_bit_t; |
| 138 | + |
| 139 | +typedef enum |
| 140 | +{ |
| 141 | + ETHER_MC_FILTER_OFF, /* Multicast frame filter disable */ |
| 142 | + ETHER_MC_FILTER_ON /* Multicast frame filter enable */ |
| 143 | +} ether_mc_filter_t; |
| 144 | + |
| 145 | +typedef struct |
| 146 | +{ |
| 147 | + uint32_t channel; /* ETHERC channel */ |
| 148 | + ether_promiscuous_bit_t bit; /* Promiscuous mode */ |
| 149 | +} ether_promiscuous_t; |
| 150 | + |
| 151 | +typedef struct |
| 152 | +{ |
| 153 | + uint32_t channel; /* ETHERC channel */ |
| 154 | + ether_mc_filter_t flag; /* Multicast frame filter */ |
| 155 | +} ether_multicast_t; |
| 156 | + |
| 157 | +typedef struct |
| 158 | +{ |
| 159 | + uint32_t channel; /* ETHERC channel */ |
| 160 | + uint32_t counter; /* Continuous reception number of Broadcast frame */ |
| 161 | +} ether_broadcast_t; |
| 162 | + |
| 163 | +/* Parameters of the control function (2nd argument) */ |
| 164 | +typedef union |
| 165 | +{ |
| 166 | + ether_cb_t ether_callback; /* Callback function pointer */ |
| 167 | + ether_promiscuous_t * p_ether_promiscuous; /* Promiscuous mode setting */ |
| 168 | + ether_cb_t ether_int_hnd; /* Interrupt handler function pointer */ |
| 169 | + uint32_t channel; /* ETHERC channel number */ |
| 170 | + ether_multicast_t * p_ether_multicast; /* Multicast frame filter setting */ |
| 171 | + ether_broadcast_t * p_ether_broadcast; /* Broadcast frame filter setting */ |
| 172 | +} ether_param_t; |
| 173 | + |
| 174 | +/*********************************************************************************************************************** |
| 175 | + Exported global variables |
| 176 | + ***********************************************************************************************************************/ |
| 177 | + |
| 178 | +/*********************************************************************************************************************** |
| 179 | + Exported global functions (to be accessed by other files) |
| 180 | + ***********************************************************************************************************************/ |
| 181 | +extern void R_ETHER_Initial (void); |
| 182 | +extern ether_return_t R_ETHER_Open_ZC2 (uint32_t channel, const uint8_t mac_addr[], uint8_t pause); |
| 183 | +extern ether_return_t R_ETHER_Close_ZC2 (uint32_t channel); |
| 184 | +extern int32_t R_ETHER_Read (uint32_t channel, void *pbuf); |
| 185 | +extern int32_t R_ETHER_Read_ZC2 (uint32_t channel, void **pbuf); |
| 186 | +extern int32_t R_ETHER_Read_ZC2_BufRelease (uint32_t channel); |
| 187 | +extern ether_return_t R_ETHER_Write (uint32_t channel, void *pbuf, uint32_t len); |
| 188 | +extern ether_return_t R_ETHER_Write_ZC2_GetBuf (uint32_t channel, void **pbuf, uint16_t *pbuf_size); |
| 189 | +extern ether_return_t R_ETHER_Write_ZC2_SetBuf (uint32_t channel, const uint32_t len); |
| 190 | +extern ether_return_t R_ETHER_CheckLink_ZC (uint32_t channel); |
| 191 | +extern void R_ETHER_LinkProcess (uint32_t channel); |
| 192 | +extern ether_return_t R_ETHER_WakeOnLAN (uint32_t channel); |
| 193 | +extern ether_return_t R_ETHER_CheckWrite (uint32_t channel); |
| 194 | +extern ether_return_t R_ETHER_Control (ether_cmd_t const cmd, ether_param_t const control); |
| 195 | +extern uint32_t R_ETHER_GetVersion (void); |
| 196 | + |
| 197 | +#ifdef __cplusplus |
| 198 | +} |
| 199 | +#endif |
| 200 | + |
| 201 | +#endif /* R_ETHER_RZA2_IF_H*/ |
0 commit comments