Associate
December 29, 2012
Question
1-Wire library for STM32 in C
- December 29, 2012
- 10 replies
- 18334 views
Posted on December 29, 2012 at 08:38
May be someone finds the Delay library useful too.
Working on DallasTemp library now - will post here when finished..
Any comments, suggestions are welcome...
#1wire #delay #1-wire
Could not find a ready solution for using 1-wire protocol with STM32 in C (working wiwth IAR), so I decided to rework the C++ library that came with arduino.
So, if anyone needs it - here it is a fully working solution (compiled wit IAR, tested on STM32F103VET6 processor running at 72 Mhz - Delay functions need to be modified for other frequencies). I have not yet add comments to functions in code, but it should not be hard to understand, as it is 1:1 ported from arduino library. Sample code:OWire OneWire;
unsigned char DeviceAddress[8];
int nCount = 0;
OWInit(&OneWire, GPIOB, GPIO_Pin_14);
while(OWSearch(&OneWire, DeviceAddress))
{
printf(''Device %d: %02X %02X %02X %02X %02X %02X %02X %02X \n\r'',
nCount+1,
DeviceAddress[7],DeviceAddress[6],
DeviceAddress[5],DeviceAddress[4],
DeviceAddress[3],DeviceAddress[2],
DeviceAddress[1],DeviceAddress[0]);
nCount++;
}
printf(''DeviceCount: %d'',nCount);
Output:
May be someone finds the Delay library useful too.
Working on DallasTemp library now - will post here when finished..
Any comments, suggestions are welcome...
#1wire #delay #1-wire