This is THE 447 FINAL PROJECT this is the frame work put your code in the spot where the it suppose to go and. Make sure you import this into your complier and work on your section, once you done just commit the changes and fork to a new folder

Dependencies:   mbed-rtos mbed draw_test EALib SWSPI

main.cpp

Committer:
AndyTran
Date:
2015-12-01
Revision:
1:3f7aa28da00d
Parent:
0:4abb197a773c
Child:
2:b14759e704c7

File content as of revision 1:3f7aa28da00d:

#include "mbed.h"
#include "cmsis_os.h"

//declare your input pin and output pin here:
//DigitalOut led1(p25);
//DigitalOut led2(p26);
//DigitalOut led3(p28);
//
// declare you globle variable here:
unsigned char X_coor = 0,Y_coor = 0x0A;
unsigned char LEDs = ((X_coor << 8)|Y_coor);
//X_coor is x coordinate from 0 to 6
//Y_coor is y coordinate form A to F
//
//
//

// this thread is your SPI communication between 2 board
void SPI_communication(void const *args) {
    //spi code here
}

// joystick update x_coor and y_coor here
void joy_stick_read(void const *args) { //might be an interrupt thread here for interrupt read of joystick
    // joy stick to update global val of x_coor and y_coor;
    // update the 8 LEDs here
}

// this thread use to update the game board
void game_view_update () {
    // update the by led game update
    // Uart runing at 921600 max speed; hopefully print 1 line and out;
    // x = hit
    // o = miss
    // > = your ship ship

    // BLANK game Board
    // F _ _ _ _ _ _   F _ _ _ _ _ _ 
    // E _ _ _ _ _ _   E _ _ _ _ _ _ 
    // D _ _ _ _ _ _   D _ _ _ _ _ _ 
    // C _ _ _ _ _ _   C _ _ _ _ _ _ 
    // B _ _ _ _ _ _   B _ _ _ _ _ _ 
    // A _ _ _ _ _ _   A _ _ _ _ _ _ 
    //   1 2 3 4 5 6     1 2 3 4 5 6
    // Friendly        Enemy
    
    // Example of running game
    // F _ O _ > _ _   F _ O _ _ _ _ 
    // E > _ O _ > _   E _ _ X _ _ _ 
    // D _ _ > _ _ _   D _ _ _ O _ _ 
    // C O _ _ _ _ _   C _ O _ _ _ _ 
    // B _ X _ O _ _   B _ _ _ X _ _ 
    // A _ _ _ > _ _   A _ _ _ _ _ _ 
    //   1 2 3 4 5 6     1 2 3 4 5 6
    // Friendly        Enemy
    // Turn 1 = miss at 2F
    // Turn 2 = Destroy Enemy battle ship at 3E
    // Turn 3 = miss at 4D
    // Turn 4 = miss at 2C
    // Tunr 5 = Destroy Enemy battle ship at 4B 
           
}

// code here to check for winer and turn on the RGB
void winnercheck () {
    //check for winner by some condition
}

//read the accele
void checkreset () {
    //read the acceleron meter and compare against the previous value to
    //determine if the board have been shake the reset the game board;
}


osThreadDef(SPI_communication, osPriorityNormal, DEFAULT_STACK_SIZE); //comm between 2 board
osThreadDef(joy_stick_read, osPriorityNormal, DEFAULT_STACK_SIZE);//might be an interrupt;
osThreadDef(game_view_update, osPriorityNormal, DEFAULT_STACK_SIZE);//update game view write to the fifo uart buffer
osThreadDef(winnercheck, osPriorityNormal, DEFAULT_STACK_SIZE); //check for winner
osThreadDef(checkreset, osPriorityNormal, DEFAULT_STACK_SIZE); //check for reset

int main() {
    osThreadCreate(osThread(SPI_communication), NULL);
    osThreadCreate(osThread(joy_stick_read), NULL);
    osThreadCreate(osThread(game_view_update), NULL);
    osThreadCreate(osThread(winnercheck), NULL);
    osThreadCreate(osThread(checkreset), NULL);
    // initialize all peripheral here
    //
    //
    //
    
    //Main Thread
    while (true) {
        //check status and update status
    }
}