Example #1
0
void DS1302_write(int address, uint8_t data)
{
  // clear lowest bit (read bit) in address
  bitClear(address, DS1302_READBIT);
  _DS1302_start();
  _DS1302_togglewrite(address, false);
  _DS1302_togglewrite(data, false);
  _DS1302_stop();
}
Example #2
0
uint8_t DS1302_read(int address)
{
  uint8_t data;
  bitSet(address, DS1302_READBIT);
  _DS1302_start();
  _DS1302_togglewrite(address, true);
  data = _DS1302_toggleread();
  _DS1302_stop();
  return (data);
}
Example #3
0
void DS1302_clock_burst_read(uint8_t *p)
{
  int i;
  _DS1302_start();
  _DS1302_togglewrite(DS1302_CLOCK_BURST_READ, true);
  for (i = 0; i<8; i++)
  {
    *p++ = _DS1302_toggleread();
  }
  _DS1302_stop();
}
Example #4
0
void DS1302_clock_burst_write(uint8_t *p)
{
  int i;
  _DS1302_start();
  _DS1302_togglewrite(DS1302_CLOCK_BURST_WRITE, false);

  for (i = 0; i<8; i++)
  {
    _DS1302_togglewrite(*p++, false);
  }
  _DS1302_stop();
}
Example #5
0
// --------------------------------------------------------
// DS1302_read
//
// This function reads a byte from the DS1302 
// (clock or ram).
//
// The address could be like "0x80" or "0x81", 
// the lowest bit is set anyway.
//
// This function may be called as the first function, 
// also the pinMode is set.
//
uint8_t DS1302_read(int address)
{
  uint8_t data;

  // set lowest bit (read bit) in address
  bitSet( address, DS1302_READBIT);  

  _DS1302_start();
  // the I/O-line is released for the data
  _DS1302_togglewrite( address, true);  
  data = _DS1302_toggleread();
  _DS1302_stop();

  return (data);
}
Example #6
0
// --------------------------------------------------------
// DS1302_clock_burst_read
//
// This function reads 8 bytes clock data in burst mode
// from the DS1302.
//
// This function may be called as the first function, 
// also the pinMode is set.
//
void DS1302_clock_burst_read( uint8_t *p)
{
  int i;

  _DS1302_start();

  // Instead of the address, 
  // the CLOCK_BURST_READ command is issued
  // the I/O-line is released for the data
  _DS1302_togglewrite( DS1302_CLOCK_BURST_READ, true);  

  for( i=0; i<8; i++)
  {
    *p++ = _DS1302_toggleread();
  }
  _DS1302_stop();
}
Example #7
0
// --------------------------------------------------------
// DS1302_clock_burst_write
//
// This function writes 8 bytes clock data in burst mode
// to the DS1302.
//
// This function may be called as the first function, 
// also the pinMode is set.
//
void DS1302_clock_burst_write( uint8_t *p)
{
  int i;

  _DS1302_start();

  // Instead of the address, 
  // the CLOCK_BURST_WRITE command is issued.
  // the I/O-line is not released
  _DS1302_togglewrite( DS1302_CLOCK_BURST_WRITE, false);  

  for( i=0; i<8; i++)
  {
    // the I/O-line is not released
    _DS1302_togglewrite( *p++, false);  
  }
  _DS1302_stop();
}