piccolo 2

Dependencies:   mbed

Fork of 01-02EjercicioComunicacionSerial by ferney alberto beltran molina

main.cpp

Committer:
jeanmojica05
Date:
2018-03-15
Revision:
1:7e0035a62222
Parent:
0:abaa541e10d5

File content as of revision 1:7e0035a62222:

#include "mbed.h"
#include "draw.h"

#define CM_EJECUTAR 0xff
#define CM_GUARDAR 0xfe
#define CM_VERTEX2D 0xfd
#define CM_DRAW 0xfc
#define CM_NODRAW 0xfb
#define CM_STOP 0xfa
#define CM_END 0xf0
#define MEM_SIZE 5000
#define MEM_TYPE uint32_t

int mem_head = 0;
int mem_tail = 0;
uint32_t full = 0;


MEM_TYPE buffer[MEM_SIZE];
Serial command(USBTX, USBRX);

uint32_t mem_free()
{
 mem_head=0;
 full=0;
}

uint32_t mem_put(MEM_TYPE data)
{
 
    if (full)
        return 1;
    buffer[mem_head] = data;
    mem_head += 1;
    if (mem_head == MEM_SIZE)
        full =1;
    return 0;
}
uint32_t mem_get(MEM_TYPE* data)
{
    if (mem_head == 0)
        return 1; 
    if (mem_head == mem_tail)
        return 1; 
    
 
    *data = buffer[mem_tail];
    mem_tail += 1;
  
    return 0;
}

void ejecutar(){
    command.printf("se esta ejecutando el dibujo...");    
    // ubicar acà el codigo
    uint32_t mem_free();
    
}
void guardar(){
    command.printf("se inicia el comado de guardar..");    
    // ubicar acà el codigo
     uint32_t mem_get(MEM_TYPE* data);
}
void init_serial()
{
    command.baud(9600);    
}
int main() {
    command.printf("se inicia el comado de guardar..");   
}