macros: add min()/max()

tags/0.1.0
S.J.R. van Schaik 8 years ago
parent e946d0ce3d
commit 03f4913e1a
  1. 4
      macros.h
  2. 3
      shell.c

@ -0,0 +1,4 @@
#pragma once
#define min(x, y) ((x < y) ? (x) : (y))
#define max(x, y) ((x > y) ? (x) : (y))

@ -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…
Cancel
Save