久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 6812|回復: 1
打印 上一主題 下一主題
收起左側

分享arduino的多線程SCoop庫及例程

[復制鏈接]
跳轉到指定樓層
樓主
要一個一個的安裝,否則有可能arduino發現不了


SCoop庫的arduino源程序如下:
  1. /*****************************************************************************/
  2. /* SCOOP LIBRARY / AUTHOR FABRICE OUDERT / GNU GPL V3                        */
  3. /* https://code.google.com/p/arduino-scoop-cooperative-scheduler-arm-avr/    */
  4. /* VERSION 1.2  NEW YEAR PACK 10/1/2013                                      */
  5. /* ENJOY AND USE AT YOUR OWN RISK  :)                                        */
  6. /* SHOULD READ USER GUIDE FIRST (@\_/@)                                      */
  7. /*****************************************************************************/


  8. #include "SCoop.h"
  9. #define SCINM SCoopInstanceNickName


  10. /********* GLOBAL VARIABLE *******/

  11. SCoopEvent*   SCoopFirstItem = NULL;           // has to be initialized here. hold a pointer on the whole list of task/event/timer...
  12. SCoopEvent*   SCoopFirstTaskItem = NULL;       // has to be initialized here. points to the first of all tasks registered in the list
  13. uint8_t       SCoopNumberTask = 0;             // hold the number of task registered. used to calculate quantum in start(xxx)


  14. SCoop  SCoopInstanceNickName;                  // then we can use the library in the main sketch directly
  15. #define SCINM SCoopInstanceNickName            // just a local nickname...
  16. #if SCoopANDROIDMODE >= 1
  17. SCoop& ArduinoSchedulerNickName = SCINM;       // this will create another identifier for the same object instance
  18. #endif

  19. /********* ASSEMBLY / LETS GET STARTED WITH THE COMPLEX THINGS **********/
  20. // original idea for switching stack pointer taken out from ChibiOS.
  21. // Credit to the author. now slightly modified.
  22. // http://forum.pjrc.com/threads/540-ChibiOS-RTand-FreeRTOS-for-Teensy-3-0
  23. //
  24. // original idea for micros() optimization taken from CORE_TEENSY
  25. // credit to Paul http://www.pjrc.com/teensy/
  26. //************************************************************************/

  27. #if defined(SCoop_ARM) && (SCoop_ARM == 1)

  28. static void SCoopSwitch(uint8_t **newSP, uint8_t **oldSP) __attribute__((naked,noinline)) ;
  29. static void SCoopSwitch(uint8_t **newSP, uint8_t **oldSP)
  30. { asm volatile ("push    {r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, lr}" : : : "memory");
  31.   asm volatile ("str     sp, [%[oldsp], #0]  \n\t"
  32.                 "ldr     sp, [%[newsp], #0]" : : [newsp] "r" (newSP), [oldsp] "r" (oldSP));
  33.   asm volatile ("pop     {r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, pc}" : : : "memory");
  34. };

  35. static inline uint32_t SCoopGetSP() __attribute__ ((always_inline)) ;
  36. uint32_t SCoopGetSP() { register uint32_t val; asm ("mov     %[temp],sp" : [temp] "=r" (val)); return val; }

  37. #define ARM_ATOMIC ASM_ATOMIC
  38. #define AVR_ATOMIC

  39. #define SCoopMicros()   ((micros_t)micros())     // overloading the standard micros()

  40. #endif

  41. #if defined(SCoop_AVR) && (SCoop_AVR == 1)

  42. static void SCoopSwitch(void *newSP, void *oldSP) __attribute__((naked,noinline));
  43. static void SCoopSwitch(void *newSP, void *oldSP)
  44. { asm volatile ("push r2  \n\t push r3  \n\t push r4  \n\t push r5  \n\t push r6  \n\t push r7  \n\t push r8  \n\t push r9  \n\t push r10 \n\t"
  45.                 "push r11 \n\t push r12 \n\t push r13 \n\t push r14 \n\t push r15 \n\t push r16 \n\t push r17 \n\t push r28 \n\t push r29");
  46.   
  47.   asm volatile ("movw    r28, %[oldsp]" : : [oldsp] "r" (oldSP));
  48.   asm volatile ("in      r2, 0x3d"); // SPL
  49.   asm volatile ("in      r3, 0x3e"); // SPH
  50.   asm volatile ("std     Y+0, r2");  // store the current SP into the pointer oldSP
  51.   asm volatile ("std     Y+1, r3");

  52.   asm volatile ("movw    r28, %[newsp]" : : [newsp] "r" (newSP));
  53.   asm volatile ("ldd     r2, Y+0");  // restore the SP from the pointer newSP
  54.   asm volatile ("ldd     r3, Y+1");
  55.   asm volatile ("in      r4, 0x3f"); // save SREG
  56.   asm volatile ("cli             "); // just to be safe on playing with stack ptr :) (useless with xmega)
  57.   asm volatile ("out     0x3e, r3"); // SPH
  58.   asm volatile ("out     0x3d, r2"); // SPL
  59.   asm volatile ("out     0x3f, r4"); // restore SREG asap (same approach as in setjmp.S credit to Marek Michalkiewicz)
  60.   
  61.   asm volatile ("pop r29 \n\t pop r28 \n\t pop r17 \n\t pop r16 \n\t pop r15 \n\t pop r14 \n\t pop r13 \n\t pop r12 \n\t pop r11 \n\t"
  62.                 "pop r10 \n\t pop r9  \n\t pop r8  \n\t pop r7  \n\t pop r6  \n\t pop r5  \n\t pop r4  \n\t pop r3  \n\t pop r2");
  63.   asm volatile ("ret");  };

  64. #define SCoopGetSP() (uint16_t)SP              // direct read access to SP register is possible

  65. #define AVR_ATOMIC for ( uint8_t sreg_save __attribute__((__cleanup__(__iRestore))) = SREG, __ToDo = __iCliRetVal() ; __ToDo ;  __ToDo = 0 )
  66. static inline void __iRestore(const  uint8_t *__s) { SREG = *__s; asm volatile ("" ::: "memory"); }
  67. static inline uint8_t __iCliRetVal(void) { noInterrupts(); return 1; }

  68. #define ARM_ATOMIC

  69. /******** NEW MICROS METHOD BASED ON CORE_TEENSY / LIMITED TO 16 BITS **********/
  70. /* Copyright (c) 2008-2010 PJRC.COM, LLC
  71. * for the Teensy and Teensy++
  72. * http://www.pjrc.com/teensy/
  73. *
  74. * Permission is hereby granted, free of charge, to any person obtaining a copy
  75. * of this software and associated documentation files (the "Software"), to deal
  76. * in the Software without restriction, including without limitation the rights
  77. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  78. * copies of the Software, and to permit persons to whom the Software is
  79. * furnished to do so, subject to the following conditions:
  80. *
  81. * The above copyright notice and this permission notice shall be included in
  82. * all copies or substantial portions of the Software.
  83. *
  84. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  85. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  86. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  87. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  88. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  89. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  90. * THE SOFTWARE.
  91. */

  92. #if F_CPU == 16000000L
  93.   #define TIMER0_MICROS_INC          4
  94. #elif F_CPU == 8000000L
  95.   #define TIMER0_MICROS_INC          8
  96. #elif F_CPU == 4000000L
  97.   #define TIMER0_MICROS_INC          16
  98. #elif F_CPU == 2000000L
  99.   #define TIMER0_MICROS_INC          32
  100. #elif F_CPU == 1000000L
  101.   #define TIMER0_MICROS_INC          64
  102. #else
  103. #define SCoopMicros()   ((micros_t)micros())     // using the standard micros()
  104. #warning "CPU Frequence not supported by the new micros() function"
  105. #endif

  106. #if defined(CORE_TEENSY)
  107. extern volatile unsigned long timer0_micros_count;   // this variable is incremented by timer 0 overflow
  108. static inline micros_t SCoopMicros16(void) __attribute__((always_inline));
  109. static inline micros_t SCoopMicros16(void) // same as standrad PJRC micros, but in 16 bits and with inlining
  110. {        register micros_t out;
  111.         asm volatile(
  112.                 "in        __tmp_reg__, __SREG__"                        "\n\t"
  113.                 "cli"                                                                "\n\t"
  114.                 "in        %A0, %2"                                                "\n\t"
  115.                 "in        __zero_reg__, %3"                                "\n\t"
  116.                 "lds        %B0, timer0_micros_count"        "\n\t"
  117.                 "out        __SREG__, __tmp_reg__"                "\n\t"
  118.                 "sbrs        __zero_reg__, %4"                        "\n\t"
  119.                 "rjmp        L_%=_skip"                                        "\n\t"
  120.                 "cpi        %A0, 255"                                        "\n\t"
  121.                 "breq        L_%=_skip"                                        "\n\t"
  122.                 "subi        %B0, 256 - %1"                                "\n\t"
  123.         "L_%=_skip:"                                                        "\n\t"
  124.                 "clr        __zero_reg__"                                "\n\t"
  125.                 "clr        __tmp_reg__"                                "\n\t"
  126. #if F_CPU == 16000000L || F_CPU == 8000000L || F_CPU == 4000000L
  127.                 "lsl        %A0"                                                "\n\t"
  128.                 "rol        __tmp_reg__"                                "\n\t"
  129.                 "lsl        %A0"                                                "\n\t"
  130.                 "rol        __tmp_reg__"                                "\n\t"
  131. #if F_CPU == 8000000L || F_CPU == 4000000L
  132.                 "lsl        %A0"                                                "\n\t"
  133.                 "rol        __tmp_reg__"                                "\n\t"
  134. #endif
  135. #if F_CPU == 4000000L
  136.                 "lsl        %A0"                                                "\n\t"
  137.                 "rol        __tmp_reg__"                                "\n\t"
  138. #endif
  139.                 "or        %B0, __tmp_reg__"                                "\n\t"
  140. #endif
  141. #if F_CPU == 1000000L || F_CPU == 2000000L
  142.                 "lsr        %A0"                                                "\n\t"
  143.                 "ror        __tmp_reg__"                                "\n\t"
  144.                 "lsr        %A0"                                                "\n\t"
  145.                 "ror        __tmp_reg__"                                "\n\t"
  146. #if F_CPU == 2000000L
  147.                 "lsr        %A0"                                                "\n\t"
  148.                 "ror        __tmp_reg__"                                "\n\t"
  149. #endif
  150.                 "or        %B0, %A0"                                                "\n\t"
  151.                 "mov        %A0, __tmp_reg__"                        "\n\t"
  152. #endif
  153.                 : "=r" (out)
  154.                 : "M" (TIMER0_MICROS_INC),
  155.                   "I" (_SFR_IO_ADDR(TCNT0)),
  156.                   "I" (_SFR_IO_ADDR(TIFR0)),
  157.                   "I" (TOV0) : "r0" ); return out; }
  158. #define SCoopMicros()   (SCoopMicros16())     // overloading the standard micros()
  159.                   
  160. #else // end of CORE_TEENSY. Now same job for the Arduino wiring.c library
  161. extern volatile unsigned long timer0_overflow_count; // use this variable which is incremented at each overflow
  162. static inline micros_t SCoopMicros16(void) __attribute__((always_inline));
  163. static inline micros_t SCoopMicros16(void) // same as standrad PJRC micros, but in 16 bits and with inlining
  164. {        register micros_t out ;
  165.         asm volatile(
  166.                 "in        __tmp_reg__, __SREG__"                        "\n\t"
  167.                 "cli"                                                                "\n\t"
  168.                 "in        %A0, %2"                                                "\n\t"
  169.                 "in        __zero_reg__, %3"                                "\n\t"
  170.                 "lds        %B0, timer0_overflow_count"        "\n\t"
  171.                 "out        __SREG__, __tmp_reg__"                "\n\t"
  172.                 "sbrs        __zero_reg__, %4"                        "\n\t"
  173.                 "rjmp        L_%=_skip"                                        "\n\t"
  174.                 "cpi        %A0, 255"                                        "\n\t"
  175.                 "breq        L_%=_skip"                                        "\n\t"
  176. #if F_CPU == 16000000L
  177.                 "subi        %B0, 1"                                                "\n\t"
  178. #elif F_CPU == 8000000L
  179.                 "subi        %B0, 2"                                                "\n\t"
  180. #endif               
  181.         "L_%=_skip:"                                                        "\n\t"
  182.                 "clr        __zero_reg__"                                "\n\t"
  183.                 "clr        __tmp_reg__"                                "\n\t"
  184. #if F_CPU == 16000000L || F_CPU == 8000000L
  185.                 "lsl        %B0"                                                "\n\t"
  186.                 "lsl        %B0"                                                "\n\t"
  187.                 "lsl        %A0"                                                "\n\t"
  188.                 "rol        __tmp_reg__"                                "\n\t"
  189.                 "lsl        %A0"                                                "\n\t"
  190.                 "rol        __tmp_reg__"                                "\n\t"
  191. #if F_CPU == 8000000L
  192.                 "lsl        %B0"                                                "\n\t"
  193.                 "lsl        %A0"                                                "\n\t"
  194.                 "rol        __tmp_reg__"                                "\n\t"
  195. #endif
  196.                 "or        %B0, __tmp_reg__"                                "\n\t"
  197. #endif
  198.                 : "=r" (out)
  199.                 : "M" (TIMER0_MICROS_INC),
  200.                   "I" (_SFR_IO_ADDR(TCNT0)),
  201.                   "I" (_SFR_IO_ADDR(TIFR0)),
  202.                   "I" (TOV0)
  203.                 : "r0" ); return out; }
  204. #define SCoopMicros()   (SCoopMicros16())     // overloading the standard micros()
  205. #endif // core_teensy

  206. #endif

  207. /********* SCOOPEVENT METHODS *******/

  208. SCoopEvent::SCoopEvent()
  209. { init(NULL);                                  // initialize specific object variable
  210.   registerThis(SCoopEventType); }              // add to list and set state to Constructed
  211.          

  212.   void SCoopEvent::registerThis(uint8_t type)
  213. { pNext = SCoopFirstItem;                      // memorize the latest item registered
  214.   SCoopFirstItem = this;                       // point the latest item to this one
  215.   itemType = type;                             // just to memorize the object type, as we use polymorphism
  216.   state = SCoopCONSTRUCTED; }                  // we are in the list and ready for a formal "init", either in the skecth or as a constructor extension
  217.    

  218. SCoopEvent::SCoopEvent(SCoopFunc_t func)
  219. { init(func);
  220.   registerThis(SCoopEventType); }
  221.   
  222. SCoopEvent::~SCoopEvent()                      // destructor : remove item from the list
  223. { unregisterThis();
  224. if (SCoopFirstTaskItem == this) SCoopFirstTaskItem = pNext; // we do not need to change this if this is not the first task
  225. // below section should be in Task Destructor, but didnt work there, probleme with chaining... so I put it here...
  226. if ((itemType == SCoopDynamicTask) || (itemType == SCoopTaskType)) {
  227.     SCINM.targetCycleMicros -= reinterpret_cast<SCoopTask*>(this)->quantumMicros; // reduce target cycle time
  228.         SCoopNumberTask--;       
  229. #if SCoopYIELDCYCLE == 0       
  230.         if (SCoopNumberTask>0) { SCINM.quantumMicrosReal = quantumMicros / SCoopNumberTask; }
  231. #endif       
  232. #if SCoopANDROIDMODE >=2
  233. if (itemType == SCoopDynamicTask)  {
  234.    free(reinterpret_cast<SCoopTask*>(this)->pStackAddr); }
  235. #endif
  236.         }
  237. }                          // remove from list
  238.   
  239. void SCoopEvent::unregisterThis()              // remove item from SCoop list (needed for local objects)
  240. {SCoopEvent * ptr = SCoopFirstItem;            // lets try first one
  241.   if (ptr == this) SCoopFirstItem = ptr->pNext;// if this item is the last one registered
  242.   else
  243.   do { if (ptr->pNext==this) {                 // if the next is the one to remove
  244.            ptr->pNext = ptr->pNext->pNext;     // skip it
  245.            break; } }                          // we are done
  246.   while ((ptr=ptr->pNext));                    // try next item until we find the end of the list (NULL)
  247.   state = SCoopTERMINATED;
  248.   };

  249. void SCoopEvent::init(SCoopFunc_t func)        // called by constructor, after registration
  250. { userFunc = func;                             // hook call for the "run", if not overriden by a virtual void in child object
  251.   if (func != NULL) state = SCoopNEW;          // this object is ready to get started or even launched (as launch() also call start())
  252. };


  253. void SCoopEvent::start() {                     // launched by scheduler when calling SCINM.start()
  254.   ifSCoopTRACE(2,"Event::start");
  255.   if (state >= SCoopNEW) {
  256.      setup();                                  // call the setup function, and do something only if a derived object has been created with this method.
  257.      state = SCoopRUNNABLE; };                       
  258. }


  259. bool SCoopEvent::launch() {                    // launch or switch into this item or derived
  260. //ifSCoopTRACE(2,"Event::launch");             // removed. too much printing !

  261.   if (state & SCoopPAUSED) return false;       // check if item is suspended or not
  262.   if (!(state & SCoopTRIGGER)) return false;
  263.   SCoopATOMIC {
  264.   state = SCoopRUNNING;                        // this also clear the trigger flag at the same time :)
  265.   run();
  266.   state = SCoopRUNNABLE; }                     // an event shouldnt pause itself so lets go with RUNNABLE
  267.   return true;                                 // has been launched
  268. };   


  269. #if SCoopTRACE > 0
  270. void SCoopEvent::traceThis() {                 // declare the trace functions for debuging or printing some info by user
  271.      SCp("this=");SCphex((ptrInt)this & 0xFFFF);
  272.      int x = (ptrInt) SCoopGetSP();            // only place where we use SP register, just to see its value
  273.          SCp(" SP=");SCphex( x & 0xFFFF); }  
  274. void SCoopEvent::trace(char * xx) {
  275.      traceThis();SCp(" ");SCpln(xx); }
  276. #endif


  277. void SCoopEvent::pause()                       // pausing an event just set the state to PAUSED
  278. { if (state >= SCoopRUNNABLE) { state |= SCoopPAUSED; } };

  279. void SCoopEvent::resume()                      // resuming an event just clear the flag PAUSED ... might be not enough for user code
  280. { if (state & SCoopPAUSED) state &= ~SCoopPAUSED; };

  281. bool SCoopEvent::paused()                      // just return the pause flag status
  282. { if (state & SCoopPAUSED) return true; else return false; }


  283. /********* SCoopDelay CLASS *******/               // a basic virtual timer implementation. sort of "timerdown"
  284.                                                // very small size code in each method. compiler will probably inline and clone everything
  285. SCoopDelay::SCoopDelay()               
  286. { reset(); }
  287.   
  288. SCoopDelay::SCoopDelay(SCDelay_t reload)
  289. { set(setReload(reload)); }

  290. SCDelay_t  SCoopDelay::setReload(SCDelay_t reload)
  291. { return (reloadValue = reload); }

  292. SCDelay_t SCoopDelay::getReload()   
  293. { return reloadValue; }

  294. void SCoopDelay::initReload()      
  295. { set(reloadValue); }

  296. void SCoopDelay::reload()           
  297. { timeValue += reloadValue; }

  298. bool SCoopDelay::reloaded()
  299. { if (elapsed()) {
  300.      reload();
  301.          return true; }
  302.   return false; }

  303. void SCoopDelay::reset()
  304. { set(0); }

  305. SCDelay_t SCoopDelay::set(SCDelay_t time)
  306. { return (timeValue = time + SCoopDelayMillis()); };

  307. SCDelay_t SCoopDelay::get()
  308. { register SCDelay_t temp =(timeValue - SCoopDelayMillis());
  309.   if (temp <0) return 0; else return temp; }

  310. SCDelay_t SCoopDelay::add(SCDelay_t time)
  311. { timeValue += time; return time; }

  312. SCDelay_t SCoopDelay::sub(SCDelay_t time)
  313. { timeValue -= time; return time; }

  314. bool SCoopDelay::elapsed()
  315. { return (get() == 0); }


  316. /********* SCoopDelayUS CLASS *******/               // a basic virtual timer implementation. sort of "timerdown"
  317.                                                // very small size code in each method. compiler will probably inline and clone everything
  318. SCoopDelayus::SCoopDelayus()               
  319. { reset(); }
  320.   
  321. SCoopDelayus::SCoopDelayus(micros_t reload)
  322. { set(setReload(reload)); }

  323. micros_t  SCoopDelayus::setReload(micros_t reload)
  324. { return (reloadValue = reload); }

  325. micros_t SCoopDelayus::getReload()   
  326. { return reloadValue; }

  327. void SCoopDelayus::initReload()      
  328. { set(reloadValue); }

  329. void SCoopDelayus::reload()           
  330. { timeValue += reloadValue; }

  331. bool SCoopDelayus::reloaded()
  332. { if (elapsed()) {
  333.      reload();
  334.          return true; }
  335.   return false; }

  336. void SCoopDelayus::reset()
  337. { set(0); }

  338. micros_t SCoopDelayus::set(micros_t time)
  339. { return (timeValue = time + SCoopMicros()); };

  340. micros_t SCoopDelayus::get()
  341. { register micros_t temp =(timeValue - SCoopMicros());
  342.   if (temp <0) return 0; else return temp; }

  343. micros_t SCoopDelayus::add(micros_t time)
  344. { timeValue += time; return time; }

  345. micros_t SCoopDelayus::sub(micros_t time)
  346. { timeValue -= time; return time; }

  347. bool SCoopDelayus::elapsed()
  348. { return (get() == 0); }



  349. /********* SCoopTimer METHODS *******/


  350. SCoopTimer::SCoopTimer() : SCoopEvent()
  351. {initBasic(); init(0,NULL); };

  352. SCoopTimer::SCoopTimer(SCDelay_t period) : SCoopEvent()
  353. {initBasic(); init(period, NULL); };

  354. SCoopTimer::SCoopTimer(SCDelay_t period, SCoopFunc_t func) : SCoopEvent()
  355. {initBasic(); init( period, func); }

  356. void SCoopTimer::initBasic() {
  357.   counter    = -1;
  358.   userFunc   = NULL;
  359.   itemType   = SCoopTimerType; };

  360. void SCoopTimer::init(SCDelay_t period, SCoopFunc_t func) {
  361.   timer.setReload(period); timer.reset();
  362.   userFunc = func;
  363.   if (func != NULL)
  364.      state = SCoopNEW; } // we can use this NEW state as the user function is now defined


  365. void SCoopTimer::start() {
  366.   ifSCoopTRACE(3,"Timer::start");
  367.   SCoopEvent::start();
  368.   timer.initReload();   // make sure the timer is starting with the reload period value
  369.   }


  370. bool SCoopTimer::launch()
  371. { if ((counter == 0) || (timer.getReload() == 0)) return false;
  372.   if (timer.reloaded()) {
  373.       
  374. //ifSCoopTRACE(3,"Timer::launch/run");  // removed too much printing

  375.          state |= SCoopTRIGGER;
  376.          register bool launched = SCoopEvent::launch();
  377.          if ((launched ) && (counter > 0)) counter--;   
  378.                     
  379.              return launched; }                    // rearm next run time so timers are NOT desynchronized by pause(). (my default choice)      
  380.    
  381.   return false; };


  382. SCDelay_t SCoopTimer::getTimeToRun()
  383. { if ((counter == 0) || (timer.getReload() == 0)) return -1;
  384.   return timer.get(); };


  385. void SCoopTimer::setTimeToRun(SCDelay_t time)
  386. { timer.set(time); };


  387. void SCoopTimer::schedule(SCDelay_t time, SCoopTimerCount_t count)
  388. { timer.set(timer.setReload(time)); counter = count; };


  389. void SCoopTimer::schedule(SCDelay_t time)
  390. { schedule(time,-1); };


  391. /********* SOME BASIC FUNCTIONS *******/

  392. void SCoopMemFill(uint8_t *startp, uint8_t *endp, uint8_t v)
  393. { if (startp) while (startp < endp) *startp++ = v; };  
  394.    
  395. ptrInt SCoopMemSearch(uint8_t *startp, uint8_t *endp, uint8_t v)
  396. { uint8_t *ptr = startp;
  397.   while (ptr < endp) if (*ptr++ != v) break;
  398.   return ((ptrInt)ptr-(ptrInt)startp-1);
  399. };

  400. /********* SCoopTASK METHODS *******/

  401. // CONSTRUCTORS

  402. SCoopTask::SCoopTask() : SCoopEvent()
  403. { initBasic(); }           


  404. SCoopTask::SCoopTask(SCoopStack_t* stack, ptrInt size) : SCoopEvent()
  405. { initBasic(); init(stack,size); }     


  406. SCoopTask::SCoopTask(SCoopStack_t* stack, ptrInt size, SCoopFunc_t func) : SCoopEvent()
  407. { initBasic(); init(stack,size,func); }     


  408. void SCoopTask::initBasic() {
  409.    SCoopNumberTask++;
  410.    pStackAddr = NULL;
  411.    pStack     = NULL;
  412.    userFunc   = NULL;
  413.    register SCoopEvent* ptr = pNext;           // point on the previous item registered in the standard item list (if any)   
  414.    pNext = SCoopFirstTaskItem;                 // register in the task list     
  415.    SCoopFirstTaskItem = this;
  416.    if (ptr != pNext) {                         // if there was another (non task) item in the list before the previous task
  417.       SCoopFirstItem = ptr;                    // mark this item as now being the first
  418.       while (ptr->pNext != pNext) ptr = ptr->pNext;  // search last event or item
  419.           ptr->pNext = this; }                     // now points to the new task                         
  420.    itemType = SCoopTaskType; }


  421. void SCoopTask::init(SCoopStack_t* stack, ptrInt size)      
  422. { pStackAddr = (uint8_t*)stack;
  423.   pStack = (uint8_t*)stack + ((size-sizeof(SCoopStack_t))         // prepare task stack to the top of the space provided
  424. #if defined(SCoop_ARM) && (SCoop_ARM == 1)
  425.   & ~7
  426. #endif
  427.   );
  428.   SCoopMemFill((uint8_t*)stack, pStack, 0x55); // fill with 0x55 patern in order to calculate StackLeft later
  429. };

  430.        
  431. void SCoopTask::init(SCoopStack_t* stack, ptrInt size, SCoopFunc_t func) // only this one can be called by user
  432. { init(stack,size);
  433.   userFunc = func;
  434.   if (func != NULL)
  435.      state = SCoopNEW; }                       // we have a stack and a user function so we can "start" later.


  436. SCoopTask::~SCoopTask(){ }                     // destructor to remove task from list .. doesnt really work with "delete"



  437. /********* ONLY USED IF SCoopTRACE DEFINED *******/

  438. #if SCoopTRACE > 0
  439. void SCoopTask::trace(char * xx) {
  440.      SCoopEvent::traceThis();
  441.      SCp(" @Stack=");SCphex((ptrInt)pStackAddr & 0xFFFF);
  442.      SCp(" pStack=");SCphex((ptrInt)pStack & 0xFFFF);      
  443.      SCp(" ");SCpln(xx); }
  444. #endif


  445. /******** START and LAUNCH SECTION ****************/


  446. void SCoopTask::start() {
  447. ifSCoopTRACE(3,"Task::start");
  448. if (pStack) {                                       // sanity check if stack has been allocated by user or constructor ...
  449.      if ((state & SCoopNEW)) {                       // if the task context is not yet set
  450.        ASM_ATOMIC {                                  // de activate interrupt so we can use the stack content for further copy/paste
  451.              SCoopSwitch(&SCINM.mainEnv,&SCINM.mainEnv);   // simulate switching but with current context : back to same place !                                               
  452.                                     
  453.              if (state & SCoopRUNNABLE) {                // this will be executed only when we comeback here with a backToTask the very first time
  454.                  startFirstLoop();                       // quite equivalent to a "setjmp" mechanism
  455.             };                                       // never come back here then.
  456.          
  457.          { register uint8_t* pEnd = SCINM.mainEnv;    //
  458.                    register uint8_t* pSource = (uint8_t*) SCoopGetSP(); // start from the stack
  459.                    do { *pStack-- = *pSource--; }            // we copy the stack context to the newly pStack space,  
  460.                    while (pSource != pEnd); }                // this includes the previous return adress (@!@)
  461.                                                      // so we ll endup just below the previous call to scoopswitch above (@\_/@)                                                            
  462.         };                                           // we can restore interrupts as we are finished with critical stack handling
  463.                 };                                           // continue forward to launch setup
  464.      SCoopEvent::start();                            // call the user setup function (if defined in derived object) and set object RUNNABLE     
  465.          quantumMicros = SCINM.startQuantum;             // initialize quantum time provided by start (xx) or by user or by default
  466.          SCINM.targetCycleMicros += quantumMicros;       // cumulate time to calculate target cycle time
  467.          prevMicros = SCoopMicros();                     // memorize time , to calculate time spent in the task and in the cycle
  468.      timer = 0; }                                    // this will enable imediate user call to sleepSync to work properly  
  469. } // end start()


  470. void SCoopTask::startFirstLoop() {                   // will execute this function the first call to backToTask() made by yield()
  471. #if SCoopTIMEREPORT > 0
  472.   yieldMicros    = 0; maxYieldMicros = 0;
  473. #endif  
  474.   state = SCoopRUNNING;                  
  475.   while (true)  {                                    // a SCoop task will never end ...
  476.      if (!(state & SCoopPAUSED)) {
  477.          loop();                                     // call user function (derived virtual loop or user adress)
  478.                  yieldInline(quantumMicros); }               // try to switch task if we reach the end of the user loop
  479.      else yield(0);                                  // switch imediately to next task (or scheduler) if we are paused
  480.     }
  481. }


  482. bool SCoopTask::launch() {
  483. //  ifSCoopTRACE(3,"task::launch")       
  484.         if (state & SCoopRUNNABLE) {                   // make sure the task context is setup first and start() has been called already
  485.        if (!(state & (SCoopPAUSED | SCoopKILLING)))
  486.               { SCINM.Task = this;                     // we always can find a pointer to the current task in which we are running
  487.             SCoopSwitch(&pStack,&SCINM.mainEnv);
  488.                     return true; }                         // return to scheduler / yield() or cycle()
  489.            else prevMicros = SCoopMicros();            // just to avoid jeopardizing the cycleMicros in fact
  490.         } else
  491.            if (state & SCoopNEW) start();              // initialize context if not done in the main arduino setup() section ...
  492.   return false; }                              

  493. #if SCoopANDROIDMODE >= 2  
  494. void SCoopTask::kill()                           
  495. { if (itemType == SCoopDynamicTask)
  496.      state |= (SCoopKILLING );
  497.          if (mySCoop.Task == this) yieldSwitch();      // quick return to main scheduler for treating the situation
  498. }
  499. #endif
  500.   
  501.   
  502. /******** YIELD SECTION ****************/

  503.   
  504.   void SCoopTask::yield()                            // check if the quantum time alowed is elapsed, the switch to scheduler
  505.   { yieldInline(quantumMicros); }
  506.       
  507.   
  508.   void SCoopTask::yield(micros_t quantum)
  509.   { yieldInline(quantum); }

  510.   
  511.   void SCoopTask::yieldInline(micros_t quantum)
  512.   { if (quantum) {
  513.        register micros_t spent = SCoopMicros() - prevMicros;
  514.        if (spent >= quantum) yieldSpent(spent);  }   // switch makes sense          
  515.     else if (!SCINM.Atomic) yieldSwitch();
  516. };     
  517.   
  518.   
  519.   void SCoopTask::yieldSpent(micros_t spent)        // immediate jump back to scheduler
  520.   { if (SCINM.Atomic) return;                      // do nothing if we are in a atomic section
  521. #if SCoopTIMEREPORT > 0                              // verifiy if we want to measure timing  
  522.     if (spent > maxYieldMicros) maxYieldMicros = spent;  // check max time to capture peak
  523.     yieldMicros += spent - (yieldMicros >> SCoopTIMEREPORT); // this cumulate the time spent in the task over the 2^x last cycles
  524. #endif
  525.      yieldSwitch(); }

  526.    
  527.    void SCoopTask::yieldSwitch() {
  528.         register SCoopEvent* temp;
  529.         if ((SCoopYIELDCYCLE == 1) &&                    // optimize speed by directly switching next adjacent task
  530.            ((temp=pNext) != NULL) &&                     // only if possible, otherwise back to main loop
  531.        ((temp->state & (SCoopRUNNABLE | SCoopPAUSED | SCoopKILLING)) == SCoopRUNNABLE))        {   
  532.            SCINM.Current = temp;                  
  533.            SCINM.Task = (SCoopTask*)temp;          // lets go next
  534.            SCoopSwitch(&(((SCoopTask*)temp)->pStack),&pStack); }    // save our context and use next one
  535.     else {                                           // systematically return to main loop or scheduler if using cycle()
  536.         SCINM.Task = NULL;                          
  537.         SCoopSwitch(&SCINM.mainEnv,&pStack);  }      // save context and return to main scheduler
  538.                                                                                                          // will return here by launch() from scheduler yield() or cycle()
  539.      prevMicros = SCoopMicros();
  540.         };                                               // come back into the task HERE / NOW

  541. /******** SLEEP SECTION ****************/

  542.    
  543.   void SCoopTask::sleep(SCDelay_t ms)                 // will replace your usual arduino "delay" function
  544.   { sleepMs(ms,false); };

  545.   
  546.   void SCoopTask::sleepSync(SCDelay_t ms)             // same as Sleep but delays are not absolute but relative to previous call to SleepSync
  547.   { sleepMs(ms, true); };
  548.   

  549.   void SCoopTask::sleepMs(SCDelay_t ms, bool sync) {
  550.    ifSCoopTRACE(3,"Task::sleepms");
  551.    if (ms < 1) { timer.reset(); return; }
  552.    if (sync) timer.add(ms); else timer.set(ms);
  553.    state = SCoopWAITING;
  554.    while (timer) yield(0);
  555.    state = SCoopRUNNING; }

  556.          
  557.   bool SCoopTask::sleepUntil(vbool& var, SCDelay_t timeOut)  // just wait for an "external" variable to become true, with a timeout
  558.   { register bool temp = false;
  559.     if (timeOut) {
  560.        timer.set(timeOut);
  561.            temp = true; }
  562.         return sleepUntilBool(var, temp); }
  563.    
  564.   
  565.   void SCoopTask::sleepUntil(vbool& var)       // just wait for an "external" variable to become true
  566.   { sleepUntilBool(var, false); }
  567.   
  568.   
  569.   bool SCoopTask::sleepUntilBool(vbool& var, bool checkTime) {             // just wait for an "external" variable to become true
  570.     ifSCoopTRACE(3,"Task::sleepuntil");
  571.         state=SCoopWAITING;
  572.         while(!var) {
  573.            yield(0);
  574.            if (checkTime)
  575.               if (timer.elapsed()) { state = SCoopRUNNING; return false; }
  576.            }
  577.     state = SCoopRUNNING;
  578.         var=false; return true; }

  579.   
  580.   ptrInt SCoopTask::stackLeft()
  581.   { if (pStackAddr) {                          // sanity check if stack has been initialized
  582.        return SCoopMemSearch(pStackAddr, pStack, 0x55);}
  583.     else return 0;
  584.   };


  585. /********* SCoop METHODS *******/
  586.   
  587. SCoop::SCoop()        // constructor
  588.   { startQuantum      = SCoopDefaultQuantum;     // every task will get the default value unless changed in their setup or with sart()
  589.     quantumMicros     = SCoopDefaultQuantum;     // the main loop also
  590. #if SCoopYIELDCYCLE == 0
  591.     quantumMicrosReal = 0;                       // we do nt know yet the number of task registered
  592. #endif
  593.         targetCycleMicros = 0;                       //  we do nt know yet the total cycle time
  594. #if SCoopTIMEREPORT > 0                          // verifiy if we want to measure timing  
  595.         cycleMicros = 0; maxCycleMicros = 0;
  596. #endif       
  597.     Current = NULL;
  598.         Task    = NULL;
  599.         Atomic  = 1; };                               // ensure yield is not activated
  600.   

  601.   void SCoop::start(micros_t cycleTime, micros_t mainLoop)   // define the total length of the cycle and the main loop quantum
  602.   { startQuantum = (cycleTime - mainLoop) / (SCoopNumberTask);
  603.     quantumMicros = mainLoop;                                // specific time for main loop
  604.     start(); }
  605.   
  606.   
  607.   void SCoop::start(micros_t cycleTime)           // define the total length of the cycle for all tasks+1
  608.   { startQuantum = cycleTime / (SCoopNumberTask+1); // consider the main loop as a task
  609.     quantumMicros = startQuantum;                 // time for the main loop will be the same then
  610.     start(); }
  611.    
  612.        
  613.     void SCoop::start()                           // start all objects in the list
  614.   { targetCycleMicros = quantumMicros;            // initialization
  615. #if SCoopYIELDCYCLE == 0
  616.     quantumMicrosReal = quantumMicros / SCoopNumberTask;  // divide time in slice, as we come back here at each task switch...
  617. #endif
  618. #if SCoopTRACE > 1
  619.         SCp("starting scheduler : ");SCp(SCoopNumberTask);SCp("+1 tasks, quantum = "); SCp(startQuantum);SCp(", main loop quantum = ");SCp(quantumMicros);
  620. #endif
  621.     Current = SCoopFirstItem;                     // take the first
  622.         while (Current) {                        
  623.           Current->start();                           // start this task (initialize environement and call setup())
  624.       Current = Current->pNext;  }                // take next ptr
  625. #if SCoopTRACE > 1
  626.         SCp(", target cycle time = ");SCpln(targetCycleMicros); // this is calculated by the task::start()
  627. #endif
  628.         SCINM.Atomic=0;                          // ready for switchiching task with "yield"
  629.    };
  630.    

  631.   // this is the main code for the Scheduler, relying on yield() method as a state machine
  632.   
  633.   void SCoop::yield0()                         // can be called from where ever in order to Force the switch to next task
  634.   { if (Task) Task->yield(0); else SCoop::yield(); }
  635.   
  636.   
  637.   void SCoop::yield()                          // can be called from where ever in order to Force the switch to next task
  638.   { if (Task) Task->yield();                   // we ve been called from a task context lets yield from there
  639.     else {
  640.           if (Atomic) return;                      // self explaining
  641.       
  642.       register SCoopEvent* temp = SCoopFirstItem;
  643.       while (temp != SCoopFirstTaskItem) { temp->launch(); temp = temp->pNext; }  // launch all events
  644.           
  645.           register micros_t time;
  646.           if (Current == NULL) {                   // a cycle is completed
  647.              temp = SCoopFirstTaskItem;
  648.                  if (temp == NULL) return;             // no tasks in the list !
  649.                                  
  650.                  // check overall target cycle time before launching first task
  651.              
  652. #if SCoopTIMEREPORT > 0                         // verifiy if we want to measure timing , then calculate average cycle time
  653.              time = SCoopMicros() - reinterpret_cast<SCoopTask*>(temp)->prevMicros; // mesure whole cycle length based on first task information
  654.                  if (quantumMicros) {                   // check if we are supposed to spend some time in the main loop or not
  655.              if (time < targetCycleMicros) return; }   // back in main loop() until we reach the expected target cycle time
  656.          Current = temp;                        // we can launch this first task
  657.          if (time > maxCycleMicros) maxCycleMicros = time;
  658.                  cycleMicros += (time - (cycleMicros>> SCoopTIMEREPORT));
  659. #else
  660.                  if (quantumMicros) {                   // check if we are supposed to spend some time in the main loop or not
  661.                   time = SCoopMicros() - reinterpret_cast<SCoopTask*>(temp)->prevMicros; // mesure whole cycle length based on first task information
  662.              if (time < targetCycleMicros) return; }   // back in main loop() until we reach the expected target cycle time
  663.          Current = temp;                        // we can launch this first task
  664. #endif
  665.                 }
  666.                 else { // lets check intertask timing before launching the next
  667. #if SCoopYIELDCYCLE == 0
  668.                      if (quantumMicrosReal) {              // check if we should spend quite some time in the main loop between 2 tasks
  669.                        time = SCoopMicros()
  670.                                 - reinterpret_cast<SCoopTask*>(Current)->prevMicros // give the time since last task executed
  671.                                     - reinterpret_cast<SCoopTask*>(Current)->quantumMicros; // mesure whole cycle length based on first task information
  672.            if (time < quantumMicrosReal) return;   // back in main loop() until we reach the expected target cycle time           
  673.                         }
  674. #endif                       
  675.                 };
  676.           do { temp = Current;
  677.              temp->launch();                     // now launch tasks from the list, and may be all in a single launch()
  678.                  Current = temp->pNext;   
  679. #if SCoopANDROIDMODE >= 2                    // check if we autorize the killme
  680.                  if ((temp->state & SCoopKILLING) &&
  681.                     (temp->itemType == SCoopDynamicTask)) {                                                                           
  682.                              delete temp;       
  683.                         } // killing done                 
  684. #endif
  685. #if SCoopYIELDCYCLE == 0                           // back to main task if we are not in yield cycle mode
  686.          return;
  687. #endif                                               // otherwise we just go back into the main loop      
  688.             } while (Current);
  689.         }
  690. }

  691.   
  692.   void SCoop::cycle() {                         // execute a complete cycle across all tasks & events
  693. #if SCoopTRACE > 1
  694.      SCpln("start scheduler cycle()");
  695. #endif     
  696.          do { yield(); } while (Current); };


  697.   
  698.   
  699.   void SCoop::sleep(SCDelay_t time)                 
  700. {  SCoopDelay SCoopSleepTimer;
  701.    SCoopSleepTimer = time; while (SCoopSleepTimer) SCINM.yield(); }

  702.    
  703.    void SCoop::delay(uint32_t ms) {
  704.   uint32_t end = millis() + ms;
  705.   while (millis() < end)        yield();
  706. }


  707. #if SCoopANDROIDMODE >= 1
  708. SCoopTask* SCoop::startLoop(SCoopFunc_t func, uint32_t stackSize) {
  709.        
  710.         uint8_t *stack = (uint8_t*)malloc(stackSize);
  711.         if (!stack) return NULL;

  712.         SCoopTask *task = new SCoopTask((SCoopStack_t*)stack,stackSize,func);
  713.         if (!task) {
  714.                 free(stack);
  715.                 return NULL; }

  716.     // object now exist and is registered in the list!
  717.         task->itemType = SCoopDynamicTask;
  718.         return task;
  719. };
  720. #endif

  721. /*************** OVERLOAD STANDARD YIELD *****************/


  722. #if SCoopOVERLOADYIELD == 1
  723. void yield(void) { SCINM.yield(); };              // overload standard arduino yield
  724. void yield0(void){ SCINM.yield0(); };             // overload standard arduino yield
  725. #endif

  726. void __attribute__((weak)) sleep (SCDelay_t time)
  727. { SCINM.sleep(time); }

  728. /*************** FIFO *****************/

  729. SCoopFifo::SCoopFifo(void * fifo, const uint8_t itemSize, const uint16_t itemNumber)
  730.    { this->itemSize = itemSize;
  731.      ptrMin = (uint8_t*)fifo;   
  732.          ptrIn =  (uint8_t*)fifo;   
  733.          ptrOut = (uint8_t*)fifo;   
  734.      ptrMax = (uint8_t*)fifo + (itemNumber * itemSize); }


  735. uint16_t SCoopFifo::count() {                      // return the number of item currently in the fifo
  736.      register int16_t temp;

  737.          AVR_ATOMIC { temp = (ptrIn-ptrOut); }
  738.      return (temp<0 ? (temp + ptrMax-ptrMin) : temp); }


  739. bool SCoopFifo::put(void* var)                     // put a record in the pifo and return true if ok or false if fifo is full
  740.    {   register uint8_t N = itemSize;
  741.        register uint8_t* dest;
  742.        register uint8_t* source;
  743.           
  744.            AVR_ATOMIC { dest = ptrIn; }
  745.        register uint8_t* post = dest + N;
  746.        if (post >= ptrMax) { post = ptrMin; }
  747.                
  748.            AVR_ATOMIC { source = ptrOut; }
  749.            if (post != source) { // no overload
  750.                  source = (uint8_t*)var;        
  751.           do { *dest++ = *source++; } while (--N);
  752.           AVR_ATOMIC { ptrIn = post; }
  753.           return true;       // ok
  754.       } else return false; } // fifo was full


  755. bool SCoopFifo::putChar(const uint8_t value) {
  756.    uint8_t X=value;  return put(&X); }


  757. bool SCoopFifo::putInt(const uint16_t value) {
  758.    uint16_t X=value;  return put(&X); }


  759. bool SCoopFifo::putLong(const uint32_t value) {
  760.    uint32_t X=value;  return put(&X); }


  761. bool SCoopFifo::get(void* var)                     // retreive one record from the fifo, if not empty otherwise return false
  762.    { register uint8_t* In;
  763.          register uint8_t* source;
  764.      
  765.      AVR_ATOMIC { In=ptrIn; source=ptrOut; }
  766.      if (In != source) {
  767.        register uint8_t N = itemSize;
  768.        register uint8_t* dest = (uint8_t*)var;      
  769.        do { *dest++ = *source++; } while (--N) ;
  770.        if (source >= ptrMax) { source = ptrMin; }
  771.        AVR_ATOMIC { ptrOut = source; }
  772.        return true;         // ok
  773.            } else return false; // fifo was empty
  774.          }


  775. void SCoopFifo::getYield(void* var)                // same as get(var) but wait until fifo is not empty, and calls yield()
  776. { register uint8_t* In;
  777.   register uint8_t* Out;
  778.    
  779.   while (true) {
  780.      AVR_ATOMIC { In=ptrIn; Out=ptrOut; }
  781.      if (In == Out) yield(); else break; } ;
  782.         get(var); }


  783. uint8_t SCoopFifo::getChar()
  784. { uint8_t result8;
  785.   getYield(&result8); return result8; }

  786. uint16_t SCoopFifo::getInt()
  787. { uint16_t result16;
  788.   getYield(&result16); return result16; }

  789. uint32_t SCoopFifo::getLong()
  790. { uint32_t result32;
  791.   getYield(&result32); return result32; }


  792. uint16_t SCoopFifo::flush() {                      // empty the fifo
  793.   ASM_ATOMIC {                                     // this will de activate interrupts
  794.      ptrIn  = ptrMin;
  795.      ptrOut = ptrMin; }                            // this will ACTIVATE interrupts                           
  796.   return (ptrMax-ptrMin); }

  797. uint16_t SCoopFifo::flushNonAtomic() {             // empty the fifo
  798.      ptrIn  = ptrMin;
  799.      ptrOut = ptrMin;
  800.   return (ptrMax-ptrMin); }
復制代碼

所有資料51hei提供下載:
SCoop-master.rar (644.13 KB, 下載次數: 59)


評分

參與人數 1黑幣 +50 收起 理由
admin + 50 共享資料的黑幣獎勵!

查看全部評分

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏3 分享淘帖 頂 踩
回復

使用道具 舉報

沙發
ID:318591 發表于 2018-11-13 01:16 | 只看該作者
thanks 謝謝
回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規則

手機版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

Powered by 單片機教程網

快速回復 返回頂部 返回列表
主站蜘蛛池模板: 亚洲精品久久久一区二区三区 | 精品动漫一区 | 欧美日韩在线成人 | 成人一区二区三区在线观看 | 欧美一区二区在线 | 精品国产乱码久久久久久丨区2区 | 欧美成人一区二区 | 国产99热精品 | 亚洲一区 | 欧美三级视频 | 久久综合成人精品亚洲另类欧美 | 日韩一区二区三区av | 夜夜久久 | 中文字幕视频网 | 鸳鸯谱在线观看高清 | 亚洲精品乱码 | a黄视频| 韩国精品在线 | 日韩中文字幕高清 | 亚洲一区二区av在线 | 亚洲视频一区在线观看 | 亚洲 中文 欧美 日韩 在线观看 | 亚洲精品一区二区久 | 中文字幕视频在线看 | japan25hdxxxx日本| 国产精品毛片一区二区在线看 | 亚洲欧美一区二区三区国产精品 | 婷婷中文字幕 | 粉嫩av在线 | 九九精品视频在线 | 成人在线观看免费视频 | 在线播放国产视频 | 国产日韩精品一区二区 | 国产精品一级在线观看 | 中文字幕一区在线观看视频 | 永久精品 | 亚洲第一色站 | 九九热精品视频 | 欧美中文字幕一区 | 天天天操 | www.亚洲一区 |