macros: add min()/max()
This commit is contained in:
parent
e946d0ce3d
commit
03f4913e1a
2 changed files with 6 additions and 1 deletions
4
macros.h
Normal file
4
macros.h
Normal file
|
@ -0,0 +1,4 @@
|
|||
#pragma once
|
||||
|
||||
#define min(x, y) ((x < y) ? (x) : (y))
|
||||
#define max(x, y) ((x > y) ? (x) : (y))
|
3
shell.c
3
shell.c
|
@ -13,6 +13,7 @@
|
|||
#include <limits.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "macros.h"
|
||||
#include "shell.h"
|
||||
#include "spi_flash.h"
|
||||
#include "usart.h"
|
||||
|
@ -156,7 +157,7 @@ static void do_read(FILE *fp, const char *s)
|
|||
return;
|
||||
|
||||
while (len) {
|
||||
nbytes = (len > 256) ? 256 : len;
|
||||
nbytes = min(len, 256);
|
||||
spi_flash_read(SPI1, addr, buf, nbytes);
|
||||
print_hex_ascii(fp, buf, nbytes);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue