https://bitbucket.org/daniel_fort/magic-lantern
Raw File
Tip revision: 0028818b7c00f373c6e57ee2ea6fea65a4db477e authored by Pieter Vandecandelaere on 16 May 2017, 13:00:59 UTC
initial 550D 110
Tip revision: 0028818
util.h
#ifndef __UTIL_H__
#define __UTIL_H__



/**
 * @brief decrease variable at given address with interrupts disabled
 * @param value pointer to value to decrease
 */
void util_atomic_dec(uint32_t *value);

/**
 * @brief increase variable at given address with interrupts disabled
 * @param value pointer to value to increase
 */
void util_atomic_inc(uint32_t *value);

/* macros from: http://gareus.org/wiki/embedding_resources_in_executables */
/**
 * @brief macros to access resource data that has been added using objcopy or ld
 */
#define EXTLD(NAME) \
  extern const unsigned char _binary_ ## NAME ## _start[]; \
  extern const unsigned char _binary_ ## NAME ## _end[]
#define LDVAR(NAME) _binary_ ## NAME ## _start
#define LDLEN(NAME) ((_binary_ ## NAME ## _end) - (_binary_ ## NAME ## _start))


/* simple binary search */
/* crit returns negative if the tested value is too high, positive if too low, 0 if perfect */
typedef int (*CritFunc)(int);
int bin_search(int lo, int hi, CritFunc crit);
  
#endif
back to top