Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: fll mbed-rtos mbed
fll.h@5:130721ce29f7, 2015-02-14 (annotated)
- Committer:
- sierra
- Date:
- Sat Feb 14 07:25:27 2015 +0000
- Revision:
- 5:130721ce29f7
- Parent:
- 3:edbf31a8589f
- Child:
- 6:d0348b7a2f05
OrPipe!
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| amutake | 0:c80e972b4c59 | 1 | // Frame Level Language |
| amutake | 0:c80e972b4c59 | 2 | // header |
| amutake | 0:c80e972b4c59 | 3 | |
| amutake | 0:c80e972b4c59 | 4 | #include "mbed.h" |
| amutake | 0:c80e972b4c59 | 5 | #include "rtos.h" |
| amutake | 0:c80e972b4c59 | 6 | #include <stdint.h> |
| amutake | 0:c80e972b4c59 | 7 | #include <vector> |
| amutake | 0:c80e972b4c59 | 8 | |
| amutake | 0:c80e972b4c59 | 9 | #define R1 0x0001 |
| amutake | 0:c80e972b4c59 | 10 | #define B_TRIANGLE 0x0002 |
| amutake | 0:c80e972b4c59 | 11 | #define B_CIRCLE 0x0004 |
| amutake | 0:c80e972b4c59 | 12 | #define B_CROSS 0x0008 |
| amutake | 0:c80e972b4c59 | 13 | #define B_SQUARE 0x0010 |
| amutake | 0:c80e972b4c59 | 14 | #define B_R2 0x0020 |
| amutake | 0:c80e972b4c59 | 15 | #define B_START 0x0040 |
| amutake | 0:c80e972b4c59 | 16 | #define B_ANALOG 0x0080 |
| amutake | 0:c80e972b4c59 | 17 | #define B_SELECT 0x0100 |
| amutake | 0:c80e972b4c59 | 18 | #define B_L2 0x0200 |
| amutake | 0:c80e972b4c59 | 19 | #define B_UP 0x0400 |
| amutake | 0:c80e972b4c59 | 20 | #define B_DOWN 0x0800 |
| amutake | 0:c80e972b4c59 | 21 | #define B_LEFT 0x1000 |
| amutake | 0:c80e972b4c59 | 22 | #define B_RIGHT 0x2000 |
| amutake | 0:c80e972b4c59 | 23 | #define B_L1 0x4000 |
| amutake | 0:c80e972b4c59 | 24 | |
| amutake | 2:165723d41023 | 25 | #define MAIL_BOX_SIZE 16 |
| amutake | 0:c80e972b4c59 | 26 | |
| sierra | 3:edbf31a8589f | 27 | typedef uint16_t button_t; |
| amutake | 0:c80e972b4c59 | 28 | |
| amutake | 0:c80e972b4c59 | 29 | class Source |
| amutake | 0:c80e972b4c59 | 30 | { |
| amutake | 0:c80e972b4c59 | 31 | private: |
| amutake | 0:c80e972b4c59 | 32 | int i; |
| sierra | 3:edbf31a8589f | 33 | button_t* button_t_seq; |
| sierra | 1:1abcd83947bf | 34 | int size; |
| amutake | 0:c80e972b4c59 | 35 | bool loop; |
| amutake | 0:c80e972b4c59 | 36 | public: |
| sierra | 3:edbf31a8589f | 37 | Source(button_t *bs, int s, bool l); |
| sierra | 3:edbf31a8589f | 38 | virtual button_t await(); |
| amutake | 0:c80e972b4c59 | 39 | }; |
| amutake | 0:c80e972b4c59 | 40 | |
| sierra | 5:130721ce29f7 | 41 | class Pipe : public Source |
| amutake | 0:c80e972b4c59 | 42 | { |
| amutake | 0:c80e972b4c59 | 43 | private: |
| sierra | 5:130721ce29f7 | 44 | Source** sources; |
| sierra | 5:130721ce29f7 | 45 | int sources_size; |
| amutake | 0:c80e972b4c59 | 46 | public: |
| sierra | 5:130721ce29f7 | 47 | Pipe(Source **srcs, int srcs_size); |
| sierra | 5:130721ce29f7 | 48 | virtual button_t fold(button_t *bs, int bs_size) = 0; |
| sierra | 3:edbf31a8589f | 49 | virtual button_t await(); |
| amutake | 0:c80e972b4c59 | 50 | }; |
| amutake | 0:c80e972b4c59 | 51 | |
| amutake | 0:c80e972b4c59 | 52 | // ストリームの終端になっていて、キー入力をするスレッドに向けてキーを送る |
| amutake | 0:c80e972b4c59 | 53 | class Sink |
| amutake | 0:c80e972b4c59 | 54 | { |
| amutake | 0:c80e972b4c59 | 55 | private: |
| amutake | 0:c80e972b4c59 | 56 | Source* source; |
| sierra | 3:edbf31a8589f | 57 | rtos::Mail<button_t, MAIL_BOX_SIZE>* mail_box; |
| amutake | 2:165723d41023 | 58 | Mutex* mutex; |
| amutake | 0:c80e972b4c59 | 59 | public: |
| sierra | 3:edbf31a8589f | 60 | Sink(Source* src, rtos::Mail<button_t, MAIL_BOX_SIZE>* box, Mutex* mut); |
| amutake | 0:c80e972b4c59 | 61 | void run(); |
| amutake | 0:c80e972b4c59 | 62 | void reset(Source* src); |
| amutake | 0:c80e972b4c59 | 63 | }; |
| amutake | 0:c80e972b4c59 | 64 | |
| amutake | 0:c80e972b4c59 | 65 | |
| amutake | 0:c80e972b4c59 | 66 | class Output |
| amutake | 0:c80e972b4c59 | 67 | { |
| amutake | 0:c80e972b4c59 | 68 | private: |
| sierra | 3:edbf31a8589f | 69 | rtos::Mail<button_t, MAIL_BOX_SIZE>* mail_box; |
| amutake | 0:c80e972b4c59 | 70 | public: |
| sierra | 3:edbf31a8589f | 71 | Output(rtos::Mail<button_t, MAIL_BOX_SIZE>* box); |
| amutake | 0:c80e972b4c59 | 72 | void run(); |
| amutake | 0:c80e972b4c59 | 73 | }; |
| amutake | 0:c80e972b4c59 | 74 | |
| sierra | 3:edbf31a8589f | 75 | void press(button_t btn); |
