Shohei Yasutake / Mbed 2 deprecated koibumi2000

Dependencies:   fll mbed-rtos mbed

fll.h

Committer:
sierra
Date:
2015-02-14
Revision:
29:2f3d6d09eaac
Parent:
6:d0348b7a2f05

File content as of revision 29:2f3d6d09eaac:

// Frame Level Language
// header

#ifndef __FLL_H__
#define __FLL_H__

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

#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 MAIL_BOX_SIZE 16

typedef uint16_t button_t;

// Base object for stream network
class Producer {
public:
    virtual button_t await() = 0;
};

// ストリームの終端になっていて、キー入力をするスレッドに向けてキーを送る
class Sink
{
private:
    Producer* source;
    rtos::Mail<button_t, MAIL_BOX_SIZE>* mail_box;
    Mutex* mutex;
public:
    Sink(Producer* src, rtos::Mail<button_t, MAIL_BOX_SIZE>* box, Mutex* mut);
    void run();
    void reset(Producer* src);
};


class Output
{
private:
    rtos::Mail<button_t, MAIL_BOX_SIZE>* mail_box;
public:
    Output(rtos::Mail<button_t, MAIL_BOX_SIZE>* box);
    void run();
};

void press(button_t btn);

#endif