Axeda Ready Demo for Freescale FRDM-KL46Z as accident alert system

Dependencies:   FRDM_MMA8451Q KL46Z-USBHost MAG3110 SocketModem TSI mbed FATFileSystem

Fork of AxedaGo-Freescal_FRDM-KL46Z by Axeda Corp

Committer:
AxedaCorp
Date:
Wed Jul 02 19:57:37 2014 +0000
Revision:
2:2f9019c5a9fc
Parent:
0:65004368569c
ip switch

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AxedaCorp 0:65004368569c 1 /* mbed USBHost Library
AxedaCorp 0:65004368569c 2 * Copyright (c) 2006-2013 ARM Limited
AxedaCorp 0:65004368569c 3 *
AxedaCorp 0:65004368569c 4 * Licensed under the Apache License, Version 2.0 (the "License");
AxedaCorp 0:65004368569c 5 * you may not use this file except in compliance with the License.
AxedaCorp 0:65004368569c 6 * You may obtain a copy of the License at
AxedaCorp 0:65004368569c 7 *
AxedaCorp 0:65004368569c 8 * http://www.apache.org/licenses/LICENSE-2.0
AxedaCorp 0:65004368569c 9 *
AxedaCorp 0:65004368569c 10 * Unless required by applicable law or agreed to in writing, software
AxedaCorp 0:65004368569c 11 * distributed under the License is distributed on an "AS IS" BASIS,
AxedaCorp 0:65004368569c 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
AxedaCorp 0:65004368569c 13 * See the License for the specific language governing permissions and
AxedaCorp 0:65004368569c 14 * limitations under the License.
AxedaCorp 0:65004368569c 15 */
AxedaCorp 0:65004368569c 16 #pragma once
AxedaCorp 0:65004368569c 17
AxedaCorp 0:65004368569c 18 #include "USBEndpoint.h"
AxedaCorp 0:65004368569c 19 #include "USBHostConf.h"
AxedaCorp 0:65004368569c 20
AxedaCorp 0:65004368569c 21 class USBEndpoint;
AxedaCorp 0:65004368569c 22
AxedaCorp 0:65004368569c 23 typedef struct {
AxedaCorp 0:65004368569c 24 bool in_use;
AxedaCorp 0:65004368569c 25 uint8_t nb_endpoint;
AxedaCorp 0:65004368569c 26 uint8_t intf_class;
AxedaCorp 0:65004368569c 27 uint8_t intf_subclass;
AxedaCorp 0:65004368569c 28 uint8_t intf_protocol;
AxedaCorp 0:65004368569c 29 USBEndpoint * ep[MAX_ENDPOINT_PER_INTERFACE];
AxedaCorp 0:65004368569c 30 //FunctionPointer detach;
AxedaCorp 0:65004368569c 31 //char name[10];
AxedaCorp 0:65004368569c 32 } INTERFACE;
AxedaCorp 0:65004368569c 33
AxedaCorp 0:65004368569c 34 /**
AxedaCorp 0:65004368569c 35 * USBDeviceConnected class
AxedaCorp 0:65004368569c 36 */
AxedaCorp 0:65004368569c 37 class USBDeviceConnected {
AxedaCorp 0:65004368569c 38 public:
AxedaCorp 0:65004368569c 39
AxedaCorp 0:65004368569c 40 /**
AxedaCorp 0:65004368569c 41 * Constructor
AxedaCorp 0:65004368569c 42 */
AxedaCorp 0:65004368569c 43 USBDeviceConnected();
AxedaCorp 0:65004368569c 44
AxedaCorp 0:65004368569c 45 /**
AxedaCorp 0:65004368569c 46 * Attach an USBEndpoint to this device
AxedaCorp 0:65004368569c 47 *
AxedaCorp 0:65004368569c 48 * @param intf_nb interface number
AxedaCorp 0:65004368569c 49 * @param ep pointeur on the USBEndpoint which will be attached
AxedaCorp 0:65004368569c 50 * @returns true if successful, false otherwise
AxedaCorp 0:65004368569c 51 */
AxedaCorp 0:65004368569c 52 bool addEndpoint(uint8_t intf_nb, USBEndpoint * ep);
AxedaCorp 0:65004368569c 53
AxedaCorp 0:65004368569c 54 /**
AxedaCorp 0:65004368569c 55 * Retrieve an USBEndpoint by its TYPE and DIRECTION
AxedaCorp 0:65004368569c 56 *
AxedaCorp 0:65004368569c 57 * @param intf_nb the interface on which to lookup the USBEndpoint
AxedaCorp 0:65004368569c 58 * @param type type of the USBEndpoint looked for
AxedaCorp 0:65004368569c 59 * @param dir direction of the USBEndpoint looked for
AxedaCorp 0:65004368569c 60 * @param index the index of the USBEndpoint whitin the interface
AxedaCorp 0:65004368569c 61 * @returns pointer on the USBEndpoint if found, NULL otherwise
AxedaCorp 0:65004368569c 62 */
AxedaCorp 0:65004368569c 63 USBEndpoint * getEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir, uint8_t index = 0);
AxedaCorp 0:65004368569c 64
AxedaCorp 0:65004368569c 65 /**
AxedaCorp 0:65004368569c 66 * Retrieve an USBEndpoint by its index
AxedaCorp 0:65004368569c 67 *
AxedaCorp 0:65004368569c 68 * @param intf_nb interface number
AxedaCorp 0:65004368569c 69 * @param index index of the USBEndpoint
AxedaCorp 0:65004368569c 70 * @returns pointer on the USBEndpoint if found, NULL otherwise
AxedaCorp 0:65004368569c 71 */
AxedaCorp 0:65004368569c 72 USBEndpoint * getEndpoint(uint8_t intf_nb, uint8_t index);
AxedaCorp 0:65004368569c 73
AxedaCorp 0:65004368569c 74 /**
AxedaCorp 0:65004368569c 75 * Add a new interface to this device
AxedaCorp 0:65004368569c 76 *
AxedaCorp 0:65004368569c 77 * @param intf_nb interface number
AxedaCorp 0:65004368569c 78 * @param intf_class interface class
AxedaCorp 0:65004368569c 79 * @param intf_subclass interface subclass
AxedaCorp 0:65004368569c 80 * @param intf_protocol interface protocol
AxedaCorp 0:65004368569c 81 * @returns true if successful, false otherwise
AxedaCorp 0:65004368569c 82 */
AxedaCorp 0:65004368569c 83 bool addInterface(uint8_t intf_nb, uint8_t intf_class, uint8_t intf_subclass, uint8_t intf_protocol);
AxedaCorp 0:65004368569c 84
AxedaCorp 0:65004368569c 85 /**
AxedaCorp 0:65004368569c 86 * Get a specific interface
AxedaCorp 0:65004368569c 87 *
AxedaCorp 0:65004368569c 88 * @param index index of the interface to be fetched
AxedaCorp 0:65004368569c 89 * @returns interface
AxedaCorp 0:65004368569c 90 */
AxedaCorp 0:65004368569c 91 INTERFACE * getInterface(uint8_t index);
AxedaCorp 0:65004368569c 92
AxedaCorp 0:65004368569c 93 /**
AxedaCorp 0:65004368569c 94 * Disconnect the device by calling a callback function registered by a driver
AxedaCorp 0:65004368569c 95 */
AxedaCorp 0:65004368569c 96 void disconnect();
AxedaCorp 0:65004368569c 97
AxedaCorp 0:65004368569c 98 void init(uint8_t hub, uint8_t _port, bool _lowSpeed);
AxedaCorp 0:65004368569c 99 void setAddress(uint8_t addr_) { addr = addr_; };
AxedaCorp 0:65004368569c 100 void setVid(uint16_t vid_) { vid = vid_; };
AxedaCorp 0:65004368569c 101 void setPid(uint16_t pid_) { pid = pid_; };
AxedaCorp 0:65004368569c 102 void setClass(uint8_t device_class_) { device_class = device_class_; }
AxedaCorp 0:65004368569c 103 void setSubClass(uint8_t device_subclass_) { device_subclass = device_subclass_; };
AxedaCorp 0:65004368569c 104 void setProtocol(uint8_t pr) { proto = pr; };
AxedaCorp 0:65004368569c 105 void setEnumerated() { enumerated = true; };
AxedaCorp 0:65004368569c 106 void setNbIntf(uint8_t nb_intf) {nb_interf = nb_intf; };
AxedaCorp 0:65004368569c 107 void setSpeed(bool _lowSpeed) { lowSpeed = _lowSpeed; }
AxedaCorp 0:65004368569c 108 void setName(const char * name_, uint8_t intf_nb) { return; };
AxedaCorp 0:65004368569c 109 void setEpCtl(USBEndpoint* ep) { ep_ctl = ep; }
AxedaCorp 0:65004368569c 110
AxedaCorp 0:65004368569c 111 static int getNewAddress() {
AxedaCorp 0:65004368569c 112 static int addr = 1;
AxedaCorp 0:65004368569c 113 return addr++;
AxedaCorp 0:65004368569c 114 }
AxedaCorp 0:65004368569c 115 uint8_t getHub() { return hub_nb; };
AxedaCorp 0:65004368569c 116 uint8_t getAddress() { return addr; };
AxedaCorp 0:65004368569c 117 uint16_t getVid() { return vid; };
AxedaCorp 0:65004368569c 118 uint16_t getPid() { return pid; };
AxedaCorp 0:65004368569c 119 uint8_t getClass() { return device_class; };
AxedaCorp 0:65004368569c 120 bool getSpeed() { return lowSpeed; }
AxedaCorp 0:65004368569c 121 bool isEnumerated() { return enumerated; };
AxedaCorp 0:65004368569c 122 USBEndpoint* getEpCtl() { return ep_ctl; }
AxedaCorp 0:65004368569c 123
AxedaCorp 0:65004368569c 124 private:
AxedaCorp 0:65004368569c 125 INTERFACE intf[MAX_INTF];
AxedaCorp 0:65004368569c 126 uint8_t hub_nb;
AxedaCorp 0:65004368569c 127 uint8_t port;
AxedaCorp 0:65004368569c 128 uint16_t vid;
AxedaCorp 0:65004368569c 129 uint16_t pid;
AxedaCorp 0:65004368569c 130 uint8_t addr;
AxedaCorp 0:65004368569c 131 uint8_t device_class;
AxedaCorp 0:65004368569c 132 uint8_t device_subclass;
AxedaCorp 0:65004368569c 133 uint8_t proto;
AxedaCorp 0:65004368569c 134 bool lowSpeed;
AxedaCorp 0:65004368569c 135 bool enumerated;
AxedaCorp 0:65004368569c 136 uint8_t nb_interf;
AxedaCorp 0:65004368569c 137 USBEndpoint* ep_ctl;
AxedaCorp 0:65004368569c 138 void init();
AxedaCorp 0:65004368569c 139 };