macros: move macros for human-readable sizes and rounding
This commit is contained in:
parent
92b3c1108b
commit
39dbac8742
3 changed files with 12 additions and 11 deletions
|
@ -2,3 +2,13 @@
|
|||
|
||||
#define min(x, y) ((x < y) ? (x) : (y))
|
||||
#define max(x, y) ((x > y) ? (x) : (y))
|
||||
|
||||
/* Human-readable sizes */
|
||||
#define KIB 1024
|
||||
#define MIB (1024 * KIB)
|
||||
#define GIB (1024 * GIB)
|
||||
|
||||
/* Rounding */
|
||||
#define IS_ROUND(x, k) (!((x) & ((k) - 1)))
|
||||
#define ROUND_DOWN(x, k) ((x) & ~((k) - 1))
|
||||
#define ROUND_UP(x, k) (((x) + (k) - 1) & ~((k) - 1))
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
#pragma once
|
||||
|
||||
/* Human-readable sizes */
|
||||
#define KIB 1024
|
||||
#define MIB (1024 * KIB)
|
||||
#define GIB (1024 * GIB)
|
||||
|
||||
/* Read commands */
|
||||
#define CMD_READ_ARRAY_SLOW 0x03
|
||||
#define CMD_READ_ID 0x9f
|
||||
|
@ -20,11 +15,6 @@
|
|||
#define CMD_ERASE_64K 0xD8
|
||||
#define CMD_ERASE_CHIP 0x60
|
||||
|
||||
/* Rounding */
|
||||
#define IS_ROUND(x, k) (!((x) & ((k) - 1)))
|
||||
#define ROUND_DOWN(x, k) ((x) & ~((k) - 1))
|
||||
#define ROUND_UP(x, k) (((x) + (k) - 1) & ~((k) - 1))
|
||||
|
||||
void init_spi(void);
|
||||
void spi_send_cmd(uint32_t dev, const char *cmd, size_t cmd_len,
|
||||
char *data, size_t data_len);
|
||||
|
|
|
@ -13,7 +13,8 @@
|
|||
#include <limits.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "spi_flash.h"
|
||||
#include <macros.h>
|
||||
#include <spi_flash.h>
|
||||
|
||||
void init_spi(void)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue