fixed drive strength

Dependents:   capstone_i2c

Fork of mbed-dev by mbed official

Committer:
cpadua
Date:
Tue Apr 11 20:39:24 2017 +0000
Revision:
163:1d4c9d0af1e9
Parent:
152:9a67f0b066fc
fixed i2c-api.c

Who changed what in which revision?

UserRevisionLine numberNew contents of line
<> 152:9a67f0b066fc 1 /* mbed Microcontroller Library
<> 152:9a67f0b066fc 2 * Copyright (c) 2016 ARM Limited
<> 152:9a67f0b066fc 3 *
<> 152:9a67f0b066fc 4 * Licensed under the Apache License, Version 2.0 (the "License");
<> 152:9a67f0b066fc 5 * you may not use this file except in compliance with the License.
<> 152:9a67f0b066fc 6 * You may obtain a copy of the License at
<> 152:9a67f0b066fc 7 *
<> 152:9a67f0b066fc 8 * http://www.apache.org/licenses/LICENSE-2.0
<> 152:9a67f0b066fc 9 *
<> 152:9a67f0b066fc 10 * Unless required by applicable law or agreed to in writing, software
<> 152:9a67f0b066fc 11 * distributed under the License is distributed on an "AS IS" BASIS,
<> 152:9a67f0b066fc 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<> 152:9a67f0b066fc 13 * See the License for the specific language governing permissions and
<> 152:9a67f0b066fc 14 * limitations under the License.
<> 152:9a67f0b066fc 15 */
<> 152:9a67f0b066fc 16
<> 152:9a67f0b066fc 17 #ifndef MBED_EMAC_API_H
<> 152:9a67f0b066fc 18 #define MBED_EMAC_API_H
<> 152:9a67f0b066fc 19
<> 152:9a67f0b066fc 20 #if DEVICE_EMAC
<> 152:9a67f0b066fc 21
<> 152:9a67f0b066fc 22 #include <stdbool.h>
<> 152:9a67f0b066fc 23 #include "emac_stack_mem.h"
<> 152:9a67f0b066fc 24
<> 152:9a67f0b066fc 25 typedef struct emac_interface emac_interface_t;
<> 152:9a67f0b066fc 26
<> 152:9a67f0b066fc 27 /**
<> 152:9a67f0b066fc 28 * EmacInterface
<> 152:9a67f0b066fc 29 *
<> 152:9a67f0b066fc 30 * This interface should be used to abstract low level access to networking hardware
<> 152:9a67f0b066fc 31 */
<> 152:9a67f0b066fc 32
<> 152:9a67f0b066fc 33 /**
<> 152:9a67f0b066fc 34 * Callback to be register with Emac interface and to be called fore received packets
<> 152:9a67f0b066fc 35 *
<> 152:9a67f0b066fc 36 * @param data Arbitrary user data (IP stack)
<> 152:9a67f0b066fc 37 * @param buf Received data
<> 152:9a67f0b066fc 38 */
<> 152:9a67f0b066fc 39 typedef void (*emac_link_input_fn)(void *data, emac_stack_mem_chain_t *buf);
<> 152:9a67f0b066fc 40
<> 152:9a67f0b066fc 41 /**
<> 152:9a67f0b066fc 42 * Callback to be register with Emac interface and to be called for link status changes
<> 152:9a67f0b066fc 43 *
<> 152:9a67f0b066fc 44 * @param data Arbitrary user data (IP stack)
<> 152:9a67f0b066fc 45 * @param up Link status
<> 152:9a67f0b066fc 46 */
<> 152:9a67f0b066fc 47 typedef void (*emac_link_state_change_fn)(void *data, bool up);
<> 152:9a67f0b066fc 48
<> 152:9a67f0b066fc 49 /**
<> 152:9a67f0b066fc 50 * Return maximum transmission unit
<> 152:9a67f0b066fc 51 *
<> 152:9a67f0b066fc 52 * @param emac Emac interface
<> 152:9a67f0b066fc 53 * @return MTU in bytes
<> 152:9a67f0b066fc 54 */
<> 152:9a67f0b066fc 55 typedef uint32_t (*emac_get_mtu_size_fn)(emac_interface_t *emac);
<> 152:9a67f0b066fc 56
<> 152:9a67f0b066fc 57 /**
<> 152:9a67f0b066fc 58 * Return interface name
<> 152:9a67f0b066fc 59 *
<> 152:9a67f0b066fc 60 * @param emac Emac interface
<> 152:9a67f0b066fc 61 * @param name Pointer to where the name should be written
<> 152:9a67f0b066fc 62 * @param size Maximum number of character to copy
<> 152:9a67f0b066fc 63 */
<> 152:9a67f0b066fc 64 typedef void (*emac_get_ifname_fn)(emac_interface_t *emac, char *name, uint8_t size);
<> 152:9a67f0b066fc 65
<> 152:9a67f0b066fc 66 /**
<> 152:9a67f0b066fc 67 * Returns size of the underlying interface HW address size
<> 152:9a67f0b066fc 68 *
<> 152:9a67f0b066fc 69 * @param emac Emac interface
<> 152:9a67f0b066fc 70 * @return HW address size in bytes
<> 152:9a67f0b066fc 71 */
<> 152:9a67f0b066fc 72 typedef uint8_t (*emac_get_hwaddr_size_fn)(emac_interface_t *emac);
<> 152:9a67f0b066fc 73
<> 152:9a67f0b066fc 74 /**
<> 152:9a67f0b066fc 75 * Return interface hw address
<> 152:9a67f0b066fc 76 *
<> 152:9a67f0b066fc 77 * Copies HW address to provided memory, @param addr has to be of correct size see @a get_hwaddr_size
<> 152:9a67f0b066fc 78 *
<> 152:9a67f0b066fc 79 * @param emac Emac interface
<> 152:9a67f0b066fc 80 * @param addr HW address for underlying interface
<> 152:9a67f0b066fc 81 */
<> 152:9a67f0b066fc 82 typedef void (*emac_get_hwaddr_fn)(emac_interface_t *emac, uint8_t *addr);
<> 152:9a67f0b066fc 83
<> 152:9a67f0b066fc 84 /**
<> 152:9a67f0b066fc 85 * Set HW address for interface
<> 152:9a67f0b066fc 86 *
<> 152:9a67f0b066fc 87 * Provided address has to be of correct size, see @a get_hwaddr_size
<> 152:9a67f0b066fc 88 *
<> 152:9a67f0b066fc 89 * @param emac Emac interface
<> 152:9a67f0b066fc 90 * @param addr Address to be set
<> 152:9a67f0b066fc 91 */
<> 152:9a67f0b066fc 92 typedef void (*emac_set_hwaddr_fn)(emac_interface_t *emac, uint8_t *addr);
<> 152:9a67f0b066fc 93
<> 152:9a67f0b066fc 94 /**
<> 152:9a67f0b066fc 95 * Sends the packet over the link
<> 152:9a67f0b066fc 96 *
<> 152:9a67f0b066fc 97 * That can not be called from an interrupt context.
<> 152:9a67f0b066fc 98 *
<> 152:9a67f0b066fc 99 * @param emac Emac interface
<> 152:9a67f0b066fc 100 * @param buf Packet to be send
<> 152:9a67f0b066fc 101 * @return True if the packet was send successfully, False otherwise
<> 152:9a67f0b066fc 102 */
<> 152:9a67f0b066fc 103 typedef bool (*emac_link_out_fn)(emac_interface_t *emac, emac_stack_mem_t *buf);
<> 152:9a67f0b066fc 104
<> 152:9a67f0b066fc 105 /**
<> 152:9a67f0b066fc 106 * Initializes the HW
<> 152:9a67f0b066fc 107 *
<> 152:9a67f0b066fc 108 * @return True on success, False in case of an error.
<> 152:9a67f0b066fc 109 */
<> 152:9a67f0b066fc 110 typedef bool (*emac_power_up_fn)(emac_interface_t *emac);
<> 152:9a67f0b066fc 111
<> 152:9a67f0b066fc 112 /**
<> 152:9a67f0b066fc 113 * Deinitializes the HW
<> 152:9a67f0b066fc 114 *
<> 152:9a67f0b066fc 115 * @param emac Emac interface
<> 152:9a67f0b066fc 116 */
<> 152:9a67f0b066fc 117 typedef void (*emac_power_down_fn)(emac_interface_t *emac);
<> 152:9a67f0b066fc 118
<> 152:9a67f0b066fc 119 /**
<> 152:9a67f0b066fc 120 * Sets a callback that needs to be called for packets received for that interface
<> 152:9a67f0b066fc 121 *
<> 152:9a67f0b066fc 122 * @param emac Emac interface
<> 152:9a67f0b066fc 123 * @param input_cb Function to be register as a callback
<> 152:9a67f0b066fc 124 * @param data Arbitrary user data to be passed to the callback
<> 152:9a67f0b066fc 125 */
<> 152:9a67f0b066fc 126 typedef void (*emac_set_link_input_cb_fn)(emac_interface_t *emac, emac_link_input_fn input_cb, void *data);
<> 152:9a67f0b066fc 127
<> 152:9a67f0b066fc 128 /**
<> 152:9a67f0b066fc 129 * Sets a callback that needs to be called on link status changes for given interface
<> 152:9a67f0b066fc 130 *
<> 152:9a67f0b066fc 131 * @param emac Emac interface
<> 152:9a67f0b066fc 132 * @param state_cb Function to be register as a callback
<> 152:9a67f0b066fc 133 * @param data Arbitrary user data to be passed to the callback
<> 152:9a67f0b066fc 134 */
<> 152:9a67f0b066fc 135 typedef void (*emac_set_link_state_cb_fn)(emac_interface_t *emac, emac_link_state_change_fn state_cb, void *data);
<> 152:9a67f0b066fc 136
<> 152:9a67f0b066fc 137 typedef struct emac_interface_ops {
<> 152:9a67f0b066fc 138 emac_get_mtu_size_fn get_mtu_size;
<> 152:9a67f0b066fc 139 emac_get_ifname_fn get_ifname;
<> 152:9a67f0b066fc 140 emac_get_hwaddr_size_fn get_hwaddr_size;
<> 152:9a67f0b066fc 141 emac_get_hwaddr_fn get_hwaddr;
<> 152:9a67f0b066fc 142 emac_set_hwaddr_fn set_hwaddr;
<> 152:9a67f0b066fc 143 emac_link_out_fn link_out;
<> 152:9a67f0b066fc 144 emac_power_up_fn power_up;
<> 152:9a67f0b066fc 145 emac_power_down_fn power_down;
<> 152:9a67f0b066fc 146 emac_set_link_input_cb_fn set_link_input_cb;
<> 152:9a67f0b066fc 147 emac_set_link_state_cb_fn set_link_state_cb;
<> 152:9a67f0b066fc 148 } emac_interface_ops_t;
<> 152:9a67f0b066fc 149
<> 152:9a67f0b066fc 150 typedef struct emac_interface {
<> 152:9a67f0b066fc 151 const emac_interface_ops_t ops;
<> 152:9a67f0b066fc 152 void *hw;
<> 152:9a67f0b066fc 153 } emac_interface_t;
<> 152:9a67f0b066fc 154
<> 152:9a67f0b066fc 155 #else
<> 152:9a67f0b066fc 156
<> 152:9a67f0b066fc 157 typedef void *emac_interface_t;
<> 152:9a67f0b066fc 158
<> 152:9a67f0b066fc 159 #endif /* DEVICE_EMAC */
<> 152:9a67f0b066fc 160 #endif /* MBED_EMAC_API_H */