Loading files
701e58161This file is pinned to the selected release. Download the original to open it in your design tool.
Files from this revision, including CAD and LFS contents. Git history is not included.
Or in GitHub Desktop, choose File → Clone repository → URL and paste this address.
Public repositories can be cloned without signing in. For pushing, use your ThingAtlas username and a Git access token as the password.
git lfs install git clone https://thingatlas.com/git/-unclaimed/tulipcc-498083946.git
Includes Git history, branches, and Git LFS files. Clones the repository’s default branch, regardless of the version shown here.
701e58161This file is pinned to the selected release. Download the original to open it in your design tool.
#ifndef __LVMP_DRV_COMMON_H
#define __LVMP_DRV_COMMON_H
#include "py/obj.h"
#include "py/runtime.h"
#include "py/binary.h"
//////////////////////////////////////////////////////////////////////////////
// A read-only buffer that contains a C pointer
// Used to communicate function pointers to lvgl Micropython bindings
//
typedef struct mp_ptr_t
{
mp_obj_base_t base;
void *ptr;
} mp_ptr_t;
STATIC mp_int_t mp_ptr_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags)
{
mp_ptr_t *self = MP_OBJ_TO_PTR(self_in);
if (flags & MP_BUFFER_WRITE) {
// read-only ptr
return 1;
}
bufinfo->buf = &self->ptr;
bufinfo->len = sizeof(self->ptr);
bufinfo->typecode = BYTEARRAY_TYPECODE;
return 0;
}
#define PTR_OBJ(ptr_global) ptr_global ## _obj
#define DEFINE_PTR_OBJ_TYPE(ptr_obj_type, ptr_type_qstr)\
STATIC MP_DEFINE_CONST_OBJ_TYPE(\
ptr_obj_type,\
ptr_type_qstr,\
MP_TYPE_FLAG_NONE,\
buffer, mp_ptr_get_buffer\
);
#define DEFINE_PTR_OBJ(ptr_global)\
DEFINE_PTR_OBJ_TYPE(ptr_global ## _type, MP_QSTR_ ## ptr_global);\
STATIC const mp_ptr_t PTR_OBJ(ptr_global) = {\
{ &ptr_global ## _type },\
&ptr_global\
}
#define NEW_PTR_OBJ(name, value)\
({\
DEFINE_PTR_OBJ_TYPE(ptr_obj_type, MP_QSTR_ ## name);\
mp_ptr_t *self = m_new_obj(mp_ptr_t);\
self->base.type = &ptr_obj_type;\
self->ptr = value;\
MP_OBJ_FROM_PTR(self);\
})
#endif // __LVMP_DRV_COMMON_H