Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace data types with fixed width typedefs (C99)
- Unified variable types (Closes #909) short --> int16_t unsigned short --> uint16_t int --> int32_t unsigned int --> uint32_t long --> int32_t unsigned long --> uint32_t long long --> int64_t unsigned long long --> uint64_t - Added missing header includes
- Loading branch information
1 parent
a9c2139
commit 5e85fd0
Showing
52 changed files
with
908 additions
and
836 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,39 @@ | ||
#ifndef BACKEND_H | ||
#define BACKEND_H | ||
|
||
#include <stdint.h> | ||
|
||
typedef struct _stlink_backend { | ||
void (*close) (stlink_t * sl); | ||
int (*exit_debug_mode) (stlink_t * sl); | ||
int (*enter_swd_mode) (stlink_t * sl); | ||
int (*enter_jtag_mode) (stlink_t * stl); | ||
int (*exit_dfu_mode) (stlink_t * stl); | ||
int (*core_id) (stlink_t * stl); | ||
int (*reset) (stlink_t * stl); | ||
int (*jtag_reset) (stlink_t * stl, int value); | ||
int (*run) (stlink_t * stl, enum run_type type); | ||
int (*status) (stlink_t * stl); | ||
int (*version) (stlink_t *sl); | ||
int (*read_debug32) (stlink_t *sl, uint32_t addr, uint32_t *data); | ||
int (*read_mem32) (stlink_t *sl, uint32_t addr, uint16_t len); | ||
int (*write_debug32) (stlink_t *sl, uint32_t addr, uint32_t data); | ||
int (*write_mem32) (stlink_t *sl, uint32_t addr, uint16_t len); | ||
int (*write_mem8) (stlink_t *sl, uint32_t addr, uint16_t len); | ||
int (*read_all_regs) (stlink_t *sl, struct stlink_reg * regp); | ||
int (*read_reg) (stlink_t *sl, int r_idx, struct stlink_reg * regp); | ||
int (*read_all_unsupported_regs) (stlink_t *sl, struct stlink_reg *regp); | ||
int (*read_unsupported_reg) (stlink_t *sl, int r_idx, struct stlink_reg *regp); | ||
int (*write_unsupported_reg) (stlink_t *sl, uint32_t value, int idx, struct stlink_reg *regp); | ||
int (*write_reg) (stlink_t *sl, uint32_t reg, int idx); | ||
int (*step) (stlink_t * stl); | ||
int (*current_mode) (stlink_t * stl); | ||
int (*force_debug) (stlink_t *sl); | ||
int32_t (*exit_debug_mode) (stlink_t * sl); | ||
int32_t (*enter_swd_mode) (stlink_t * sl); | ||
int32_t (*enter_jtag_mode) (stlink_t * stl); | ||
int32_t (*exit_dfu_mode) (stlink_t * stl); | ||
int32_t (*core_id) (stlink_t * stl); | ||
int32_t (*reset) (stlink_t * stl); | ||
int32_t (*jtag_reset) (stlink_t * stl, int32_t value); | ||
int32_t (*run) (stlink_t * stl, enum run_type type); | ||
int32_t (*status) (stlink_t * stl); | ||
int32_t (*version) (stlink_t *sl); | ||
int32_t (*read_debug32) (stlink_t *sl, uint32_t addr, uint32_t *data); | ||
int32_t (*read_mem32) (stlink_t *sl, uint32_t addr, uint16_t len); | ||
int32_t (*write_debug32) (stlink_t *sl, uint32_t addr, uint32_t data); | ||
int32_t (*write_mem32) (stlink_t *sl, uint32_t addr, uint16_t len); | ||
int32_t (*write_mem8) (stlink_t *sl, uint32_t addr, uint16_t len); | ||
int32_t (*read_all_regs) (stlink_t *sl, struct stlink_reg * regp); | ||
int32_t (*read_reg) (stlink_t *sl, int32_t r_idx, struct stlink_reg * regp); | ||
int32_t (*read_all_unsupported_regs) (stlink_t *sl, struct stlink_reg *regp); | ||
int32_t (*read_unsupported_reg) (stlink_t *sl, int32_t r_idx, struct stlink_reg *regp); | ||
int32_t (*write_unsupported_reg) (stlink_t *sl, uint32_t value, int32_t idx, struct stlink_reg *regp); | ||
int32_t (*write_reg) (stlink_t *sl, uint32_t reg, int32_t idx); | ||
int32_t (*step) (stlink_t * stl); | ||
int32_t (*current_mode) (stlink_t * stl); | ||
int32_t (*force_debug) (stlink_t *sl); | ||
int32_t (*target_voltage) (stlink_t *sl); | ||
int (*set_swdclk) (stlink_t * stl, int freq_khz); | ||
int (*trace_enable) (stlink_t * sl, uint32_t frequency); | ||
int (*trace_disable) (stlink_t * sl); | ||
int (*trace_read) (stlink_t * sl, uint8_t* buf, size_t size); | ||
int32_t (*set_swdclk) (stlink_t * stl, int32_t freq_khz); | ||
int32_t (*trace_enable) (stlink_t * sl, uint32_t frequency); | ||
int32_t (*trace_disable) (stlink_t * sl); | ||
int32_t (*trace_read) (stlink_t * sl, uint8_t* buf, size_t size); | ||
} stlink_backend_t; | ||
|
||
#endif // BACKEND_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
5e85fd0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Nightwalker-87
it is deeply wrong to change int to int32_t and so on without context.
All system calls like open, recv, send, and others return int. And we should respect it. Ohterway it led us to a problem on 64-bit systems or other settings where int is bigger than int32_t.
So please, revert this commit.
5e85fd0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The width of int on the most common architectures ILP32LL, LLP64, and LP64 is 32-bit each, so there should technically be no difference here (see also: https://pvs-studio.com/fr/blog/posts/cpp/a0042/).
Please also see: https://barrgroup.com/embedded-systems/how-to/c-fixed-width-integers-c99 as one reference among others.
With a view to further refactoring work and perspectives there are indeed good arguments for this approach.