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@26:08387521c994, 2015-02-16 (annotated)
- Committer:
- amutake
- Date:
- Mon Feb 16 18:06:40 2015 +0000
- Revision:
- 26:08387521c994
- Parent:
- 22:b19dc0387288
- Child:
- 33:cc84b10e6c67
Use p20 to reset the sink
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 | 9:0d6631edfc32 | 10 | // buttons represented by 16 bit |
| amutake | 0:c80e972b4c59 | 11 | #define R1 0x0001 |
| amutake | 7:61b4825304e2 | 12 | #define TRIANGLE 0x0002 |
| amutake | 7:61b4825304e2 | 13 | #define CIRCLE 0x0004 |
| amutake | 7:61b4825304e2 | 14 | #define CROSS 0x0008 |
| amutake | 7:61b4825304e2 | 15 | #define SQUARE 0x0010 |
| amutake | 7:61b4825304e2 | 16 | #define R2 0x0020 |
| amutake | 7:61b4825304e2 | 17 | #define START 0x0040 |
| amutake | 7:61b4825304e2 | 18 | #define ANALOG 0x0080 |
| amutake | 7:61b4825304e2 | 19 | #define SELECT 0x0100 |
| amutake | 7:61b4825304e2 | 20 | #define L2 0x0200 |
| amutake | 7:61b4825304e2 | 21 | #define UP 0x0400 |
| amutake | 7:61b4825304e2 | 22 | #define DOWN 0x0800 |
| amutake | 7:61b4825304e2 | 23 | #define LEFT 0x1000 |
| amutake | 7:61b4825304e2 | 24 | #define RIGHT 0x2000 |
| amutake | 7:61b4825304e2 | 25 | #define L1 0x4000 |
| amutake | 0:c80e972b4c59 | 26 | |
| amutake | 2:165723d41023 | 27 | #define MAIL_BOX_SIZE 16 |
| amutake | 0:c80e972b4c59 | 28 | |
| amutake | 8:d16a0fcc2735 | 29 | #define FRAME (1.0 / 60) // 1 frame (sec) |
| amutake | 8:d16a0fcc2735 | 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; |
| amutake | 0:c80e972b4c59 | 50 | public: |
| sierra | 6:d0348b7a2f05 | 51 | Sink(Producer* src, rtos::Mail<button_t, MAIL_BOX_SIZE>* box, Mutex* mut); |
| amutake | 0:c80e972b4c59 | 52 | void run(); |
| amutake | 26:08387521c994 | 53 | void reset(); // reset source |
| amutake | 26:08387521c994 | 54 | void reset(Producer* src); // reset with new source |
| amutake | 0:c80e972b4c59 | 55 | }; |
| amutake | 0:c80e972b4c59 | 56 | |
| amutake | 7:61b4825304e2 | 57 | // Output reads the next button from mail box and press the button |
| amutake | 7:61b4825304e2 | 58 | // It must be run per 1/60 sec |
| amutake | 0:c80e972b4c59 | 59 | class Output |
| amutake | 0:c80e972b4c59 | 60 | { |
| amutake | 0:c80e972b4c59 | 61 | private: |
| sierra | 3:edbf31a8589f | 62 | rtos::Mail<button_t, MAIL_BOX_SIZE>* mail_box; |
| amutake | 0:c80e972b4c59 | 63 | public: |
| sierra | 3:edbf31a8589f | 64 | Output(rtos::Mail<button_t, MAIL_BOX_SIZE>* box); |
| amutake | 0:c80e972b4c59 | 65 | void run(); |
| amutake | 0:c80e972b4c59 | 66 | }; |
| amutake | 0:c80e972b4c59 | 67 | |
| amutake | 7:61b4825304e2 | 68 | // tells dualshock2 circuit which button is pressed |
| amutake | 8:d16a0fcc2735 | 69 | void press(button_t btn); |
| amutake | 8:d16a0fcc2735 | 70 | |
| amutake | 11:21b3b0494baa | 71 | // init function |
| amutake | 11:21b3b0494baa | 72 | void fll_init(); |
| amutake | 11:21b3b0494baa | 73 | |
| amutake | 8:d16a0fcc2735 | 74 | // main function |
| amutake | 8:d16a0fcc2735 | 75 | void fll_run(Producer* producer); |
