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@6:d0348b7a2f05, 2015-02-14 (annotated)
- Committer:
- sierra
- Date:
- Sat Feb 14 08:02:21 2015 +0000
- Revision:
- 6:d0348b7a2f05
- Parent:
- 5:130721ce29f7
- Child:
- 7:61b4825304e2
- Child:
- 29:2f3d6d09eaac
Create base object: Producer
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 | |
| sierra | 6:d0348b7a2f05 | 29 | // Base object for stream network |
| sierra | 6:d0348b7a2f05 | 30 | class Producer { |
| sierra | 6:d0348b7a2f05 | 31 | public: |
| sierra | 6:d0348b7a2f05 | 32 | virtual button_t await() = 0; |
| sierra | 6:d0348b7a2f05 | 33 | }; |
| sierra | 6:d0348b7a2f05 | 34 | |
| sierra | 6:d0348b7a2f05 | 35 | // 0 input |
| sierra | 6:d0348b7a2f05 | 36 | class RepeaterSource : public Producer { |
| amutake | 0:c80e972b4c59 | 37 | private: |
| amutake | 0:c80e972b4c59 | 38 | int i; |
| sierra | 6:d0348b7a2f05 | 39 | button_t* button_seq; |
| sierra | 1:1abcd83947bf | 40 | int size; |
| amutake | 0:c80e972b4c59 | 41 | public: |
| sierra | 6:d0348b7a2f05 | 42 | RepeaterSource(button_t *bs, int s); |
| sierra | 3:edbf31a8589f | 43 | virtual button_t await(); |
| amutake | 0:c80e972b4c59 | 44 | }; |
| amutake | 0:c80e972b4c59 | 45 | |
| sierra | 6:d0348b7a2f05 | 46 | // N inputs |
| sierra | 6:d0348b7a2f05 | 47 | class FoldFlow : public Producer { |
| amutake | 0:c80e972b4c59 | 48 | private: |
| sierra | 6:d0348b7a2f05 | 49 | Producer** sources; |
| sierra | 5:130721ce29f7 | 50 | int sources_size; |
| amutake | 0:c80e972b4c59 | 51 | public: |
| sierra | 6:d0348b7a2f05 | 52 | FoldFlow(Producer **srcs, int srcs_size); |
| sierra | 5:130721ce29f7 | 53 | virtual button_t fold(button_t *bs, int bs_size) = 0; |
| sierra | 3:edbf31a8589f | 54 | virtual button_t await(); |
| amutake | 0:c80e972b4c59 | 55 | }; |
| amutake | 0:c80e972b4c59 | 56 | |
| amutake | 0:c80e972b4c59 | 57 | // ストリームの終端になっていて、キー入力をするスレッドに向けてキーを送る |
| amutake | 0:c80e972b4c59 | 58 | class Sink |
| amutake | 0:c80e972b4c59 | 59 | { |
| amutake | 0:c80e972b4c59 | 60 | private: |
| sierra | 6:d0348b7a2f05 | 61 | Producer* source; |
| sierra | 3:edbf31a8589f | 62 | rtos::Mail<button_t, MAIL_BOX_SIZE>* mail_box; |
| amutake | 2:165723d41023 | 63 | Mutex* mutex; |
| amutake | 0:c80e972b4c59 | 64 | public: |
| sierra | 6:d0348b7a2f05 | 65 | Sink(Producer* src, rtos::Mail<button_t, MAIL_BOX_SIZE>* box, Mutex* mut); |
| amutake | 0:c80e972b4c59 | 66 | void run(); |
| sierra | 6:d0348b7a2f05 | 67 | void reset(Producer* src); |
| amutake | 0:c80e972b4c59 | 68 | }; |
| amutake | 0:c80e972b4c59 | 69 | |
| amutake | 0:c80e972b4c59 | 70 | |
| amutake | 0:c80e972b4c59 | 71 | class Output |
| amutake | 0:c80e972b4c59 | 72 | { |
| amutake | 0:c80e972b4c59 | 73 | private: |
| sierra | 3:edbf31a8589f | 74 | rtos::Mail<button_t, MAIL_BOX_SIZE>* mail_box; |
| amutake | 0:c80e972b4c59 | 75 | public: |
| sierra | 3:edbf31a8589f | 76 | Output(rtos::Mail<button_t, MAIL_BOX_SIZE>* box); |
| amutake | 0:c80e972b4c59 | 77 | void run(); |
| amutake | 0:c80e972b4c59 | 78 | }; |
| amutake | 0:c80e972b4c59 | 79 | |
| sierra | 3:edbf31a8589f | 80 | void press(button_t btn); |
