<commit_before>#ifndef __PLATFORM_H
#define __PLATFORM_H

#include "ft81x/platforms/platform_types.h"

// the board file defines the platform
#include "ft81x/boards/board.h"

#ifndef FT81X_PLATFORM
#  error FT81X_PLATFORM is not defined
#elif ((FT81X_PLATFORM) == (FT81X_PLATFORM_NXP_KINETIS_K66))
#  include "ft81x/platforms/nxp_kinetis_k66.h"
#else
#  error FT81X_PLATFORM is not a defined platform
#endif

#include "ft81x/commands.h"

#include <stdint.h>

typedef enum
{
    FT81X_PLATFORM_GPIO_DIRECTION_INPUT,
    FT81X_PLATFORM_GPIO_DIRECTION_OUTPUT
} ft81x_gpio_direction;

// ----------------------------------------------------------------------------
// Helper macros
// ----------------------------------------------------------------------------
#define WRITE_GPU_MEM(addr, count, data)                                                    \
{                                                                                           \
    ft81x_result res = ft81x_platform_gpu_write_mem(handle, addr, count, data); \
    if (res != FT81X_RESULT_OK)                                                             \
    {                                                                                       \
        return res;                                                                         \
    }                                                                                       \
}

#define WRITE_GPU_REG_8(addr, data)                                                         \
{                                                                                           \
    ft81x_result res = ft81x_platform_gpu_write_register_8(handle, addr, data); \
    if (res != FT81X_RESULT_OK)                                                             \
    {                                                                                       \
        return res;                                                                         \
    }                                                                                       \
}

#define WRITE_GPU_REG_16(addr, data)                                                            \
{                                                                                               \
    ft81x_result res = ft81x_platform_gpu_write_register_16(handle, addr, data);    \
    if (res != FT81X_RESULT_OK)                                                                 \
    {                                                                                           \
        return res;                                                                             \
    }                                                                                           \
}

#define WRITE_GPU_REG_32(addr, data)                                                            \
{                                                                                               \
    ft81x_result res = ft81x_platform_gpu_write_register_32(handle, addr, data);    \
    if (res != FT81X_RESULT_OK)                                                                 \
    {                                                                                           \
        return res;                                                                             \
    }                                                                                           \
}

#define READ_GPU_REG_32(addr, data)                                                            \
{                                                                                               \
    ft81x_result res = ft81x_platform_gpu_read_register_32(handle, addr, &data);    \
    if (res != FT81X_RESULT_OK)                                                                 \
    {                                                                                           \
        return res;                                                                             \
    }                                                                                           \
}

#define DUMP_GPU_REG_32(addr)                                       \
{                                                                   \
    uint32_t data;                                                  \
    READ_GPU_REG_32(addr, data);                                    \
    printf("%s (%08X) = %08X\n", #addr, addr, (unsigned int)data);  \
}

// ----------------------------------------------------------------------------
// Platform API functions
// ----------------------------------------------------------------------------
ft81x_result ft81x_platform_initialise(FT81X_Handle *handle);<commit_msg>FT81X_LIB Platform: Added more brackets to helper macros.<commit_after>#ifndef __PLATFORM_H
#define __PLATFORM_H

#include "ft81x/platforms/platform_types.h"

// the board file defines the platform
#include "ft81x/boards/board.h"

#ifndef FT81X_PLATFORM
#  error FT81X_PLATFORM is not defined
#elif ((FT81X_PLATFORM) == (FT81X_PLATFORM_NXP_KINETIS_K66))
#  include "ft81x/platforms/nxp_kinetis_k66.h"
#else
#  error FT81X_PLATFORM is not a defined platform
#endif

#include "ft81x/commands.h"

#include <stdint.h>

typedef enum
{
    FT81X_PLATFORM_GPIO_DIRECTION_INPUT,
    FT81X_PLATFORM_GPIO_DIRECTION_OUTPUT
} ft81x_gpio_direction;

// ----------------------------------------------------------------------------
// Helper macros
// ----------------------------------------------------------------------------
#define WRITE_GPU_MEM(addr, count, data)                                                    \
{                                                                                           \
    ft81x_result res = ft81x_platform_gpu_write_mem((handle), (addr), (count), (data));     \
    if (res != FT81X_RESULT_OK)                                                             \
    {                                                                                       \
        return res;                                                                         \
    }                                                                                       \
}

#define WRITE_GPU_REG_8(addr, data)                                                         \
{                                                                                           \
    ft81x_result res = ft81x_platform_gpu_write_register_8((handle), (addr), (data));       \
    if (res != FT81X_RESULT_OK)                                                             \
    {                                                                                       \
        return res;                                                                         \
    }                                                                                       \
}

#define WRITE_GPU_REG_16(addr, data)                                                            \
{                                                                                               \
    ft81x_result res = ft81x_platform_gpu_write_register_16((handle), (addr), (data));          \
    if (res != FT81X_RESULT_OK)                                                                 \
    {                                                                                           \
        return res;                                                                             \
    }                                                                                           \
}

#define WRITE_GPU_REG_32(addr, data)                                                            \
{                                                                                               \
    ft81x_result res = ft81x_platform_gpu_write_register_32((handle), (addr), (data));          \
    if (res != FT81X_RESULT_OK)                                                                 \
    {                                                                                           \
        return res;                                                                             \
    }                                                                                           \
}

#define READ_GPU_REG_32(addr, data)                                                            \
{                                                                                               \
    ft81x_result res = ft81x_platform_gpu_read_register_32((handle), (addr), &(data));          \
    if (res != FT81X_RESULT_OK)                                                                 \
    {                                                                                           \
        return res;                                                                             \
    }                                                                                           \
}

#define DUMP_GPU_REG_32(addr)                                           \
{                                                                       \
    uint32_t data;                                                      \
    READ_GPU_REG_32((addr), data);                                      \
    printf("%s (%08X) = %08X\n", #addr, (addr), (unsigned int)data);    \
}

// ----------------------------------------------------------------------------
// Platform API functions
// ----------------------------------------------------------------------------
ft81x_result ft81x_platform_initialise(FT81X_Handle *handle);
{'fraction_non_alphanumeric': 0.11701680672268908, 'fraction_numerical': 0.018697478991596638, 'mean_word_length': 0.4485014453065571, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 203, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3398585', 'n_tokens_mistral': 1690, 'n_tokens_neox': 1586, 'n_words': 270}