/** \brief Turn ON the Cooler -> LED RGB BLUE
 **
 ** \param[in] fd_out file descriptor for digital output ports
 **/
static void turnON_Cooler(int32_t fd_out){
	/* write RGB B */
   uint8_t outputs;
   ciaaPOSIX_read(fd_out, &outputs, 1);
   outputs |= RGBB;
   ciaaPOSIX_write(fd_out, &outputs, 1);
}
Ejemplo n.º 2
0
void botonera_CIAA()
{

	/*
	 * BOTONERA DE LA CIAA
	 *
	 * De izquierda a derecha
	 *
	 * Boton 1: SHIFT
	 * Boton 2: IZQUIERDA
	 * Boton 3: DERECHA
	 * Boton 4: ENTER
	 */

	ciaaPOSIX_read(fd_in, &inputs, 1);

	if((inputs&0x01) == 0)
		boton_seleccionado = SHIFT;

	if((inputs&0x02) == 0)
		boton_seleccionado = IZQUIERDA;

	if((inputs&0x04) == 0)
		boton_seleccionado = DERECHA;

	if((inputs&0x08) == 0)
		boton_seleccionado = ENTER;
}
/** \brief Turn OFF the Heater -> LED RGB RED
 **
 ** \param[in] fd_out file descriptor for digital output ports
 **/
static void turnOFF_Heater(int32_t fd_out)
{
   /* write RGB R */
   uint8_t outputs;
   ciaaPOSIX_read(fd_out, &outputs, 1);
   outputs &= ~RGBR;
   ciaaPOSIX_write(fd_out, &outputs, 1);
}
Ejemplo n.º 4
0
void teclado_task(void)
{
   uint8_t inputs;

   /* lee el estado de las entradas */
   ciaaPOSIX_read(fd_in, &inputs, 1);

   /* detecta flanco ascendente */
   teclasFlancoUP |= (inputs ^ estadoTeclas) & inputs;

   /* guarda el nuevo estado de las teclas */
   estadoTeclas = inputs;
}
Ejemplo n.º 5
0
int AT24C512_I2C_Leer(uint8_t addr, uint8_t *pBuf_out, uint32_t len_out, uint8_t *pBuf_in, uint32_t len_in)
{
	uint32_t reg = 0UL;
	reg |=  ((uint32_t)pBuf_out[0]) << 8;
	reg |=  ((uint32_t)pBuf_out[1]) << 0;

	ciaaPOSIX_ioctl(i2cExpansion, ciaaPOSIX_IOCTL_SET_SLAVEADD, 			(void *)addr);
	ciaaPOSIX_ioctl(i2cExpansion, ciaaPOSIX_IOCTL_SET_REGISTERADDWIDTH, 	(void *)len_out);
	ciaaPOSIX_ioctl(i2cExpansion, ciaaPOSIX_IOCTL_SET_REGISTERADD, 			(void *)reg);
	len_in = ciaaPOSIX_read(i2cExpansion, pBuf_in, len_in);

	return len_in;
}
/** \brief Send Temperature to UART
 **
 ** \param[in] tempNow temperature to send multiplied by 10
 **/
static void sendTemp_Uart(uint32_t tempNow)
{
   char data_to_send[10];
   uint8_t outputs;

   convert_temp_to_ascii(tempNow, data_to_send);

   ciaaPOSIX_write(fd_uart1, data_to_send, ciaaPOSIX_strlen(data_to_send));

   /* Toggle LED 1 */
   ciaaPOSIX_read(fd_out, &outputs, 1);
   outputs ^= LED1;
   ciaaPOSIX_write(fd_out, &outputs, 1);
}
Ejemplo n.º 7
0
int MPU6050_I2C_Leer(uint8_t addr, uint8_t *pBuf_out, uint32_t len_out, uint8_t *pBuf_in, uint32_t len_in)
{
	uint32_t reg = 0UL;
	int i;
	for(i = 0; i < len_out; i++)
	{
		reg |=  pBuf_out[i] << (8*i);
	}

	ciaaPOSIX_ioctl(i2cExpansion, ciaaPOSIX_IOCTL_SET_SLAVEADD, 			(void *)addr);
	ciaaPOSIX_ioctl(i2cExpansion, ciaaPOSIX_IOCTL_SET_REGISTERADDWIDTH, 	(void *)len_out);
	ciaaPOSIX_ioctl(i2cExpansion, ciaaPOSIX_IOCTL_SET_REGISTERADD, 			(void *)reg);
	len_in = ciaaPOSIX_read(i2cExpansion, pBuf_in, len_in);

	return len_in;
}
Ejemplo n.º 8
0
void ciaaKeyboard_MainTask(void){

    static uint8_t Column, Row = 0;
    static uint8_t prev_col = 5;
    static uint8_t prev_row = 5;
    uint8_t err;

    if(0 != change_keyb_func){
    	ciaaKeyboard_FunctionInit(change_keyb_func);
    }

	err = ciaaPOSIX_ioctl(fd_keyb,KEYB_LINE_CTRL,Row);

	if(err == (-1)){
	   /* Error. ioctl function cannot be done */
	   ciaaPOSIX_printf("Error changing Active Line\n");
	   while(1);
	}


	err = ciaaPOSIX_read(fd_keyb,&Column,1);

	if(err == (-1)){
	   /* Error. read function cannot be done */
	   ciaaPOSIX_printf("Error reading Keyboard\n");
	   while(1);
	}

	if(0xFF != Column)
	{

	if((Row != prev_row) && (Column != prev_col))
	{
		err = functions[Row][Column]();
	    prev_row = Row;
	    prev_col = Column;
	}
	}

	if(MAX_COLUMN <= Row){
		Row = 0;
	}
	else{
		Row++;
	}
}
Ejemplo n.º 9
0
int LeerEntradas(void)
{
	ciaaPOSIX_read(fd_teclado, &estado_teclas, 1);
	ciaaPOSIX_read(fd_leds, &estado_leds, 1);
	return 1;
}
Ejemplo n.º 10
0
/*==================[internal functions definition]==========================*/
static uint16_t cmd0x03ReadHoldingReg(
       uint16_t start,
       uint16_t quantity,
       uint8_t * exceptioncode,
       uint8_t * buf
       )
{
   /* used to store holding register value */
   uint16_t hrValue;
   /* used to indicate quantity of registers processed */
   int16_t quantityRegProcessed;
/* used to indicate total of registers reads */
   int8_t ret = 0;
/* used to store input or outputs byte */
   uint8_t inOutValue;

   /* loop to read all registers indicated */
   do
   {
      /* select register address to be read */
      switch (start)
      {
         /* read inputs of CIAA */
         case CIAA_MODBUS_ADDRESS_INPUTS:
            ciaaPOSIX_read(fd_in, &inOutValue, 1);
            hrValue = inOutValue;
            ciaaModbus_writeInt(buf, hrValue);
            quantityRegProcessed = 1;
            break;

         /* read outputs of CIAA */
         case CIAA_MODBUS_ADDRESS_OUTPUS:
            ciaaPOSIX_read(fd_out, &inOutValue, 1);
            hrValue = inOutValue;
            ciaaModbus_writeInt(buf, hrValue);
            quantityRegProcessed = 1;
            break;

         /* wrong address */
         default:
            *exceptioncode = CIAA_MODBUS_E_WRONG_STR_ADDR;
            quantityRegProcessed = -1;
            break;
      }

      /* if quantityRegProcessed > 0, successful operation */
      if (quantityRegProcessed > 0)
      {
         /* update buffer pointer to next register */
         buf += (quantityRegProcessed*2);

         /* next address to be read */
         start += quantityRegProcessed;

         /* increment count of registers */
         ret += quantityRegProcessed;
      }
      else
      {
         /* an error occurred in reading */
         ret = -1;
      }
      /* repeat until:
      * - read total registers or
      * - error occurs
      */
   }while ((ret > 0) && (ret < quantity));

   return ret;
}
Ejemplo n.º 11
0
void obtener_boton()
{
	uint16_t i;
	uint16_t inputs = 0x00;

	botonera_CIAA();

	//TECLADO EXTERNO

	/*
	* SALIDAS (outputs)
	*
	*Utilizamos el registro outputs configurado para 16 bits (2 bytes)
	*
	* Bits: 7 al 10 -> xxxx xx11 11xx xxxx
	*
	* Las mantenemos en alto a todas menos a la que queremos testear.
	* Utilizamos pull-up, lo que quiere decir que esperamos un 0 al apretar un boton
	*
	*
	*
	* ENTRADAS (inputs)
	*
	* Utilizamos el registro inputs configurado para 8 bits (1 byte)
	*
	* Bits: 5 al 7 -> x111 xxxx
	*
	* preguntamos por cual de todos estara en 0
	* el resto estara en 1
	*
	*/

	//FILA 1
	outputs = outputs & 0xFFBF; 				//xxxx xx11 10xx xxxx
	outputs = outputs | 0x0380;
	ciaaPOSIX_write(fd_out, &outputs, 2);
	ciaaPOSIX_read(fd_in, &inputs, 1);

	if((inputs&0x10)==0)  		//COLUMNA 1
	{
	   for(i = 0; i<0xFFF; i++);
	   if((inputs&0x10)==0)
		   boton_seleccionado = 1;
	}


	if((inputs&0x20)==0)		//COLUMNA 2
	{
	   for(i = 0; i<0xFFF; i++);	//anti rebote
	   if((inputs&0x20)==0)			//confirme boton
		   boton_seleccionado = 2;
	}

	if((inputs&0x40)==0)		//COLUMNA 3
	{
	   for(i = 0; i<0xFFF; i++);
	   if((inputs&0x40)==0)
		   boton_seleccionado = 3;
	}


	//FILA 2
	outputs = outputs & 0xFF7F;				//xxxx xx11 01xx xxxx
	outputs = outputs | 0x0340;
	ciaaPOSIX_write(fd_out, &outputs, 2);
	ciaaPOSIX_read(fd_in, &inputs, 1);

	if((inputs&0x10)==0)  		//COLUMNA 1
	{
	   for(i = 0; i<0xFFF; i++);
	   if((inputs&0x10)==0)
		   boton_seleccionado = 4;
	}

	if((inputs&0x20)==0)		//COLUMNA 2
	{
	   for(i = 0; i<0xFFF; i++);
	   if((inputs&0x20)==0)
		   boton_seleccionado = 5;
	}

	if((inputs&0x40)==0)		//COLUMNA 3
	{
	   for(i = 0; i<0xFFF; i++);
	   if((inputs&0x40)==0)
		   boton_seleccionado = 6;
	}

	//FILA 3
	outputs = outputs & 0xFEFF;				//xxxx xx10 11xx xxxx
	outputs = outputs | 0x02c0;
	ciaaPOSIX_write(fd_out, &outputs, 2);
	ciaaPOSIX_read(fd_in, &inputs, 1);

	if((inputs&0x10)==0)  		//COLUMNA 1
	{
	   for(i = 0; i<0xFFF; i++);
	   if((inputs&0x10)==0)
		   boton_seleccionado = 7;
	}

	if((inputs&0x20)==0)		//COLUMNA 2
	{
	   for(i = 0; i<0xFFF; i++);
	   if((inputs&0x20)==0)
		   boton_seleccionado = 8;
	}

	if((inputs&0x40)==0)		//COLUMNA 3
	{
	   for(i = 0; i<0xFFF; i++);
	   if((inputs&0x40)==0)
		   boton_seleccionado = 9;
	}

	//FILA 4
	outputs = outputs & 0xFDFF;				//xxxx xx01 11xx xxxx
	outputs = outputs | 0x01c0;
	ciaaPOSIX_write(fd_out, &outputs, 2);
	ciaaPOSIX_read(fd_in, &inputs, 1);

	if((inputs&0x10)==0)		//COLUMNA 1
	{
	   for(i = 0; i<0xFFF; i++);
	   if((inputs&0x10)==0)
		   boton_seleccionado = BORRAR;
	}

	if((inputs&0x20)==0)		//COLUMNA 2
	{
	   for(i = 0; i<0xFFF; i++);
	   if((inputs&0x20)==0)
		   boton_seleccionado = 0;
	}

	if((inputs&0x40)==0)		//COLUMNA 3
	{
	   for(i = 0; i<0xFFF; i++);
	   if((inputs&0x40)==0)
		   boton_seleccionado = CONFIRMAR;
	}

}