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@35:4ba2f4fd7015, 2015-02-17 (annotated)
- Committer:
- sierra
- Date:
- Tue Feb 17 07:36:34 2015 +0000
- Revision:
- 35:4ba2f4fd7015
- Parent:
- 34:422d4d6ae5ea
first release!
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| amutake | 0:c80e972b4c59 | 1 | // Frame Level Language |
| amutake | 7:61b4825304e2 | 2 | // interface |
| amutake | 0:c80e972b4c59 | 3 | |
| amutake | 9:0d6631edfc32 | 4 | #pragma once |
| amutake | 9:0d6631edfc32 | 5 | |
| amutake | 0:c80e972b4c59 | 6 | #include "mbed.h" |
| amutake | 0:c80e972b4c59 | 7 | #include "rtos.h" |
| amutake | 0:c80e972b4c59 | 8 | #include <stdint.h> |
| amutake | 0:c80e972b4c59 | 9 | |
| amutake | 2:165723d41023 | 10 | #define MAIL_BOX_SIZE 16 |
| amutake | 0:c80e972b4c59 | 11 | |
| sierra | 35:4ba2f4fd7015 | 12 | #define FRAME (1.0 / 59.94) // 1 frame (sec) |
| amutake | 8:d16a0fcc2735 | 13 | |
| sierra | 32:fdf9f6fca8a2 | 14 | #define R1 0x0001 |
| sierra | 32:fdf9f6fca8a2 | 15 | #define TRIANGLE 0x0002 |
| sierra | 32:fdf9f6fca8a2 | 16 | #define CIRCLE 0x0004 |
| sierra | 32:fdf9f6fca8a2 | 17 | #define CROSS 0x0008 |
| sierra | 32:fdf9f6fca8a2 | 18 | #define SQUARE 0x0010 |
| sierra | 32:fdf9f6fca8a2 | 19 | #define R2 0x0020 |
| sierra | 32:fdf9f6fca8a2 | 20 | #define START 0x0040 |
| sierra | 32:fdf9f6fca8a2 | 21 | #define ANALOG 0x0080 |
| sierra | 32:fdf9f6fca8a2 | 22 | #define SELECT 0x0100 |
| sierra | 32:fdf9f6fca8a2 | 23 | #define L2 0x0200 |
| sierra | 32:fdf9f6fca8a2 | 24 | #define UP 0x0400 |
| sierra | 32:fdf9f6fca8a2 | 25 | #define DOWN 0x0800 |
| sierra | 32:fdf9f6fca8a2 | 26 | #define LEFT 0x1000 |
| sierra | 32:fdf9f6fca8a2 | 27 | #define RIGHT 0x2000 |
| sierra | 32:fdf9f6fca8a2 | 28 | #define L1 0x4000 |
| sierra | 32:fdf9f6fca8a2 | 29 | #define BUTTON_NUM 15 |
| sierra | 32:fdf9f6fca8a2 | 30 | |
| sierra | 3:edbf31a8589f | 31 | typedef uint16_t button_t; |
| amutake | 0:c80e972b4c59 | 32 | |
| sierra | 6:d0348b7a2f05 | 33 | // Base object for stream network |
| amutake | 7:61b4825304e2 | 34 | class Producer |
| amutake | 7:61b4825304e2 | 35 | { |
| sierra | 6:d0348b7a2f05 | 36 | public: |
| sierra | 6:d0348b7a2f05 | 37 | virtual button_t await() = 0; |
| amutake | 18:c5d3a4d6e8e5 | 38 | virtual bool is_finished() = 0; |
| amutake | 22:b19dc0387288 | 39 | virtual void reset() = 0; |
| sierra | 6:d0348b7a2f05 | 40 | }; |
| sierra | 6:d0348b7a2f05 | 41 | |
| amutake | 7:61b4825304e2 | 42 | // Sink is the end of button stream network |
| amutake | 7:61b4825304e2 | 43 | // It sends next button to Output object through rtos::Mail |
| amutake | 0:c80e972b4c59 | 44 | class Sink |
| amutake | 0:c80e972b4c59 | 45 | { |
| amutake | 0:c80e972b4c59 | 46 | private: |
| sierra | 6:d0348b7a2f05 | 47 | Producer* source; |
| sierra | 3:edbf31a8589f | 48 | rtos::Mail<button_t, MAIL_BOX_SIZE>* mail_box; |
| amutake | 2:165723d41023 | 49 | Mutex* mutex; |
| sierra | 34:422d4d6ae5ea | 50 | button_t temporary[MAIL_BOX_SIZE]; |
| sierra | 34:422d4d6ae5ea | 51 | int temporary_size; |
| sierra | 34:422d4d6ae5ea | 52 | bool paused; |
| amutake | 0:c80e972b4c59 | 53 | public: |
| sierra | 6:d0348b7a2f05 | 54 | Sink(Producer* src, rtos::Mail<button_t, MAIL_BOX_SIZE>* box, Mutex* mut); |
| amutake | 0:c80e972b4c59 | 55 | void run(); |
| sierra | 34:422d4d6ae5ea | 56 | void resume(); |
| sierra | 34:422d4d6ae5ea | 57 | void pause(); |
| sierra | 34:422d4d6ae5ea | 58 | void restart(); // reset source |
| amutake | 26:08387521c994 | 59 | void reset(Producer* src); // reset with new source |
| amutake | 0:c80e972b4c59 | 60 | }; |
| amutake | 0:c80e972b4c59 | 61 | |
| sierra | 32:fdf9f6fca8a2 | 62 | class FLL |
| sierra | 32:fdf9f6fca8a2 | 63 | { |
| sierra | 32:fdf9f6fca8a2 | 64 | public: |
| sierra | 32:fdf9f6fca8a2 | 65 | FLL(Producer* p); |
| sierra | 32:fdf9f6fca8a2 | 66 | ~FLL(); |
| sierra | 32:fdf9f6fca8a2 | 67 | void press(button_t btn); |
| sierra | 32:fdf9f6fca8a2 | 68 | void run(); |
| sierra | 32:fdf9f6fca8a2 | 69 | private: |
| sierra | 32:fdf9f6fca8a2 | 70 | Producer *producer; |
| sierra | 34:422d4d6ae5ea | 71 | DigitalOut* pin[BUTTON_NUM]; |
| sierra | 34:422d4d6ae5ea | 72 | int off[BUTTON_NUM]; |
| sierra | 32:fdf9f6fca8a2 | 73 | }; |
| sierra | 32:fdf9f6fca8a2 | 74 | |
| amutake | 7:61b4825304e2 | 75 | // Output reads the next button from mail box and press the button |
| amutake | 7:61b4825304e2 | 76 | // It must be run per 1/60 sec |
| amutake | 0:c80e972b4c59 | 77 | class Output |
| amutake | 0:c80e972b4c59 | 78 | { |
| amutake | 0:c80e972b4c59 | 79 | private: |
| sierra | 3:edbf31a8589f | 80 | rtos::Mail<button_t, MAIL_BOX_SIZE>* mail_box; |
| sierra | 32:fdf9f6fca8a2 | 81 | FLL *fll; |
| amutake | 0:c80e972b4c59 | 82 | public: |
| sierra | 32:fdf9f6fca8a2 | 83 | Output(rtos::Mail<button_t, MAIL_BOX_SIZE>* box, FLL *f); |
| amutake | 0:c80e972b4c59 | 84 | void run(); |
| sierra | 32:fdf9f6fca8a2 | 85 | }; |
