5.2.1 - Updated I2C files

Dependents:   mbed-TFT-example-NCS36510 mbed-Accelerometer-example-NCS36510 mbed-Accelerometer-example-NCS36510

Committer:
jacobjohnson
Date:
Mon Feb 27 17:45:05 2017 +0000
Revision:
1:f30bdcd2b33b
Parent:
0:098463de4c5d
changed the inputscale from 1 to 7 in analogin_api.c.  This will need to be changed later, and accessed from the main level, but for now this allows the  adc to read a value from 0 to 3.7V, instead of just up to 1V.;

Who changed what in which revision?

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