Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: SDFileSystem app epson mbed msp430 pl tests
utils.h
- Committer:
- marcbax
- Date:
- 2018-01-11
- Revision:
- 0:c643d398cdb6
File content as of revision 0:c643d398cdb6:
/*
Plastic Logic EPD project on MSP430
Copyright (C) 2013 Plastic Logic Limited
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef INCLUDE_UTIL_H
#define INCLUDE_UTIL_H 1
//#include "FatFs/ff.h"
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#ifdef LOG_TAG
#define LOG(msg, ...) \
do { printf("%-16s "msg"\n", LOG_TAG, ##__VA_ARGS__); } while (0)
#else
#define LOG(msg, ...)
#endif
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
#endif
#ifndef min
#define min(x,y) ( (x) < (y) ? (x) : (y) )
#endif
#ifndef max
#define max(x,y) ( (x) > (y) ? (x) : (y) )
#endif
#define DIV_ROUND_CLOSEST(x, divisor)( \
{ \
(((x) + ((divisor) / 2)) / (divisor)); \
} \
)
#define CPU_CLOCK_SPEED_IN_HZ 20000000L
#if CPU_CLOCK_SPEED_IN_HZ < 1000000L
#error CPU_CLOCK_SPEED_IN_HZ assumed to be more than 1MHz in delay timer calculations
#endif
/* -- Sleep & delay -- */
extern void udelay(uint16_t us);
extern void mdelay(uint16_t ms);
extern void msleep(uint16_t ms);
/* -- Debug utilities */
/** Print the contents of a buffer with offsets on stdout */
extern void dump_hex(const void *data, uint16_t len);
#endif /* INCLUDE_UTIL_H */