Skip to content

Commit

Permalink
build of C examples fixed
Browse files Browse the repository at this point in the history
Signed-off-by: DTJF <[email protected]>
  • Loading branch information
DTJF authored and DTJF committed Aug 20, 2023
1 parent da553d0 commit c74bbd6
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 27 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8.3)

SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")

PROJECT(libpruw1 Fbc)
PROJECT(libpruw1 Fbc C)

# constants
SET(PROJ_NAME "${CMAKE_PROJECT_NAME}" CACHE STRING "project name" FORCE)
Expand Down
2 changes: 1 addition & 1 deletion src/c_include/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
INSTALL(FILES "pruw1.h" "pruw1.hp"
INSTALL(FILES "pruw1.h" "../bas/pruw1.hp"
DESTINATION include/libpruw1
COMPONENT dev
)
36 changes: 19 additions & 17 deletions src/c_include/pruw1.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ Copyright 2015-\Year by \Email
extern "C" {
#endif /* __cplusplus */

#include "pruw1.hp"
#include "libpruio/pruio.h"

typedef unsigned char UInt8; //!< 8 bit unsigned integer data type.
typedef short Int16; //!< 16 bit signed integer data type.
typedef int Int32; //!< 32 bit signed integer data type.
Expand Down Expand Up @@ -97,7 +94,7 @@ typedef struct pruw1{

//! A pre-computed table for fast CRC checksum computation.
UInt8 crc8_table[255 + 1];
//UInt64 *Slots; //!< The FB array to store the device IDs.
UInt8 Slots[32]; //!< Meta-data for FB array to store the device IDs.
}pruw1;

/** \brief Wrapper function for the constructor PruW1::PruW1().
Expand All @@ -110,26 +107,31 @@ The constructor is designed to
- allocate and initialize memory for the class variables,
- evaluate the free PRU (not used by libpruio)
- check the header pin configuration (and, if not matching, try to adapt it - root privileges),
- check the header pin configuration (and, if not matching, try to adapt it - pinmuxing),
- load the firmware and start it
In case of success the variable PruW1::Errr is 0 (zero) and you can
start to communicate on the bus. Otherwise the variable contains an
error message. The string is owned by \Proj and should not be freed. In
that case call the destructor (and do not start any communication).
In case of success the variable PruW1::Errr is 0 (zero), ready for
starting the communication on the bus. Otherwise the variable contains
an error message. The string is owned by \Proj and should not be freed.
In that case call the destructor (and do not start any communication).
The operating modus M is introduced in version 0.4 in order to
influence power consumption (ie. for batterie powered systems):
- Bit-0 controlls the idle state of the line. By default the line is in
input state and the external pull-up resistor pulls the line high
during idle. Set the bit to configure the line for parasite power (=
output/high during idle) by the costs of more energy consumption (max.
current = 6 mA).
- Bit-0 controlls the idle state of the line during sensor operation.
By default the line is in input state (only the pull-up resistor
pulls the line high). Set this bit in order to bring the line in high
output state during sensor operation for parasite powering.
\note For parasite powering the sensor VDD line must get grounded. The
sensors current is up to 1.5 mA, so you must not run more than 4
sensors in parasite powering on a BBB-GPIO.
- Bit-1 controlls the resistor configuration. By default an external
resistor is used at the line (usually 4k7 Ohm). Set the bit to
configure the internal pull up resistor (10k).
- Bit-1 controlls the resistor configuration. By default By default the
internal pull-up resistor pulls the line high, so that a sensor can
operate without any further wiring. For long cables use an external
resistor (usually 4k7 Ohm). Clear the bit in oder to save some energy
consumption.
\since 0.0
*/
Expand Down
1 change: 0 additions & 1 deletion src/c_include/pruw1.hp

This file was deleted.

6 changes: 4 additions & 2 deletions src/examples/dallas.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ Check the output for enabled monitoring feature as well, see section

#include <stdio.h>
#include <unistd.h>
#include "libpruio/pruio.h"
#include "libpruio/pruio_pins.h" // libruio pin numbering
#include "../c_include/pruw1.h" // library header (local)
//#include "libpruw1/pruw1.h" // library header when installed
#include "libpruio/pruio_pins.h" // libruio pin numbering

//! The main function.
int main(int argc, char **argv)
Expand All @@ -43,13 +44,14 @@ int main(int argc, char **argv)

// Create new libpruw1 instance.
pruw1 *w1 = pruw1_new(io, P9_15, PRUW1_PARPOW + PRUW1_PULLUP); // 2 wire (VDD=GND))
//pruw1 *w1 = pruw1_new(io, P9_15, 0); // external VDD and pullup
//pruw1 *w1 = pruw1_new(io, P9_15, PRUW1_PULLUP); // external VDD and pullup
if (w1->Errr) {
printf("libpruw1 CTOR failed (%s)\n", w1->Errr); break;}
// Scan the bus for parasite powered devices
printf("%s parasite powered device.",
(pruw1_checkPara(w1) ? "At least one" : "No"));
// Scan the bus for device IDs
printf("\ntrying to scan devices ...");
if (pruw1_scanBus(w1)) {
printf("scanBus failed (%s)\n", w1->Errr); break;}
for (i = 0; i <= pruw1_getSlotMax(w1); i++)
Expand Down
10 changes: 5 additions & 5 deletions src/examples/onlyDS18S20.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ Check the output for enabled monitoring feature as well, see section

#include <stdio.h>
#include <unistd.h>
#include "../c_include/pruw1.h" // library header
//#include "libpruw1/pruw1.h" // library header when installed
#include "libpruio/pruio.h"
#include "libpruio/pruio_pins.h" // libruio pin numbering
//#include <libpruio/pruio_pins.h> // libruio pin numbering
#include "../c_include/pruw1.h" // library header (local)
//#include "libpruw1/pruw1.h" // library header when installed

//! The main function.
int main(int argc, char **argv)
Expand All @@ -41,13 +41,13 @@ int main(int argc, char **argv)
//printf("libpruio config failed (%s)\n", io->Errr); break;}

// Create new libpruw1 instance.
pruw1 *w1 = pruw1_new(io, P9_15, 0);
pruw1 *w1 = pruw1_new(io, P9_15, PRUW1_PULLUP);
if (w1->Errr) {
printf("libpruw1 CTOR failed (%s)\n", w1->Errr); break;}
// Scan the bus for device IDs
printf("\ntrying to scan devices ...");
if (pruw1_scanBus(w1)) {
printf("scanBus failed (%s)\n", w1->Errr); break;}
printf("\nsizeof(UInt64)=%d",sizeof(UInt64));
for (i = 0; i <= pruw1_getSlotMax(w1); i++)
{
printf("\nfound device %d, ID: %llX", i, pruw1_getId(w1, i));
Expand Down

0 comments on commit c74bbd6

Please sign in to comment.