Skip to content

Commit

Permalink
fix issue #127 and migrate functions to stricter prototype standards
Browse files Browse the repository at this point in the history
  • Loading branch information
James committed Aug 15, 2018
1 parent c303094 commit d4728b7
Show file tree
Hide file tree
Showing 61 changed files with 337 additions and 295 deletions.
4 changes: 3 additions & 1 deletion library/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ CC := gcc
LINKER := gcc

# general compiler flags
WFLAGS := -Wall -Wextra -Werror=float-equal -Wuninitialized -Wunused-variable -Wdouble-promotion
WFLAGS := -Wall -Wextra -Werror=float-equal -Wuninitialized \
-Wunused-variable -Wdouble-promotion -pedantic -Wmissing-prototypes \
-Wmissing-declarations -Werror=undef
CFLAGS := -g -fPIC -I $(INCLUDEDIR)
OPT_FLAGS := -O1
LDFLAGS := -lm -lrt -pthread -shared -Wl,-soname,$(SONAME)
Expand Down
8 changes: 4 additions & 4 deletions library/include/rc/adc.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ extern "C" {
*
* @return 0 on success, -1 on failure.
*/
int rc_adc_init();
int rc_adc_init(void);

/**
* @brief Cleans up the ADC subsystem.
Expand All @@ -52,7 +52,7 @@ int rc_adc_init();
*
* @return 0 on success, -1 on failure.
*/
int rc_adc_cleanup();
int rc_adc_cleanup(void);

/**
* @brief reads the raw integer ADC value for a particular channel
Expand All @@ -77,14 +77,14 @@ double rc_adc_read_volt(int ch);
*
* @return voltage of battery or -1 on failure
*/
double rc_adc_batt();
double rc_adc_batt(void);

/**
* @brief Reads the voltage of the 9-18v DC jack
*
* @return Voltage at DC jack or -1 on failure
*/
double rc_adc_dc_jack();
double rc_adc_dc_jack(void);



Expand Down
4 changes: 2 additions & 2 deletions library/include/rc/bmp.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ int rc_bmp_set_sea_level_pressure_pa(double pa);
*
* @return 0 on success, -1 on failure
*/
int rc_bmp_power_off();
int rc_bmp_power_off(void);


/**
Expand All @@ -116,4 +116,4 @@ int rc_bmp_read(rc_bmp_data_t* data);

#endif // RC_BMP_H

/** @} end group Barometer */
/** @} end group Barometer */
2 changes: 1 addition & 1 deletion library/include/rc/button.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ int rc_button_init(int chip, int pin, char polarity, int debounce_us);
* @brief Closes all button handlers. Call at the end of your program
* before returning.
*/
void rc_button_cleanup();
void rc_button_cleanup(void);


/**
Expand Down
4 changes: 2 additions & 2 deletions library/include/rc/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ int rc_cpu_set_governor(rc_governor_t gov);
*
* @return frequency in hz
*/
int rc_cpu_get_freq();
int rc_cpu_get_freq(void);

/**
* @brief Prints the current frequency to the screen. For example "600mhz".
*
* @return 0 on success or -1 on failure.
*/
int rc_cpu_print_freq();
int rc_cpu_print_freq(void);



Expand Down
16 changes: 8 additions & 8 deletions library/include/rc/deprecated.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ extern "C" {



int rc_initialize() __attribute__ ((deprecated));
int rc_initialize(void) __attribute__ ((deprecated));

int rc_cleanup() __attribute__ ((deprecated));
int rc_cleanup(void) __attribute__ ((deprecated));

typedef enum rc_button_state_t {
RELEASED,
Expand All @@ -33,21 +33,21 @@ int rc_set_pause_pressed_func(void (*func)(void)) __attribute__ ((deprecated));
int rc_set_pause_released_func(void (*func)(void)) __attribute__ ((deprecated));
int rc_set_mode_pressed_func(void (*func)(void)) __attribute__ ((deprecated));
int rc_set_mode_released_func(void (*func)(void)) __attribute__ ((deprecated));
rc_button_state_t rc_get_pause_button() __attribute__ ((deprecated));
rc_button_state_t rc_get_mode_button() __attribute__ ((deprecated));
rc_button_state_t rc_get_pause_button(void) __attribute__ ((deprecated));
rc_button_state_t rc_get_mode_button(void) __attribute__ ((deprecated));


int rc_get_encoder_pos(int ch) __attribute__ ((deprecated));
int rc_set_encoder_pos(int ch, int value) __attribute__ ((deprecated));

int rc_enable_motors() __attribute__ ((deprecated));
int rc_disable_motors() __attribute__ ((deprecated));
int rc_enable_motors(void) __attribute__ ((deprecated));
int rc_disable_motors(void) __attribute__ ((deprecated));
int rc_set_motor(int motor, float duty) __attribute__ ((deprecated));
int rc_set_motor_all(float duty) __attribute__ ((deprecated));
int rc_set_motor_free_spin(int motor) __attribute__ ((deprecated));
int rc_set_motor_free_spin_all() __attribute__ ((deprecated));
int rc_set_motor_free_spin_all(void) __attribute__ ((deprecated));
int rc_set_motor_brake(int motor) __attribute__ ((deprecated));
int rc_set_motor_brake_all() __attribute__ ((deprecated));
int rc_set_motor_brake_all(void) __attribute__ ((deprecated));



Expand Down
18 changes: 9 additions & 9 deletions library/include/rc/dsm.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ extern "C" {
*
* @return 0 on success, -1 on failure
*/
int rc_dsm_init();
int rc_dsm_init(void);


/**
Expand All @@ -48,7 +48,7 @@ int rc_dsm_init();
* @return 0 on success, -1 on failure. 1 if there was a timeout due to user
* callback function not returning.
*/
int rc_dsm_cleanup();
int rc_dsm_cleanup(void);


/**
Expand Down Expand Up @@ -94,7 +94,7 @@ double rc_dsm_ch_normalized(int ch);
* @return returns 1 if new data is ready to be read by the user. otherwise
* returns 0
*/
int rc_dsm_is_new_data();
int rc_dsm_is_new_data(void);


/**
Expand Down Expand Up @@ -122,7 +122,7 @@ void rc_dsm_set_disconnect_callback(void (*func)(void));
* @return returns 1 if packets are arriving in good health without
* timeouts. returns 0 otherwise.
*/
int rc_dsm_is_connection_active();
int rc_dsm_is_connection_active(void);


/**
Expand All @@ -131,7 +131,7 @@ int rc_dsm_is_connection_active();
* @return Returns the number of nanoseconds since the last dsm packet was
* received. Return -1 on error or if no packet has ever been received.
*/
int64_t rc_dsm_nanos_since_last_packet();
int64_t rc_dsm_nanos_since_last_packet(void);


/**
Expand All @@ -141,7 +141,7 @@ int64_t rc_dsm_nanos_since_last_packet();
* @return returns 10 or 11 indicating 10-bit or 11-bit resolution returns a
* 0 if no packet has been received yet or -1 on error
*/
int rc_dsm_resolution();
int rc_dsm_resolution(void);


/**
Expand All @@ -150,7 +150,7 @@ int rc_dsm_resolution();
* @return Returns number of channels being received, 0 if no packet has
* been received yet or -1 on error.
*/
int rc_dsm_channels();
int rc_dsm_channels(void);


/**
Expand Down Expand Up @@ -189,7 +189,7 @@ int rc_dsm_channels();
*
* @return 0 on success, -1 on failure
*/
int rc_dsm_bind_routine();
int rc_dsm_bind_routine(void);


/**
Expand All @@ -202,7 +202,7 @@ int rc_dsm_bind_routine();
*
* @return 0 on success, -1 on failure
*/
int rc_dsm_calibrate_routine();
int rc_dsm_calibrate_routine(void);


#ifdef __cplusplus
Expand Down
4 changes: 2 additions & 2 deletions library/include/rc/encoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ extern "C" {
*
* @return 0 on success or -1 on failure
*/
int rc_encoder_init();
int rc_encoder_init(void);

/**
* @brief Stops the encoder counters and closes file descriptors. This is
Expand All @@ -42,7 +42,7 @@ int rc_encoder_init();
*
* @return 0 on success or -1 on failure.
*/
int rc_encoder_cleanup();
int rc_encoder_cleanup(void);

/**
* @brief Reads the current position of an encoder channel.
Expand Down
4 changes: 2 additions & 2 deletions library/include/rc/encoder_eqep.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ extern "C" {
*
* @return 0 on success or -1 on failure
*/
int rc_encoder_eqep_init();
int rc_encoder_eqep_init(void);

/**
* @brief Stops the eQEP encoder counters and closes file descriptors. This
Expand All @@ -43,7 +43,7 @@ int rc_encoder_eqep_init();
*
* @return 0 on success or -1 on failure.
*/
int rc_encoder_eqep_cleanup();
int rc_encoder_eqep_cleanup(void);

/**
* @brief Reads the current position of an encoder channel.
Expand Down
6 changes: 3 additions & 3 deletions library/include/rc/encoder_pru.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ extern "C" {
*
* @return 0 on success or -1 on failure
*/
int rc_encoder_pru_init();
int rc_encoder_pru_init(void);

/**
* @brief Stops the PRU encoder counter and closes file descriptors. This
* is not strictly necessary but is recommended that the user calls this
* function at the end of their program.
*/
void rc_encoder_pru_cleanup();
void rc_encoder_pru_cleanup(void);

/**
* @brief Reads the current position of encoder channel 4.
Expand All @@ -53,7 +53,7 @@ void rc_encoder_pru_cleanup();
* @return The current position (signed 32-bit integer) or -1 and prints an
* error message is there is a problem.
*/
int rc_encoder_pru_read();
int rc_encoder_pru_read(void);

/**
* @brief Sets the current position of encoder channel 4. Usually for
Expand Down
4 changes: 2 additions & 2 deletions library/include/rc/led.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ int rc_led_set(rc_led_t led, int value);
* This does NOT turn off the LEDs, it is up to the user to leave the LEDs in
* the desired state before closing.
*/
void rc_led_cleanup();
void rc_led_cleanup(void);


/**
Expand Down Expand Up @@ -113,7 +113,7 @@ void rc_led_stop_blink(rc_led_t led);
* rc_led_stop_blink from a separate thread or signal handler. This will cause
* rc_led_blink to return 1 if blinking was stopped mid-way.
*/
void rc_led_stop_blink_all();
void rc_led_stop_blink_all(void);



Expand Down
2 changes: 1 addition & 1 deletion library/include/rc/math/filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ typedef struct rc_filter_t{
*
* @return Empty zero-filled rc_filter_t struct
*/
rc_filter_t rc_filter_empty();
rc_filter_t rc_filter_empty(void);

/**
* @brief Allocate memory for a discrete-time filter & populates it with
Expand Down
2 changes: 1 addition & 1 deletion library/include/rc/math/kalman.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ typedef struct rc_kalman_t {
*
* @return Empty zero-filled rc_kalman_t struct
*/
rc_kalman_t rc_kalman_empty();
rc_kalman_t rc_kalman_empty(void);

/**
* @brief Allocates memory for a Kalman filter of given dimensions
Expand Down
2 changes: 1 addition & 1 deletion library/include/rc/math/matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ typedef struct rc_matrix_t{
*
* @return Returns an empty rc_matrix_t
*/
rc_matrix_t rc_matrix_empty();
rc_matrix_t rc_matrix_empty(void);

/**
* @brief Allocates memory for matrix A to have size rows&cols.
Expand Down
4 changes: 2 additions & 2 deletions library/include/rc/math/other.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ extern "C" {
*
* @return random floating point number between -1 and 1
*/
float rc_get_random_float();
float rc_get_random_float(void);

/**
* @brief Returns a random double-precision floating point number between
Expand All @@ -38,7 +38,7 @@ float rc_get_random_float();
*
* @return random double-precision floating point number between -1 and 1
*/
double rc_get_random_double();
double rc_get_random_double(void);

/**
* @brief Modifies val to be bounded between between min and max.
Expand Down
2 changes: 1 addition & 1 deletion library/include/rc/math/ring_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ typedef struct rc_ringbuf_t {
*
* @return empty and ready-to-allocate rc_ringbuf_t
*/
rc_ringbuf_t rc_ringbuf_empty();
rc_ringbuf_t rc_ringbuf_empty(void);

/**
* @brief Allocates memory for a ring buffer and initializes an
Expand Down
2 changes: 1 addition & 1 deletion library/include/rc/math/vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ typedef struct rc_vector_t{
* @return rc_vector_t with no allocated memory and the initialized flag set
* to 0.
*/
rc_vector_t rc_vector_empty();
rc_vector_t rc_vector_empty(void);

/**
* @brief Allocates memory for vector v to have specified length.
Expand Down
10 changes: 5 additions & 5 deletions library/include/rc/mavlink_udp.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ int rc_mav_set_system_id(uint8_t system_id);
*
* @return 0 on success, -1 on failure
*/
int rc_mav_cleanup();
int rc_mav_cleanup(void);


/**
Expand Down Expand Up @@ -201,7 +201,7 @@ int rc_mav_set_callback_connection_lost(void (*func)(void));
*
* @return Returns current connection state.
*/
rc_mav_connection_state_t rc_mav_get_connection_state();
rc_mav_connection_state_t rc_mav_get_connection_state(void);


/**
Expand All @@ -222,7 +222,7 @@ uint8_t rc_mav_get_sys_id_of_last_msg(int msg_id);
* @return Returns the system ID on success. Returns -1 on failure, for
* example if no message has been received.
*/
uint8_t rc_mav_get_sys_id_of_last_msg_any();
uint8_t rc_mav_get_sys_id_of_last_msg_any(void);

/**
* @brief Fetches the number of nanoseconds since the last message of type
Expand All @@ -243,15 +243,15 @@ int64_t rc_mav_ns_since_last_msg(int msg_id);
* @return Returns the number of nanoseconds since any message has been
* received. Returns -1 on failure, for example if no message has been received.
*/
int64_t rc_mav_ns_since_last_msg_any();
int64_t rc_mav_ns_since_last_msg_any(void);

/**
* @brief Returns the msg_id of the last received packet.
*
* @return Returns the msg_id of the last received packet. Returns -1 on
* failure, for example if no message has been received.
*/
int rc_mav_msg_id_of_last_msg();
int rc_mav_msg_id_of_last_msg(void);

/**
* @brief Prints to stdout a human-readable name for a message type.
Expand Down
Loading

0 comments on commit d4728b7

Please sign in to comment.