Skip to content

Commit

Permalink
stlink-org#1216 refactoring of common.c
Browse files Browse the repository at this point in the history
File divided to some parts. Functions with "flash" in names extracted to common_flash.c, with "option" extracted to option.c etc.
Removed unnecessary headers.
Removed one single function which was used nowhere.
And so on.
Project built under Windows and seems to be working.
  • Loading branch information
hydroconstructor committed Jan 20, 2022
1 parent 3be2c70 commit e5ff479
Show file tree
Hide file tree
Showing 13 changed files with 3,592 additions and 3 deletions.
10 changes: 9 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# General cmake settings
###

cmake_minimum_required(VERSION 3.10.2)
cmake_minimum_required(VERSION 3.7.2)
cmake_policy(SET CMP0042 NEW)
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
Expand Down Expand Up @@ -110,6 +110,8 @@ add_subdirectory(inc)
set(STLINK_HEADERS
inc/backend.h
inc/stlink.h
src/common_flash.h
src/calculate.h
src/stlink-lib/commands.h
src/stlink-lib/libusb_settings.h
src/stlink-lib/reg.h
Expand All @@ -123,7 +125,13 @@ set(STLINK_HEADERS
)

set(STLINK_SOURCE
src/read_write.c
src/common.c
src/option.c
src/common_flash.c
src/map_file.c
src/flashloader.c
src/calculate.c
src/stlink-lib/chipid.c
src/stlink-lib/flash_loader.c
src/stlink-lib/logging.c
Expand Down
6 changes: 4 additions & 2 deletions inc/stlink.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

/*
* File: stlink.h
*
Expand All @@ -13,6 +14,7 @@
#include <stdbool.h>

#include "stm32.h"
#include "stm32flash.h"

#ifdef __cplusplus
extern "C" {
Expand Down Expand Up @@ -284,15 +286,15 @@ int stlink_mwrite_sram(stlink_t *sl, uint8_t* data, uint32_t length, stm32_addr_
int stlink_fwrite_sram(stlink_t *sl, const char* path, stm32_addr_t addr);
int stlink_verify_write_flash(stlink_t *sl, stm32_addr_t address, uint8_t *data, uint32_t length);

int stlink_chip_id(stlink_t *sl, uint32_t *chip_id);
//int stlink_chip_id(stlink_t *sl, uint32_t *chip_id);
int stlink_cpu_id(stlink_t *sl, cortex_m3_cpuid_t *cpuid);

int stlink_erase_flash_page(stlink_t* sl, stm32_addr_t flashaddr);
uint32_t stlink_calculate_pagesize(stlink_t *sl, uint32_t flashaddr);
int stlink_check_address_range_validity(stlink_t *sl, stm32_addr_t addr, size_t size);
int stlink_check_address_alignment(stlink_t *sl, stm32_addr_t addr);
uint16_t read_uint16(const unsigned char *c, const int pt);
void stlink_core_stat(stlink_t *sl);
//void stlink_core_stat(stlink_t *sl);
void stlink_print_data(stlink_t *sl);
unsigned int is_bigendian(void);
uint32_t read_uint32(const unsigned char *c, const int pt);
Expand Down
Loading

0 comments on commit e5ff479

Please sign in to comment.