Skip to content

Commit

Permalink
pga460: Change variable initialization to uniform initialization styl…
Browse files Browse the repository at this point in the history
…e, format whitespace, and change baud rate unsigned to speed_t type. (#11861)
  • Loading branch information
mcsauder authored and dagar committed Jun 29, 2019
1 parent db96b6c commit 423219c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 21 deletions.
7 changes: 2 additions & 5 deletions src/drivers/distance_sensor/pga460/pga460.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@
#include "pga460.h"


extern "C" __EXPORT int pga460_main(int argc, char *argv[]);

PGA460::PGA460(const char *port)
{
// Store port name.
Expand Down Expand Up @@ -313,7 +311,6 @@ int PGA460::open_serial()
// no NL to CR translation, don't mark parity errors or breaks
// no input parity check, don't strip high bit off,
// no XON/XOFF software flow control
//
uart_config.c_iflag &= ~(IGNBRK | BRKINT | ICRNL | INLCR | IGNCR | PARMRK | INPCK | ISTRIP | IXON | IXOFF);

uart_config.c_iflag |= IGNPAR;
Expand All @@ -339,7 +336,7 @@ int PGA460::open_serial()

uart_config.c_cc[VTIME] = 0;

unsigned speed = 115200;
speed_t speed = 115200;

// Set the baud rate.
if ((termios_state = cfsetispeed(&uart_config, speed)) < 0) {
Expand Down Expand Up @@ -899,7 +896,7 @@ int PGA460::write_register(const uint8_t reg, const uint8_t val)
}
}

int pga460_main(int argc, char *argv[])
extern "C" __EXPORT int pga460_main(int argc, char *argv[])
{
return PGA460::main(argc, argv);
}
32 changes: 16 additions & 16 deletions src/drivers/distance_sensor/pga460/pga460.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,13 @@
#define USER_DATA18 0x0 //reg addr 0x11
#define USER_DATA19 0x0 //reg addr 0x12
#define USER_DATA20 0x0 //reg addr 0x13
#define TVGAIN0 0x9D //reg addr 0x14
#define TVGAIN1 0xBD //reg addr 0x15
#define TVGAIN2 0xEF //reg addr 0x16
#define TVGAIN3 0x31 //reg addr 0x17
#define TVGAIN4 0x48 //reg addr 0x18
#define TVGAIN5 0x67 //reg addr 0x19
#define TVGAIN6 0xAC //reg addr 0x1A
#define TVGAIN0 0x9D //reg addr 0x14
#define TVGAIN1 0xBD //reg addr 0x15
#define TVGAIN2 0xEF //reg addr 0x16
#define TVGAIN3 0x31 //reg addr 0x17
#define TVGAIN4 0x48 //reg addr 0x18
#define TVGAIN5 0x67 //reg addr 0x19
#define TVGAIN6 0xAC //reg addr 0x1A
#define INIT_GAIN 0x40 //reg addr 0x1B
#define FREQUENCY (uint8_t)(5*(_resonant_frequency - 30.0f)) //reg addr 0x1C
#define DEADTIME 0xF0 //reg addr 0x1D
Expand All @@ -152,7 +152,7 @@
#define TEMP_TRIM 0x0 //reg addr 0x28
#define P1_GAIN_CTRL 0x0 //reg addr 0x29
#define P2_GAIN_CTRL 0x8 //reg addr 0x2A
#define EE_CRC 0x29 //reg addr 0x2B
#define EE_CRC 0x29 //reg addr 0x2B

// Register-based -- volatile
#define EE_CNTRL 0x0 //reg addr 0x40
Expand Down Expand Up @@ -385,28 +385,28 @@ class PGA460 : public ModuleBase<PGA460>
void uORB_publish_results(const float dist);

/** @orb_advert_t orb_advert_t uORB advertisement topic. */
orb_advert_t _distance_sensor_topic = nullptr;
orb_advert_t _distance_sensor_topic{nullptr};

/** @param _fd Returns the file descriptor from px4_open(). */
int _fd = -1;
int _fd{-1};

/** @param _port Stores the port name. */
char _port[20];
char _port[20] {};

/** @param _previous_report_distance The previous reported sensor distance. */
float _previous_report_distance = 0;
float _previous_report_distance{0};

/** @param _previous_valid_report_distance The previous valid reported sensor distance. */
float _previous_valid_report_distance = 0;
float _previous_valid_report_distance{0};

/** @param _resonant_frequency The sensor resonant (transmit) frequency. */
float _resonant_frequency = 41.0f;
float _resonant_frequency{41.0f};

/** @param _mode_long_range Flag for long range mode. If false, sensor is in short range mode. */
uint8_t _ranging_mode = MODE_SHORT_RANGE;
uint8_t _ranging_mode{MODE_SHORT_RANGE};

/** @param _start_loop The starting value for the loop time of the main loop. */
uint64_t _start_loop = 0;
uint64_t _start_loop{0};
};

#endif

0 comments on commit 423219c

Please sign in to comment.