Skip to content

Commit

Permalink
changes to add pigpio library
Browse files Browse the repository at this point in the history
  • Loading branch information
lukolszewski committed May 2, 2022
1 parent c6de0f1 commit d59b10c
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 12 deletions.
8 changes: 7 additions & 1 deletion Tools/ardupilotwaf/ardupilotwaf.py
Expand Up @@ -261,8 +261,14 @@ def ap_program(bld,
program_dir = program_groups[0]

name = os.path.join(program_dir, program_name)

tg_constructor = bld.program

#A bit of a hack, but works
if("-lpigpio" not in bld.env.LDFLAGS):
print("LDFLAGS IS:",bld.env.LDFLAGS)
bld.env.LDFLAGS += ['-lpigpio']


if bld.env.AP_PROGRAM_AS_STLIB:
tg_constructor = bld.stlib
else:
Expand Down
11 changes: 7 additions & 4 deletions Tools/ardupilotwaf/boards.py
Expand Up @@ -116,7 +116,7 @@ def configure_env(self, cfg, env):
'-Wno-redundant-decls',
'-Wno-unknown-pragmas',
'-Wno-trigraphs',
'-Werror=shadow',
#'-Werror=shadow',
'-Werror=return-type',
'-Werror=unused-result',
'-Werror=unused-variable',
Expand Down Expand Up @@ -222,11 +222,11 @@ def configure_env(self, cfg, env):
'-Werror=type-limits',
'-Werror=undef',
'-Werror=unused-result',
'-Werror=shadow',
#'-Werror=shadow',
'-Werror=unused-value',
'-Werror=unused-variable',
'-Werror=delete-non-virtual-dtor',
'-Wfatal-errors',
#'-Wfatal-errors',
'-Wno-trigraphs',
'-Werror=parentheses',
'-DARDUPILOT_BUILD',
Expand Down Expand Up @@ -632,7 +632,7 @@ def configure_env(self, cfg, env):
'-Wmissing-declarations',
'-Wno-unused-parameter',
'-Werror=array-bounds',
'-Wfatal-errors',
#'-Wfatal-errors',
'-Werror=uninitialized',
'-Werror=init-self',
'-Werror=unused-but-set-variable',
Expand Down Expand Up @@ -1045,6 +1045,9 @@ def configure_env(self, cfg, env):
env.DEFINES.update(
CONFIG_HAL_BOARD_SUBTYPE = 'HAL_BOARD_SUBTYPE_LINUX_OBAL_V1',
)

#Just for now
env.LINKFLAGS += ['-L/home/luk/dev/ardupilot/plane/modules/pigpio']

class SITL_static(sitl):
def configure_env(self, cfg, env):
Expand Down
4 changes: 3 additions & 1 deletion libraries/AP_HAL_Linux/HAL_Linux_Class.cpp
Expand Up @@ -34,6 +34,7 @@
#include "RCOutput_Bebop.h"
#include "RCOutput_Disco.h"
#include "RCOutput_PCA9685.h"
#include "RCOutput_PIGPIO.h"
#include "RCOutput_PRU.h"
#include "RCOutput_Sysfs.h"
#include "RCOutput_ZYNQ.h"
Expand Down Expand Up @@ -214,7 +215,8 @@ static RCOutput_Sysfs rcoutDriver(0, 0, 15);
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_RST_ZYNQ
static RCOutput_Sysfs rcoutDriver(0, 0, 8);
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_OBAL_V1
static RCOutput_PCA9685 rcoutDriver(i2c_mgr_instance.get_device(1, PCA9685_PRIMARY_ADDRESS), 0, 0, RPI_GPIO_<17>());
//static RCOutput_PCA9685 rcoutDriver(i2c_mgr_instance.get_device(1, PCA9685_PRIMARY_ADDRESS), 0, 0, RPI_GPIO_<17>());
static RCOutput_PIGPIO rcoutDriver(5);
#else
static Empty::RCOutput rcoutDriver;
#endif
Expand Down
12 changes: 8 additions & 4 deletions libraries/AP_HAL_Linux/RCOutput_PIGPIO.cpp
Expand Up @@ -9,11 +9,11 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <utility>
//#include <utility>

#include <pigpio.h>

#include <AP_HAL/AP_HAL.h>
//#include <AP_HAL/AP_HAL.h>
#include <GCS_MAVLink/GCS.h>

#include "GPIO.h"
Expand All @@ -22,9 +22,13 @@
using namespace Linux;


RCOutput_PIGPIO::RCOutput_PIGPIO(uint8_t channels)
RCOutput_PIGPIO::RCOutput_PIGPIO(uint8_t ch)
{
channels = sizeof(PIGPIO_CHANNELS_TO_GPIO_MAPPING);
if(ch>sizeof(PIGPIO_CHANNELS_TO_GPIO_MAPPING)) {
printf("Error. More channels requested than defined in pigpio map! Trimming.");
ch=sizeof(PIGPIO_CHANNELS_TO_GPIO_MAPPING);
}
channels = ch;
for(uint8_t i=0;i<channels;i++){
channels_enabled[i] = false;
}
Expand Down
2 changes: 1 addition & 1 deletion libraries/AP_HAL_Linux/RCOutput_PIGPIO.h
Expand Up @@ -9,7 +9,7 @@ namespace Linux {

class RCOutput_PIGPIO : public AP_HAL::RCOutput {
public:
RCOutput_PIGPIO(uint8_t channels); //sample_rate can be in 1,2,4,5,8,10uS
RCOutput_PIGPIO(uint8_t ch);

~RCOutput_PIGPIO();
void init() override;
Expand Down
2 changes: 1 addition & 1 deletion wscript
Expand Up @@ -399,7 +399,7 @@ def configure(cfg):
cfg.env.append_value('GIT_SUBMODULES', 'mavlink')

cfg.env.prepend_value('INCLUDES', [
cfg.srcnode.abspath() + '/libraries/',
cfg.srcnode.abspath() + '/libraries/',cfg.srcnode.abspath() + '/modules/pigpio/'
])

cfg.find_program('rsync', mandatory=False)
Expand Down

0 comments on commit d59b10c

Please sign in to comment.