Ignore:
Timestamp:
Apr 30, 2016, 11:29:25 PM (8 years ago)
Author:
ertl-honda
Message:

1.7.10のファイルに更新

File:
1 edited

Legend:

Unmodified
Added
Removed
  • rtos_arduino/trunk/arduino_lib/hardware/arduino/samd/cores/arduino/USB/USBAPI.h

    r136 r224  
    11/*
    2   Copyright (c) 2012 Arduino.  All right reserved.
     2  Copyright (c) 2015 Arduino LLC.  All right reserved.
    33
    44  This library is free software; you can redistribute it and/or
     
    1616  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    1717*/
    18 
    19 #ifndef __USBAPI__
    20 #define __USBAPI__
    21 
    22 
    23 /* Define attribute */
    24 #if defined   ( __CC_ARM   ) /* Keil uVision 4 */
    25     #define WEAK (__attribute__ ((weak)))
    26 #elif defined ( __ICCARM__ ) /* IAR Ewarm 5.41+ */
    27     #define WEAK __weak
    28 #elif defined (  __GNUC__  ) /* GCC CS */
    29     #define WEAK __attribute__ ((weak))
    30 #endif
    31 
     18/*
     19**Modified 04/04/2016 by Arduino.org development team
     20*/
     21
     22#pragma once
     23
     24#define WEAK __attribute__ ((weak))
     25
     26#define HSTPIPCFG_PTYPE_BLK 1
     27#define HSTPIPCFG_PTOKEN_IN 2
     28#define HSTPIPCFG_PTOKEN_OUT 3
     29#define HSTPIPCFG_PBK_1_BANK 4
     30#define HSTPIPCFG_PTYPE_INTRPT 5
     31
     32#define EP0      0
     33#define EPX_SIZE 64 // 64 for Full Speed, EPT size max is 1024
    3234
    3335#if defined __cplusplus
     
    3739
    3840//================================================================================
    39 //================================================================================
    40 //      USB
    41 
    42 class USBDevice_
    43 {
    44 public:
    45         USBDevice_();
     41// USB
     42//================================================================================
     43//================================================================================
     44// Low level API
     45typedef struct {
     46        union {
     47                uint8_t bmRequestType;
     48                struct {
     49                        uint8_t direction : 5;
     50                        uint8_t type : 2;
     51                        uint8_t transferDirection : 1;
     52                };
     53        };
     54        uint8_t bRequest;
     55        uint8_t wValueL;
     56        uint8_t wValueH;
     57        uint16_t wIndex;
     58        uint16_t wLength;
     59} Setup;
     60
     61
     62class USBDevice_ {
     63public:
     64        USBDevice_() {};
     65
     66        // USB Device API
     67        void init();
     68        bool attach();  // Serial port goes down too...
     69        bool detach();
     70
    4671        bool configured();
    4772
    48         bool attach();
    49         bool detach();  // Serial port goes down too...
    50         void poll();
    51         void init();
    52 };
     73private:
     74        bool initialized;
     75};
     76
    5377extern USBDevice_ USBDevice;
    5478
    5579//================================================================================
    56 //================================================================================
    5780//      Serial over CDC (Serial1 is the physical port)
    5881
    5982class Serial_ : public Stream
    6083{
    61 private:
    62         RingBuffer *_cdc_rx_buffer;
    63 public:
     84public:
     85        Serial_(USBDevice_ &_usb) : usb(_usb) { }
    6486        void begin(uint32_t baud_count);
    6587        void begin(unsigned long, uint8_t);
     
    7597        using Print::write; // pull in write(str) from Print
    7698        operator bool();
     99
     100        // This method allows processing "SEND_BREAK" requests sent by
     101        // the USB host. Those requests indicate that the host wants to
     102        // send a BREAK signal and are accompanied by a single uint16_t
     103        // value, specifying the duration of the break. The value 0
     104        // means to end any current break, while the value 0xffff means
     105        // to start an indefinite break.
     106        // readBreak() will return the value of the most recent break
     107        // request, but will return it at most once, returning -1 when
     108        // readBreak() is called again (until another break request is
     109        // received, which is again returned once).
     110        // This also mean that if two break requests are received
     111        // without readBreak() being called in between, the value of the
     112        // first request is lost.
     113        // Note that the value returned is a long, so it can return
     114        // 0-0xffff as well as -1.
     115        int32_t readBreak();
     116
     117        // These return the settings specified by the USB host for the
     118        // serial port. These aren't really used, but are offered here
     119        // in case a sketch wants to act on these settings.
     120        uint32_t baud();
     121        uint8_t stopbits();
     122        uint8_t paritytype();
     123        uint8_t numbits();
     124        bool dtr();
     125        bool rts();
     126        enum {
     127                ONE_STOP_BIT = 0,
     128                ONE_AND_HALF_STOP_BIT = 1,
     129                TWO_STOP_BITS = 2,
     130        };
     131        enum {
     132                NO_PARITY = 0,
     133                ODD_PARITY = 1,
     134                EVEN_PARITY = 2,
     135                MARK_PARITY = 3,
     136                SPACE_PARITY = 4,
     137        };
     138
     139private:
     140        USBDevice_ &usb;
     141        RingBuffer *_cdc_rx_buffer;
    77142};
    78143extern Serial_ SerialUSB;
     
    171236//================================================================================
    172237//================================================================================
    173 //      Low level API
    174 
    175 typedef struct
    176 {
    177         uint8_t bmRequestType;
    178         uint8_t bRequest;
    179         uint8_t wValueL;
    180         uint8_t wValueH;
    181         uint16_t wIndex;
    182         uint16_t wLength;
    183         uint8_t data[8];
    184 } Setup;
    185 
    186 //================================================================================
    187 //================================================================================
    188238//      HID 'Driver'
    189239
     
    202252uint32_t                MSC_GetInterface(uint8_t* interfaceNum);
    203253uint32_t                MSC_GetDescriptor(uint32_t i);
    204 bool    MSC_Setup(Setup& setup);
     254bool    MSC_Setup(Setup& pSetup);
    205255bool    MSC_Data(uint8_t rx,uint8_t tx);
    206256
     
    209259//      CDC 'Driver'
    210260
    211 const void* CDC_GetInterface(/*uint8_t* interfaceNum*/);
    212 uint32_t WEAK CDC_GetInterfaceLength(void);
     261int CDC_GetInterface(uint8_t* interfaceNum);
     262const void* _CDC_GetInterface(void);
     263uint32_t _CDC_GetInterfaceLength(void);
    213264uint32_t                CDC_GetOtherInterface(uint8_t* interfaceNum);
    214265uint32_t                CDC_GetDescriptor(uint32_t i);
    215 bool    CDC_Setup(Setup& setup);
    216 
    217 //================================================================================
    218 //================================================================================
    219 
    220 uint32_t USBD_SendControl(uint8_t flags, const void* d, uint32_t len);
     266bool    CDC_Setup(Setup& pSetup);
     267
     268
     269//================================================================================
     270//================================================================================
     271
     272uint32_t USBD_SendControl(const void* _data, uint32_t len);
    221273uint32_t USBD_RecvControl(void* d, uint32_t len);
     274void USBD_Calibrate();
    222275uint32_t USBD_SendInterfaces(void);
    223276bool USBD_ClassInterfaceRequest(Setup& setup);
     
    228281uint32_t USBD_Recv(uint32_t ep, void* data, uint32_t len);              // non-blocking
    229282uint32_t USBD_Recv(uint32_t ep);                                                        // non-blocking
     283uint8_t USBD_armRecv(uint32_t ep);
    230284void USBD_Flush(uint32_t ep);
    231285uint32_t USBD_Connected(void);
    232286
    233287#endif  // __cplusplus
    234 #endif  // __USBAPI__
Note: See TracChangeset for help on using the changeset viewer.