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 revert by Axeda Corp

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers USBEndpoint.h Source File

USBEndpoint.h

00001 /* mbed USBHost Library
00002  * Copyright (c) 2006-2013 ARM Limited
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016  
00017 #pragma once
00018 #include "USBHostTypes.h"
00019 #include "USBDeviceConnected.h"
00020 class USBDeviceConnected;
00021 
00022 class USBEndpoint {
00023 public:
00024     USBEndpoint() : data01_toggle(DATA0),address(0),MaxPacketSize(8) {
00025         dev = NULL;
00026     }
00027     void setDevice(USBDeviceConnected* _dev) { dev = _dev; }
00028     void setState(uint8_t st){}; // dummy
00029     void setLengthTransferred(int len) { transferred = len; };
00030     void setSize(int size) { MaxPacketSize = size; }
00031     void setType(ENDPOINT_TYPE _type) { type = _type; };
00032     void setAddress(uint8_t addr) { address = addr; }
00033     void setData01(uint8_t data01) { data01_toggle = data01; }
00034 
00035     USBDeviceConnected* getDevice() { return dev; }
00036     ENDPOINT_TYPE getType() { return type; };
00037     int getLengthTransferred() { return transferred; }
00038     uint8_t getAddress(){ return address; };
00039     int getSize() { return MaxPacketSize; }
00040     ENDPOINT_DIRECTION getDir() { return (address & 0x80) ? IN : OUT; }
00041     uint8_t getData01() { return data01_toggle; }
00042     void toggleData01() {
00043         data01_toggle = (data01_toggle == DATA0) ? DATA1 : DATA0;
00044     }
00045 
00046 private:
00047     ENDPOINT_TYPE type;
00048     ENDPOINT_DIRECTION dir;
00049     USBDeviceConnected* dev;
00050     uint8_t data01_toggle; // DATA0,DATA1
00051     uint8_t address;
00052     int transferred;
00053     int MaxPacketSize;
00054 };