Skip to content

Commit dcb764c

Browse files
committed
Merged macro.h into util.h.
- Changed ELEMENTS_IN_ARRAY() to use ARRAY_SIZE(). - Using single definition of MAX().
1 parent 05f3419 commit dcb764c

File tree

26 files changed

+73
-92
lines changed

26 files changed

+73
-92
lines changed

source/daplink/circ_buf.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include "circ_buf.h"
2323

2424
#include "cortex_m.h"
25-
#include "macro.h"
2625
#include "util.h"
2726

2827
void circ_buf_init(circ_buf_t *circ_buf, uint8_t *buffer, uint32_t size)

source/daplink/daplink_debug.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#include <stdint.h>
2929
#include "cmsis_os2.h"
3030
#include "rl_usb.h"
31-
#include "macro.h"
31+
#include "util.h"
3232

3333
#ifdef __cplusplus
3434
extern "C" {

source/daplink/drag-n-drop/file_stream.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424
#include "file_stream.h"
2525
#include "util.h"
26-
#include "macro.h"
2726
#include "intelhex.h"
2827
#include "flash_decoder.h"
2928
#include "error.h"
@@ -80,7 +79,7 @@ stream_t stream[] = {
8079
{detect_bin, open_bin, write_bin, close_bin}, // STREAM_TYPE_BIN
8180
{detect_hex, open_hex, write_hex, close_hex}, // STREAM_TYPE_HEX
8281
};
83-
COMPILER_ASSERT(ELEMENTS_IN_ARRAY(stream) == STREAM_TYPE_COUNT);
82+
COMPILER_ASSERT(ARRAY_SIZE(stream) == STREAM_TYPE_COUNT);
8483
// STREAM_TYPE_NONE must not be included in count
8584
COMPILER_ASSERT(STREAM_TYPE_NONE > STREAM_TYPE_COUNT);
8685

source/daplink/drag-n-drop/flash_decoder.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424
#include "flash_decoder.h"
2525
#include "util.h"
26-
#include "macro.h"
2726
#include "daplink.h"
2827
#include "flash_manager.h"
2928
#include "target_config.h" // for target_device

source/daplink/drag-n-drop/flash_manager.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
#include "flash_manager.h"
2323
#include "util.h"
24-
#include "macro.h"
2524
#include "error.h"
2625

2726
// Set to 1 to enable debugging

source/daplink/drag-n-drop/iap_flash_intf.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
#include "compiler.h"
3030
#include "crc.h"
3131
#include "info.h"
32-
#include "macro.h"
3332

3433
// Application start must be aligned to page write
3534
COMPILER_ASSERT(DAPLINK_ROM_APP_START % DAPLINK_MIN_WRITE_SIZE == 0);

source/daplink/drag-n-drop/vfs_user.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#include <string.h>
2525

2626
#include "vfs_manager.h"
27-
#include "macro.h"
2827
#include "error.h"
2928
#include "util.h"
3029
#include "settings.h"

source/daplink/drag-n-drop/virtual_fs.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include "info.h"
2626
#include "settings.h"
2727
#include "compiler.h"
28-
#include "macro.h"
2928
#include "util.h"
3029

3130
// Virtual file system driver
@@ -257,7 +256,7 @@ const virtual_media_t virtual_media_tmpl[] = {
257256
/* Raw filesystem contents follow */
258257
};
259258
// Keep virtual_media_idx_t in sync with virtual_media_tmpl
260-
COMPILER_ASSERT(MEDIA_IDX_COUNT == ELEMENTS_IN_ARRAY(virtual_media_tmpl));
259+
COMPILER_ASSERT(MEDIA_IDX_COUNT == ARRAY_SIZE(virtual_media_tmpl));
261260

262261
static const FatDirectoryEntry_t root_dir_entry = {
263262
/*uint8_t[11] */ .filename = {""},
@@ -311,7 +310,7 @@ static void write_fat(file_allocation_table_t *fat, uint32_t idx, uint16_t val)
311310
high_idx = idx * 2 + 1;
312311

313312
// Assert that this is still within the fat table
314-
if (high_idx >= ELEMENTS_IN_ARRAY(fat->f)) {
313+
if (high_idx >= ARRAY_SIZE(fat->f)) {
315314
util_assert(0);
316315
return;
317316
}
@@ -366,7 +365,7 @@ void vfs_init(const vfs_filename_t drive_name, uint32_t disk_size)
366365
virtual_media_idx = MEDIA_IDX_COUNT;
367366
data_start = 0;
368367

369-
for (i = 0; i < ELEMENTS_IN_ARRAY(virtual_media_tmpl); i++) {
368+
for (i = 0; i < ARRAY_SIZE(virtual_media_tmpl); i++) {
370369
data_start += virtual_media[i].length;
371370
}
372371

@@ -424,7 +423,7 @@ vfs_file_t vfs_create_file(const vfs_filename_t filename, vfs_read_cb_t read_cb,
424423
}
425424

426425
// Update directory entry
427-
if (dir_idx >= ELEMENTS_IN_ARRAY(dir_current.f)) {
426+
if (dir_idx >= ARRAY_SIZE(dir_current.f)) {
428427
util_assert(0);
429428
return VFS_FILE_INVALID;
430429
}
@@ -438,7 +437,7 @@ vfs_file_t vfs_create_file(const vfs_filename_t filename, vfs_read_cb_t read_cb,
438437
de->first_cluster_low_16 = (first_cluster >> 0) & 0xFFFF;
439438

440439
// Update virtual media
441-
if (virtual_media_idx >= ELEMENTS_IN_ARRAY(virtual_media)) {
440+
if (virtual_media_idx >= ARRAY_SIZE(virtual_media)) {
442441
util_assert(0);
443442
return VFS_FILE_INVALID;
444443
}
@@ -502,7 +501,7 @@ void vfs_read(uint32_t requested_sector, uint8_t *buf, uint32_t num_sectors)
502501
memset(buf, 0, num_sectors * VFS_SECTOR_SIZE);
503502
current_sector = 0;
504503

505-
for (i = 0; i < ELEMENTS_IN_ARRAY(virtual_media); i++) {
504+
for (i = 0; i < ARRAY_SIZE(virtual_media); i++) {
506505
uint32_t vm_sectors = virtual_media[i].length / VFS_SECTOR_SIZE;
507506
uint32_t vm_start = current_sector;
508507
uint32_t vm_end = current_sector + vm_sectors;

source/daplink/error.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
#include "error.h"
2323
#include "util.h"
24-
#include "macro.h"
2524
#include "compiler.h"
2625

2726
static const char *const error_message[] = {
@@ -223,7 +222,7 @@ static error_type_t error_type[] = {
223222
ERROR_TYPE_INTERFACE,
224223
};
225224

226-
COMPILER_ASSERT(ERROR_COUNT == ELEMENTS_IN_ARRAY(error_message));
225+
COMPILER_ASSERT(ERROR_COUNT == ARRAY_SIZE(error_message));
227226

228227
const char *error_get_string(error_t error)
229228
{

source/daplink/macro.h

Lines changed: 0 additions & 47 deletions
This file was deleted.

0 commit comments

Comments
 (0)