本文整理汇总了C++中ow_reset函数的典型用法代码示例。如果您正苦于以下问题:C++ ow_reset函数的具体用法?C++ ow_reset怎么用?C++ ow_reset使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ow_reset函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: writeSP
// write to scratchpad of a SINGLE sensor
void writeSP(int brdNo) {
int i;
int get[8];
ow_reset();
write_byte(0xCC);
write_byte(0x4E);
write_byte(brdNo);
write_byte(0x0);
write_byte(0x7F);
while(read_bit() == 0);
ow_reset();
write_byte(0xCC);
write_byte(0x48);
uDelay(120);
ow_reset();
write_byte(0xCC);
uDelay(120);
write_byte(0xBE);
for (i = 0 ; i < 9 ; i++){
get[i] = read_byte();
}
if(get[2] != brdNo || get[3] != 0 || get[4] != 0x7F) {
UART_printf("BAD CONFIGURATION?\n");
}
}
示例2: ow_read_temperature
int ow_read_temperature(void)
{
char get[10];
char temp_lsb,temp_msb;
int k;
char temp_c;
//char temp_f;
ow_reset();
ow_write_byte(0xCC); //Skip ROM
ow_write_byte(0x44); // Start Conversion
delay_usec(119); //wait 120us
ow_reset();
ow_write_byte(0xCC); // Skip ROM
ow_write_byte(0xBE); // Read Scratch Pad
for (k=0; k<9; k++) {
get[k] = ow_read_byte();
}
temp_msb = get[1]; // Sign byte + lsbit
temp_lsb = get[0]; // Temp data plus lsb
if (temp_msb <= 0x80){temp_lsb = (temp_lsb/2);} // shift to get whole degree
temp_msb = temp_msb & 0x80; // mask all but the sign bit
if (temp_msb >= 0x80) {temp_lsb = (~temp_lsb)+1;} // twos complement
if (temp_msb >= 0x80) {temp_lsb = (temp_lsb/2);}// shift to get whole degree
if (temp_msb >= 0x80) {temp_lsb = ((-1)*temp_lsb);} // add sign bit
temp_c = temp_lsb; // ready for conversion to Fahrenheit
//temp_f = (((int)temp_c)* 9)/5 + 32;
return temp_c;
}
示例3: DS18X20_get_power_status
/* get power status of DS18x20
input : id = rom_code
returns: DS18X20_POWER_EXTERN or DS18X20_POWER_PARASITE */
uint8_t DS18X20_get_power_status(uint8_t id[])
{
uint8_t pstat;
ow_reset();
ow_command(DS18X20_READ_POWER_SUPPLY, id);
pstat=ow_bit_io(1); // pstat 0=is parasite/ !=0 ext. powered
ow_reset();
return (pstat) ? DS18X20_POWER_EXTERN:DS18X20_POWER_PARASITE;
}
示例4: ds18x20_get_power_status
unsigned char ds18x20_get_power_status(void)
{
ow_reset();
send_selected_rom();
ow_put_byte(READ_POWER_SUPPLY);
power_status=ow_get_bit();
ow_reset();
return(power_status);
}
示例5: ds18x20_get_scratchpad
void ds18x20_get_scratchpad(unsigned char *mem_array)
{
unsigned char x=0;
ow_reset();
send_selected_rom();
ow_put_byte(READ_SCRATCHPAD);
for(x=0; x<9; x++) {*(mem_array+x)=ow_get_byte(); }
ow_reset();
return;
}
示例6: OneWireInit
void OneWireInit(void)
{
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOE, ENABLE);
ow_reset();
ow_write_byte(0xcc);
ow_write_byte(0x4e);
ow_write_byte(0);
ow_write_byte(0);
ow_write_byte(0x60); // 12 bit
ow_reset();
}
示例7: tempSense
/* tempSense() - returns temperature (in celcius) of device ROM
* to specify which device is read, pass in the index of the device (ROM)
* in the foundROM array
*
* FINDING THE BOARD NUMBER OF A TEMPERATURE READ
* The board number is returned as the 16 MSB of tempSense()'s return
* value
* i.e. for temperature = tempSense(x) | 0x7F
* i.e. for board number = tempSense(x) >> 16
*/
int tempSense(int ROM) {
char get[10];
char temp_lsb, temp_msb;
int k, i;
ow_reset();
write_byte(0x55);
uDelay(10);
for(i = 0 ; i < 8 ; i++) {
write_byte(FoundROM[ROM][i]);
}
write_byte(0x44); // Start Conversion
uDelay(102);
ow_reset();
write_byte(0x55);
uDelay(10);
for(i = 0 ; i < 8 ; i++) {
write_byte(FoundROM[ROM][i]);
}
// Read Scratch Pad
write_byte(0xBE);
for (k=0;k<9;k++){
get[k]=read_byte();
}
temp_msb = get[1]; // Sign byte + lsbit
temp_lsb = get[0]; // Temp data plus lsb
// shift to get whole degree
if (temp_msb <= 0x80)
temp_lsb = (temp_lsb/2);
// mask all but the sign bit
temp_msb = temp_msb & 0x80;
// twos complement
if (temp_msb >= 0x80)
temp_lsb = (~temp_lsb)+1;
// shift to get whole degree
if (temp_msb >= 0x80)
temp_lsb = (temp_lsb/2);
// add sign bit
if (temp_msb >= 0x80)
temp_lsb = ((-1)*temp_lsb);
return (int)temp_lsb | get[2] << 16;
}
示例8: FindDevices
// FIND DEVICES
uint8_t FindDevices(void) {
unsigned char m;
// Begins when a presence is detected
if(!ow_reset()) {
// Begins when at least one part is found
if(First()) {
numROMs=0;
do {
numROMs++;
for(m=0;m<8;m++) {
// Identifies ROM number on found device
FoundROM[numROMs][m]=ROM[m];
}
#if OW_DEBUG
UART_printf("\nSENSOR = %d ROM = %02X %02X %02X %02X %02X %02X %02X %02X\n",
numROMs + 1, FoundROM[numROMs][0],FoundROM[numROMs][1],
FoundROM[numROMs][2],FoundROM[numROMs][3], FoundROM[numROMs][4],
FoundROM[numROMs][5],FoundROM[numROMs][6],FoundROM[numROMs][7]);
#endif
} while (Next()&&(numROMs<=NO_ROMS)); //Continues until no additional devices are found
}
}
return numROMs;
}
示例9: ds18b20_recall_eeprom
void ds18b20_recall_eeprom()
{
ow_reset();
ow_write_byte(0xCC);
ow_write_byte(0xB8);
__delay_us(50);
}
示例10: ds18b20_read_rom
void ds18b20_read_rom(struct ds18b20 *dev)
{
//uint8_t romid[8];
//ow_init();
ow_reset();
ow_write_byte(0x33);
dev->romcode[0] = ow_read_byte();
dev->romcode[1] = ow_read_byte();
dev->romcode[2] = ow_read_byte();
dev->romcode[3] = ow_read_byte();
dev->romcode[4] = ow_read_byte();
dev->romcode[5] = ow_read_byte();
dev->romcode[6] = ow_read_byte();
dev->romcode[7] = ow_read_byte();
//printf("id 1 = %x\r\n", dev->romcode[0]);
//printf("id 2 = %x\r\n", dev->romcode[1]);
//printf("id 3 = %x\r\n", dev->romcode[2]);
//printf("id 4 = %x\r\n", dev->romcode[3]);
//printf("id 5 = %x\r\n", dev->romcode[4]);
//printf("id 6 = %x\r\n", dev->romcode[5]);
//printf("id 7 = %x\r\n", dev->romcode[6]);
//printf("id 8 = %x\r\n", dev->romcode[7]);
//*(id) = romid[1] | romid[0];
//*(id + 1) = romid[3] | romid[2];
//dev->address[0] = ((((unsigned long)romid[3] << 8) | (unsigned long)romid[2]) << 16) | (((unsigned long)romid[1] << 8) | romid[0]);
//dev->address[1] = ((((unsigned long)romid[7] << 8) | (unsigned long)romid[6]) << 16) | (((unsigned long)romid[5] << 8) | romid[4]);
//printf("Address 1 = %ld\r\n", dev->address[0]);
//printf("Address 2 = %ld\r\n", dev->address[1]);
}
示例11: search_sensors
static uint8_t search_sensors(void)
{
uint8_t i;
uint8_t id[OW_ROMCODE_SIZE];
uint8_t diff, nSensors;
ow_reset();
nSensors = 0;
diff = OW_SEARCH_FIRST;
while ( diff != OW_LAST_DEVICE && nSensors < MAXSENSORS ) {
DS18X20_find_sensor( &diff, &id[0] );
if( diff == OW_PRESENCE_ERR ) {
break;
}
if( diff == OW_DATA_ERR ) {
break;
}
for ( i=0; i < OW_ROMCODE_SIZE; i++ ) {
gSensorIDs[nSensors][i] = id[i];
}
nSensors++;
}
return nSensors;
}
示例12: search_sensors
uint8_t search_sensors(void)
{
uint8_t i;
uint8_t id[OW_ROMCODE_SIZE];
uint8_t diff, nSensors;
ow_reset();
nSensors = 0;
diff = OW_SEARCH_FIRST;
while (diff != OW_LAST_DEVICE && nSensors < MAXSENSORS) {
ds18b20_find_sensor(&diff, &id[0]);
if (diff == OW_PRESENCE_ERR) {
//printf("no sensors\n");
break;
}
if (diff == OW_DATA_ERR) {
//printf("bus error\n");
break;
}
for (i = 0; i < OW_ROMCODE_SIZE; i++)
sensor_ids[nSensors][i] = id[i];
nSensors++;
}
return nSensors;
}
示例13: Read1820
port_width Read1820(port_width error)
{
uint8_t l, m, pokus=0;
port_width errormask = (port_width)0x0001;
//???;*'vysledkom je 16 bytov v buffroch: 8x1.byte+8x2.byte...
do
{
owire(0xBE,error); //read scratch, save it to 1Wbuff, read 9 bytes, switch off power after finish)
for(l = 0;l<8;l++)
{
ow_inp(OWbuff,l,error); //zacinaj ukladat data vzdy od 1. dallasu byte "l"
}
ow_reset(error);
error = CheckCRC_8(OWbuff,error,8); //checkCRC
pokus++;
}while(error && (pokus < 5)); //cyklus, kym error !=0 alebo try=3 (tri pokusy o spravne nacitanie)
ow_rstprt(error);
if(error) //ak bola chyba v comm, tak data pri chybe = 0xFF
{
for(l=0;l<D_NUM;l++)
{
if(error & errormask)
{
for(m=0;m<8;m++)
OWbuff[l].data[m] = 0xFF;
}
errormask<<=1;
}
}
return(error);
}
示例14: search_sensors
static uint8_t search_sensors(void)
{
uint8_t i;
uint8_t id[OW_ROMCODE_SIZE];
uint8_t diff, nSensors;
uart_puts_P( NEWLINESTR "Scanning Bus for DS18X20" NEWLINESTR );
ow_reset();
nSensors = 0;
diff = OW_SEARCH_FIRST;
while ( diff != OW_LAST_DEVICE && nSensors < MAXSENSORS ) {
DS18X20_find_sensor( &diff, &id[0] );
if( diff == OW_PRESENCE_ERR ) {
uart_puts_P( "No Sensor found" NEWLINESTR );
break;
}
if( diff == OW_DATA_ERR ) {
uart_puts_P( "Bus Error" NEWLINESTR );
break;
}
for ( i=0; i < OW_ROMCODE_SIZE; i++ )
gSensorIDs[nSensors][i] = id[i];
nSensors++;
}
return nSensors;
}
示例15: ow_reset_demo
void ow_reset_demo(void)
{
unsigned char c1;
clear_screen();
printf("1-Wire-Reset: Test, ob JEMAND am Bus angeschlossen ist\n");
printf("======================================================\n");
printf("(Beenden durch Eingabe von 'e')");
printf("\n\nStart des Tests: Taste druecken ... ");
while(1)
{
set_cursor(7,2); printf(" ");
set_cursor(7,2);
c1=getchar();
if (c1 == 'e') break; // Rücksprung
// 1-Wire Reset durchführen
if (ow_reset()) printf(" Test NEGATIV: Keiner da !\n");
else printf(" Test POSITIV: Mindestens EINER da !\n");
printf("\n\nWeiter - Taste druecken ... ");
c1 = getchar();
}
}