Skip to content

Commit

Permalink
Improvents for library documentation
Browse files Browse the repository at this point in the history
- Renamed header file reg.h to register.h
- Added unified header comments for files
- [doc] flash_loader.h: // Static functions
  • Loading branch information
Nightwalker-87 committed Jun 7, 2023
1 parent 92ad99f commit c8eaebc
Show file tree
Hide file tree
Showing 22 changed files with 110 additions and 21 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ set(STLINK_HEADERS
src/stlink-lib/map_file.h
src/stlink-lib/md5.h
src/stlink-lib/option_bytes.h
src/stlink-lib/reg.h
src/stlink-lib/register.h
src/stlink-lib/sg.h
src/stlink-lib/usb.h
)
Expand Down
6 changes: 2 additions & 4 deletions inc/stlink.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@

/*
* File: stlink.h
*
* This should contain all the common top level stlink interfaces,
* regardless of how the backend does the work....
* All common top level stlink interfaces, regardless of how the backend does the work....
*/

#ifndef STLINK_H
Expand Down Expand Up @@ -300,7 +298,7 @@ int32_t stlink_target_connect(stlink_t *sl, enum connect_type connect);

#include <sg.h>
#include <usb.h>
#include <reg.h>
#include <register.h>
#include <commands.h>
#include <chipid.h>
#include <flash_loader.h>
Expand Down
2 changes: 1 addition & 1 deletion src/st-trace/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <unistd.h>

#include <logging.h>
#include <reg.h>
#include <register.h>
#include <stlink.h>

#define DEFAULT_LOGGING_LEVEL 50
Expand Down
6 changes: 6 additions & 0 deletions src/stlink-lib/calculate.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
* File: calculate.c
*
* Calculation of sector numbers and pages
*/

#include <stdint.h>

#include <stlink.h>
Expand Down
6 changes: 6 additions & 0 deletions src/stlink-lib/chipid.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
* File: chipid.c
*
* Chip-ID parametres
*/

#include <ctype.h>
#include <errno.h>
#include <stdio.h>
Expand Down
6 changes: 6 additions & 0 deletions src/stlink-lib/chipid.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
* File: chipid.h
*
* Chip-ID parametres
*/

#ifndef CHIPID_H
#define CHIPID_H

Expand Down
6 changes: 6 additions & 0 deletions src/stlink-lib/commands.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
* File: commands.h
*
* stlink commands
*/

#ifndef COMMANDS_H
#define COMMANDS_H

Expand Down
6 changes: 6 additions & 0 deletions src/stlink-lib/common_flash.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
* File: common_flash.c
*
* Flash operations
*/

#include <stdint.h>
#include <stdio.h>
#include <unistd.h>
Expand Down
6 changes: 6 additions & 0 deletions src/stlink-lib/flash_loader.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
* File: flash_loader.c
*
* Flash loaders
*/

#include <stdint.h>
#include <stdio.h>
#include <string.h>
Expand Down
14 changes: 7 additions & 7 deletions src/stlink-lib/flash_loader.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* File: flash_loader.h
*
* Flash loader
* Flash loaders
*/

#ifndef FLASH_LOADER_H
Expand All @@ -14,19 +14,19 @@
#include <stlink.h>

int32_t stlink_flash_loader_init(stlink_t *sl, flash_loader_t* fl);
static int32_t loader_v_dependent_assignment(stlink_t *sl,
const uint8_t **loader_code, size_t *loader_size,
const uint8_t *high_v_loader, size_t high_v_loader_size,
const uint8_t *low_v_loader, size_t low_v_loader_size);
// static int32_t loader_v_dependent_assignment(stlink_t *sl,
// const uint8_t **loader_code, size_t *loader_size,
// const uint8_t *high_v_loader, size_t high_v_loader_size,
// const uint8_t *low_v_loader, size_t low_v_loader_size);
int32_t stlink_flash_loader_write_to_sram(stlink_t *sl, stm32_addr_t* addr, size_t* size);
int32_t stlink_flash_loader_run(stlink_t *sl, flash_loader_t* fl, stm32_addr_t target, const uint8_t* buf, size_t size);


/* === Functions from old header file flashloader.h === */

int32_t stm32l1_write_half_pages(stlink_t *sl, stm32_addr_t addr, uint8_t *base, uint32_t len, uint32_t pagesize);
static void set_flash_cr_pg(stlink_t *sl, uint32_t bank);
static void set_dma_state(stlink_t *sl, flash_loader_t *fl, int32_t bckpRstr);
// static void set_flash_cr_pg(stlink_t *sl, uint32_t bank);
// static void set_dma_state(stlink_t *sl, flash_loader_t *fl, int32_t bckpRstr);
int32_t stlink_flashloader_start(stlink_t *sl, flash_loader_t *fl);
int32_t stlink_flashloader_write(stlink_t *sl, flash_loader_t *fl, stm32_addr_t addr, uint8_t *base, uint32_t len);
int32_t stlink_flashloader_stop(stlink_t *sl, flash_loader_t *fl);
Expand Down
6 changes: 6 additions & 0 deletions src/stlink-lib/helper.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
* File: helper.c
*
* General helper functions
*/

#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
Expand Down
6 changes: 6 additions & 0 deletions src/stlink-lib/helper.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
* File: helper.h
*
* General helper functions
*/

#ifndef HELPER_H
#define HELPER_H

Expand Down
6 changes: 6 additions & 0 deletions src/stlink-lib/libusb_settings.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
* File: libusb_settings.h
*
* Settings for libusb library
*/

#ifndef LIBUSB_SETTINGS_H
#define LIBUSB_SETTINGS_H

Expand Down
3 changes: 1 addition & 2 deletions src/stlink-lib/logging.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/*
* UglyLogging
*
* Slow, yet another wheel reinvented, but enough to make the rest of our code
* pretty enough.
* Slow, yet another wheel reinvented, but enough to make the rest of our code pretty enough.
*/

#include <stdarg.h>
Expand Down
6 changes: 6 additions & 0 deletions src/stlink-lib/map_file.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
* File: map_file.c
*
* File mapping
*/

#include <fcntl.h>
#include <stdint.h>
#include <unistd.h>
Expand Down
6 changes: 6 additions & 0 deletions src/stlink-lib/md5.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
* This is free and unencumbered software released into the public domain - June 2013 - waterjuice.org
*/

/*
* File: md5.c
*
* MD5 hash function
*/

#include <stdint.h>
#include <memory.h>

Expand Down
6 changes: 6 additions & 0 deletions src/stlink-lib/option_bytes.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
* File: option_bytes.c
*
* Read and write option bytes and option control registers
*/

#include <stdint.h>
#include <stdio.h>
#include <string.h>
Expand Down
10 changes: 8 additions & 2 deletions src/stlink-lib/reg.h → src/stlink-lib/register.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#ifndef REG_H
#define REG_H
/*
* File: register.h
*
* Common STM32 registers
*/

#ifndef REGISTER_H
#define REGISTER_H

#define STLINK_REG_CM3_CPUID 0xE000ED00

Expand Down
6 changes: 6 additions & 0 deletions src/stlink-lib/sg.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@
* part to an existing options line for usb-storage).
*/

/*
* File: sg.c
*
*
*/

#define __USE_GNU

#include <assert.h>
Expand Down
5 changes: 3 additions & 2 deletions src/stlink-lib/sg.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* File: sg.h
* Author: karl
* File: sg.h
*
*
*/

#ifndef SG_H
Expand Down
6 changes: 6 additions & 0 deletions src/stlink-lib/usb.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
* File: usb.c
*
*
*/

#include <limits.h>
#include <stdint.h>
#include <stdio.h>
Expand Down
5 changes: 3 additions & 2 deletions src/stlink-lib/usb.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* File: usb.h
* Author: karl
* File: usb.h
*
*
*/

#ifndef USB_H
Expand Down

0 comments on commit c8eaebc

Please sign in to comment.