#ifndef _ID_GENERATOR_H
#define _ID_GENERATOR_H

#ifdef __cplusplus
extern "C"
{
#endif

#include <stdint.h>

#include "log.h"

#define ID_GENERATOR_LOG_ERROR(format, ...) LOG_ERROR("id generator", format, ##__VA_ARGS__)
#define ID_GENERATOR_LOG_DEBUG(format, ...) LOG_DEBUG("id generator", format, ##__VA_ARGS__)

/*
 * device_base   (5bit)  : [0, 31]
 * device_offset (7bit)  : [0, 127]
 * device_id     (12bit) : (base << 7 | offset)
 *
 * return  0: success
 * return -1: failed
 */
int id_generator_init(uint8_t device_base, uint8_t device_offset);
uint64_t id_generator_alloc();

#ifdef __cplusplus
}
#endif

#endif
