Shohei Yasutake / Mbed 2 deprecated koibumi2000

Dependencies:   fll mbed-rtos mbed

fll.h

Committer:
sierra
Date:
2015-02-13
Revision:
1:1abcd83947bf
Parent:
0:c80e972b4c59
Child:
2:165723d41023

File content as of revision 1:1abcd83947bf:

// Frame Level Language
// header

#include "mbed.h"
#include "rtos.h"
#include <stdint.h>
#include <vector>

#define R1 0x0001
#define B_TRIANGLE 0x0002
#define B_CIRCLE 0x0004
#define B_CROSS 0x0008
#define B_SQUARE 0x0010
#define B_R2 0x0020
#define B_START 0x0040
#define B_ANALOG 0x0080
#define B_SELECT 0x0100
#define B_L2 0x0200
#define B_UP 0x0400
#define B_DOWN 0x0800
#define B_LEFT 0x1000
#define B_RIGHT 0x2000
#define B_L1 0x4000

#define QUEUE_SIZE 16

typedef uint16_t button;

class Source
{
private:
    int i;
    button* button_seq;
    int size;
    bool loop;
public:
    Source(button *bs, int s, bool l);
    virtual button await();
};

class Flow : Source
{
private:
    vector<Source*>& sources;
public:
    Flow(vector<Source*> &srcs);
    virtual button fold(vector<button> &bs);
    virtual button await();
};

// ストリームの終端になっていて、キー入力をするスレッドに向けてキーを送る
class Sink
{
private:
    Source* source;
    rtos::Mail<button, QUEUE_SIZE>* queue;
    Mutex* queueMutex; // Main Thread と同じ Mutex でなければいけない
public:
    Sink(Source* src, rtos::Mail<button, QUEUE_SIZE>* q, Mutex* mut);
    void run();
    void reset(Source* src);
};


class Output
{
private:
    rtos::Mail<button, QUEUE_SIZE>* queue;
public:
    Output(rtos::Mail<button, QUEUE_SIZE>* q);
    void run();
};

void press(button btn);