GEX core repository.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gex-core/framework/resources.h

40 lines
990 B

7 years ago
//
// Created by MightyPork on 2017/11/24.
//
#ifndef GEX_RESOURCES_H
#define GEX_RESOURCES_H
#include "platform.h"
#include "unit.h"
#include "rsc_enum.h"
7 years ago
#define CHECK_SUC() do { if (!suc) return false; } while (0)
void rsc_init_registry(void);
error_t rsc_claim_pin(Unit *unit, char port_name, uint8_t pin);
error_t rsc_claim(Unit *unit, Resource rsc);
error_t rsc_claim_range(Unit *unit, Resource rsc0, Resource rsc1);
7 years ago
/**
* Claim GPIOs by bitmask and port name, atomically.
* Tear down the unit on failure.
*
* @param unit - claiming unit
* @param port_name - port (eg. 'A')
* @param pins - pins, bitmask
* @return success
*/
error_t rsc_claim_gpios(Unit *unit, char port_name, uint16_t pins);
void rsc_teardown(Unit *unit);
void rsc_free(Unit *unit, Resource rsc);
void rsc_free_range(Unit *unit, Resource rsc0, Resource rsc1);
7 years ago
const char * rsc_get_name(Resource rsc);
/** Get rsc owner name */
const char * rsc_get_owner_name(Resource rsc);
7 years ago
#endif //GEX_RESOURCES_H