Пример #1
0
/*---------------------------------------------------------------------------*/
INT8U RTC_RandomRead(INT8U Address)
// Description:
//   Random Read Operation. Data is read from the RTC. The RTC
//   address is defined with the parameter Address.
{

	INT8U data_in;
#if (defined I2C_SW &&  I2C_SW == 1)
	CRITICAL_SECTION_START();
	sw_i2c_start();							// Send start signal

	sw_i2c_write(DS1307Address);		// Send identifer I2C address  (10100000b)
	delay_time(I2C_DELAY);
	sw_i2c_write((INT8U) Address);			// Send address to EEPROM
	delay_time(I2C_DELAY);
	sw_i2c_start();							// Send I2C Start Transfer
	sw_i2c_write(DS1307Address | 1);	// Send identifer I2C address  (10100001b)
	delay_time(I2C_DELAY);
	data_in = sw_i2c_read(0);			// Read byte
	sw_i2c_stop();			 // Send I2C Stop Transfer
	
	CRITICAL_SECTION_END();
#else
	IIC_transmite(DS1307Address, Address, NULL);
	IIC_recebe(DS1307Address, &data_in);
#endif
	return data_in;

}
Пример #2
0
unsigned char TOS_parampost(void (*tp) (), uint32_t arg) {

  DECLARE_CRITICAL_SECTION();
  uint8_t tmp;
  
  //  dbg(DBG_SCHED, ("TOSH_post: %d 0x%x\n", TOSH_sched_free, (int)tp));
  
  CRITICAL_SECTION_BEGIN();

  tmp = TOSH_sched_free;
  
  if (TOSH_queue[tmp].tp == 0x0) {
#ifdef TASK_QUEUE_DEBUG
    occupancy++;
    if (occupancy > max_occupancy) {
       max_occupancy = occupancy;
    }
#endif
    if(pushqueue(&paramtaskQueue, arg)){
    
      TOSH_sched_free = (tmp + 1) & sys_task_bitmask;
      TOSH_queue[tmp].tp = tp;
      TOSH_queue[tmp].postingFunction = (void *)__builtin_return_address(0);
      TOSH_queue[tmp].timestamp = OSCR0;
      TOSH_queue[tmp].executeTime = 0;
    }
    else{
      printFatalErrorMsg("paramtaskqueue full",0);
    }
      
    CRITICAL_SECTION_END();

    return 0x1;
  }
  else {	
#ifdef TASK_QUEUE_DEBUG
    failed_post++;
#endif
    CRITICAL_SECTION_END();
    printFatalErrorMsg("TaskQueue Full.  Size = ", 1,sys_max_tasks);
    return 0x0;
  }
}
Пример #3
0
INT8U RTC_DS1307_Init(void)
{
#if (defined I2C_SW &&  I2C_SW == 1)
	INT8U ret = NO_I2C_ACK;
	CRITICAL_SECTION_START();
		sw_i2c_init();
	CRITICAL_SECTION_END();
	
	sw_i2c_start();							// Send start signal
	ret = sw_i2c_write(DS1307Address);		// Send identifer I2C address  (10100000b)
	delay_time(I2C_DELAY);
	sw_i2c_stop();	
	
	return ((ret == OK_I2C_ACK) ? TRUE : FALSE);
	
#else
	IIC_init();
#endif

}
Пример #4
0
/*---------------------------------------------------------------------------*/
INT8U RTC_CurrentAddressRead(void)
// Description:
//   Current Address Read Operation. Data is read from the RTC. The current
//   address from the RTC is used.
{

	INT8U data_in;

#if (defined I2C_SW &&  I2C_SW == 1)
	CRITICAL_SECTION_START();
	sw_i2c_start();				// Send I2C Start Transfer        				
	sw_i2c_write(DS1307Address | 1);	// Send identifer I2C address  (10100001b)
	data_in = sw_i2c_read(0);				// Read byte
	sw_i2c_stop();				// Send I2C Stop Transfer
	CRITICAL_SECTION_END();
#else
	IIC_recebe(DS1307Address, &data_in);
#endif
	return data_in;

}
Пример #5
0
void RTC_ByteWrite(INT8U Address, INT8U Data)
// Description:
//   Byte Write Operation. The communication via the I2C bus with an EEPROM
//   (2465) is realized. A data byte is written into a user defined address.
{

#if (defined I2C_SW &&  I2C_SW == 1)
	CRITICAL_SECTION_START();
	sw_i2c_start();							// Send start signal
	sw_i2c_write(DS1307Address & 0b11111110);// Send identifier I2C address     0xA0 = 10100000b
	delay_time(I2C_DELAY);
	sw_i2c_write((INT8U) Address);// Send address to RTC  (byte address) 
	delay_time(I2C_DELAY);
	sw_i2c_write(Data);					// Send low byte to RTC  (data to write)
	delay_time(I2C_DELAY); // Delay a period of time to write   
	sw_i2c_stop();	   // Send I2C Stop Transfer
	delay_time(20);	   // Delay a period of time to write
	CRITICAL_SECTION_END();
#else
	IIC_transmite(DS1307Address, Address, &Data);
#endif
}