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@32:fdf9f6fca8a2, 2015-02-17 (annotated)
- Committer:
- sierra
- Date:
- Tue Feb 17 03:19:06 2015 +0000
- Revision:
- 32:fdf9f6fca8a2
- Parent:
- 18:c5d3a4d6e8e5
- Child:
- 33:cc84b10e6c67
Move main process to FLL class
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 | |
| amutake | 8:d16a0fcc2735 | 12 | #define FRAME (1.0 / 60) // 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; |
| sierra | 6:d0348b7a2f05 | 39 | }; |
| sierra | 6:d0348b7a2f05 | 40 | |
| amutake | 7:61b4825304e2 | 41 | // Sink is the end of button stream network |
| amutake | 7:61b4825304e2 | 42 | // It sends next button to Output object through rtos::Mail |
| amutake | 0:c80e972b4c59 | 43 | class Sink |
| amutake | 0:c80e972b4c59 | 44 | { |
| amutake | 0:c80e972b4c59 | 45 | private: |
| sierra | 6:d0348b7a2f05 | 46 | Producer* source; |
| sierra | 3:edbf31a8589f | 47 | rtos::Mail<button_t, MAIL_BOX_SIZE>* mail_box; |
| amutake | 2:165723d41023 | 48 | Mutex* mutex; |
| amutake | 0:c80e972b4c59 | 49 | public: |
| sierra | 6:d0348b7a2f05 | 50 | Sink(Producer* src, rtos::Mail<button_t, MAIL_BOX_SIZE>* box, Mutex* mut); |
| amutake | 0:c80e972b4c59 | 51 | void run(); |
| sierra | 6:d0348b7a2f05 | 52 | void reset(Producer* src); |
| amutake | 0:c80e972b4c59 | 53 | }; |
| amutake | 0:c80e972b4c59 | 54 | |
| sierra | 32:fdf9f6fca8a2 | 55 | class FLL |
| sierra | 32:fdf9f6fca8a2 | 56 | { |
| sierra | 32:fdf9f6fca8a2 | 57 | public: |
| sierra | 32:fdf9f6fca8a2 | 58 | FLL(Producer* p); |
| sierra | 32:fdf9f6fca8a2 | 59 | ~FLL(); |
| sierra | 32:fdf9f6fca8a2 | 60 | void press(button_t btn); |
| sierra | 32:fdf9f6fca8a2 | 61 | void run(); |
| sierra | 32:fdf9f6fca8a2 | 62 | private: |
| sierra | 32:fdf9f6fca8a2 | 63 | Producer *producer; |
| sierra | 32:fdf9f6fca8a2 | 64 | DigitalOut **pin; |
| sierra | 32:fdf9f6fca8a2 | 65 | int **off; |
| sierra | 32:fdf9f6fca8a2 | 66 | }; |
| sierra | 32:fdf9f6fca8a2 | 67 | |
| amutake | 7:61b4825304e2 | 68 | // Output reads the next button from mail box and press the button |
| amutake | 7:61b4825304e2 | 69 | // It must be run per 1/60 sec |
| amutake | 0:c80e972b4c59 | 70 | class Output |
| amutake | 0:c80e972b4c59 | 71 | { |
| amutake | 0:c80e972b4c59 | 72 | private: |
| sierra | 3:edbf31a8589f | 73 | rtos::Mail<button_t, MAIL_BOX_SIZE>* mail_box; |
| sierra | 32:fdf9f6fca8a2 | 74 | FLL *fll; |
| amutake | 0:c80e972b4c59 | 75 | public: |
| sierra | 32:fdf9f6fca8a2 | 76 | Output(rtos::Mail<button_t, MAIL_BOX_SIZE>* box, FLL *f); |
| amutake | 0:c80e972b4c59 | 77 | void run(); |
| sierra | 32:fdf9f6fca8a2 | 78 | }; |
