### Install Project Components Source: https://github.com/libdriver/syn6288/blob/main/CONTRIBUTING.md Defines installation rules for runtime binaries, static libraries, and dynamic libraries with their respective destinations. ```cmake # install the binary install(TARGETS ${CMAKE_PROJECT_NAME}_exe RUNTIME DESTINATION bin ) # install the static library install(TARGETS ${CMAKE_PROJECT_NAME}_static ARCHIVE DESTINATION lib ) # install the dynamic library install(TARGETS ${CMAKE_PROJECT_NAME} EXPORT ${CMAKE_PROJECT_NAME}-targets LIBRARY DESTINATION lib PUBLIC_HEADER DESTINATION include/${CMAKE_PROJECT_NAME} ) ``` -------------------------------- ### Makefile Install Rules Source: https://github.com/libdriver/syn6288/blob/main/CONTRIBUTING.md Provides rules for installing the application, shared library, and static library to their designated system locations. Includes directory creation and symbolic linking. ```makefile # set install .PHONY .PHONY: install # install files install : $(shell if [ ! -d $(INC_INSTL_DIRS) ]; then mkdir $(INC_INSTL_DIRS); fi;) cp -rv $(INSTL_INCS) $(INC_INSTL_DIRS) cp -rv $(SHARED_LIB_NAME).$(VERSION) $(LIB_INSTL_DIRS) ln -sf $(LIB_INSTL_DIRS)/$(SHARED_LIB_NAME).$(VERSION) $(LIB_INSTL_DIRS)/$(SHARED_LIB_NAME) cp -rv $(STATIC_LIB_NAME) $(LIB_INSTL_DIRS) cp -rv $(APP_NAME) $(BIN_INSTL_DIRS) ``` -------------------------------- ### Install SYN6288 Project with Make Source: https://github.com/libdriver/syn6288/blob/main/project/raspberrypi4b/README.md Installs the compiled SYN6288 driver to the system. This step is optional. ```shell sudo make install ``` -------------------------------- ### Install Dependencies for SYN6288 Source: https://github.com/libdriver/syn6288/blob/main/project/raspberrypi4b/README.md Installs necessary development libraries for building the SYN6288 driver. ```shell sudo apt-get install libgpiod-dev pkg-config cmake -y ``` -------------------------------- ### Platform Interface Implementation Example Source: https://context7.com/libdriver/syn6288/llms.txt Provides an example implementation of the `driver_syn6288_interface` for a platform using STM32 HAL. This includes UART initialization, deinitialization, read/write operations, flushing, delay, and debug printing. Ensure the correct HAL functions and UART peripherals (e.g., `huart1`, `huart2`) are configured for your specific MCU. ```c #include "driver_syn6288_interface.h" /* Include your MCU HAL here, e.g. stm32f4xx_hal.h or wiringPi.h */ uint8_t syn6288_interface_uart_init(void) { /* Open UART at 9600 bps, 8N1. Return 0 on success, 1 on failure. */ return HAL_UART_Init(&huart1) == HAL_OK ? 0 : 1; } uint8_t syn6288_interface_uart_deinit(void) { return HAL_UART_DeInit(&huart1) == HAL_OK ? 0 : 1; } uint16_t syn6288_interface_uart_read(uint8_t *buf, uint16_t len) { /* Return actual number of bytes read */ uint16_t received = 0; HAL_UART_Receive(&huart1, buf, len, 200); /* 200 ms timeout */ return len; /* or actual bytes received */ } uint8_t syn6288_interface_uart_write(uint8_t *buf, uint16_t len) { return HAL_UART_Transmit(&huart1, buf, len, 100) == HAL_OK ? 0 : 1; } uint8_t syn6288_interface_uart_flush(void) { __HAL_UART_FLUSH_DRREGISTER(&huart1); return 0; } void syn6288_interface_delay_ms(uint32_t ms) { HAL_Delay(ms); } void syn6288_interface_debug_print(const char *const fmt, ...) { char buf[128]; va_list args; va_start(args, fmt); vsnprintf(buf, sizeof(buf), fmt, args); va_end(args); HAL_UART_Transmit(&huart2, (uint8_t *)buf, strlen(buf), 100); /* debug UART */ } ``` -------------------------------- ### SYN6288 Basic Deinitialization Example Source: https://github.com/libdriver/syn6288/blob/main/doc/html/driver__syn6288__basic_8c_source.html Deinitializes the SYN6288 device. Returns 0 on success, 1 if deinitialization fails. ```c uint8_t syn6288_basic_deinit(void) { /* deinit syn6288 */ if (syn6288_deinit(&gs_handle) != 0) { return 1; } else { return 0; } } ``` -------------------------------- ### Makefile Basic Configuration Variables Source: https://github.com/libdriver/syn6288/blob/main/CONTRIBUTING.md Define essential project details such as version, application name, library names, and installation directories. ```makefile # set the project version VERSION := 2.1.0 # set the application name APP_NAME := demo # set the shared libraries name SHARED_LIB_NAME := libdemo.so # set the static libraries name STATIC_LIB_NAME := libdemo.a # set the install directories INSTL_DIRS := /usr/local # set the include directories INC_INSTL_DIRS := $(INSTL_DIRS)/include/$(APP_NAME) # set the library directories LIB_INSTL_DIRS := $(INSTL_DIRS)/lib # set the bin directories BIN_INSTL_DIRS := $(INSTL_DIRS)/bin # set the compiler CC := gcc # set the ar tool AR := ar ``` -------------------------------- ### CMake Configuration for Package Installation Source: https://github.com/libdriver/syn6288/blob/main/CONTRIBUTING.md Configures CMake to write package configuration and version files, and installs them along with the project's targets. Ensure the `PACKAGE_VERSION` variable is correctly set. ```cmake write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/cmake/${CMAKE_PROJECT_NAME}-config-version.cmake VERSION ${PACKAGE_VERSION} COMPATIBILITY AnyNewerVersion ) # install the cmake files install(FILES "${CMAKE_CURRENT_BINARY_DIR}/cmake/${CMAKE_PROJECT_NAME}-config.cmake" "${CMAKE_CURRENT_BINARY_DIR}/cmake/${CMAKE_PROJECT_NAME}-config-version.cmake" DESTINATION cmake ) # set the export items install(EXPORT ${CMAKE_PROJECT_NAME}-targets DESTINATION cmake ) ``` -------------------------------- ### Defining Compilation and Installation Directories Source: https://github.com/libdriver/syn6288/blob/main/CONTRIBUTING.md Defines CMake variables for library include directories, general include directories, header files for installation, source files for libraries, and source files for programs. ```cmake # include all library header directories set(LIB_INC_DIRS ${OpenCV_INCLUDE_DIRS} ${GSL_INCLUDE_DIRS} ) # include all linked libraries set(LIBS ${OpenCV_LIBRARIES} ${GSL_LIBRARIES} ) # include all header directories set(INC_DIRS ${LIB_INC_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/src ``` -------------------------------- ### Initialize SYN6288 Basic Example Source: https://github.com/libdriver/syn6288/blob/main/doc/html/driver__syn6288__basic_8c_source.html Initializes the SYN6288 driver and links the interface functions. This function should be called before any other SYN6288 driver functions. It also configures the default baud rate, mode, and text type if SYN6288_BASIC_SEND_CONFIG is defined as 1. ```c uint8_t syn6288_basic_init(void) { uint8_t res; /* link interface function */ DRIVER_SYN6288_LINK_INIT(&gs_handle, syn6288_handle_t); DRIVER_SYN6288_LINK_UART_INIT(&gs_handle, syn6288_interface_uart_init); DRIVER_SYN6288_LINK_UART_DEINIT(&gs_handle, syn6288_interface_uart_deinit); DRIVER_SYN6288_LINK_UART_READ(&gs_handle, syn6288_interface_uart_read); DRIVER_SYN6288_LINK_UART_WRITE(&gs_handle, syn6288_interface_uart_write); DRIVER_SYN6288_LINK_UART_FLUSH(&gs_handle, syn6288_interface_uart_flush); DRIVER_SYN6288_LINK_DELAY_MS(&gs_handle, syn6288_interface_delay_ms); DRIVER_SYN6288_LINK_DEBUG_PRINT(&gs_handle, syn6288_interface_debug_print); /* syn6288 init */ res = syn6288_init(&gs_handle); if (res != 0) { syn6288_interface_debug_print("syn6288: init failed.\n"); return 1; } #if (SYN6288_BASIC_SEND_CONFIG == 1) /* set defalut baud rate */ res = syn6288_set_baud_rate(&gs_handle, SYN6288_BASIC_DEFAULT_BAUD_RATE); if (res != 0) { syn6288_interface_debug_print("syn6288: set baud rate failed.\n"); (void)syn6288_deinit(&gs_handle); return 1; } syn6288_interface_delay_ms(100); /* set defalut mode */ res = syn6288_set_mode(&gs_handle, SYN6288_BASIC_DEFAULT_MODE); if (res != 0) { syn6288_interface_debug_print("syn6288: set mode failed.\n"); (void)syn6288_deinit(&gs_handle); return 1; } syn6288_interface_delay_ms(100); /* set defalut text type */ res = syn6288_set_text_type(&gs_handle, SYN6288_BASIC_DEFAULT_TEXT_TYPE); if (res != 0) { ``` -------------------------------- ### Basic driver example Source: https://context7.com/libdriver/syn6288/llms.txt A simplified wrapper that hides handle management for applications needing only text-to-speech. It defaults to 9600 bps, common mode, GB2312 encoding, maximum volume, and fastest speed. ```APIDOC ### Basic example driver — `syn6288_basic_init` / `syn6288_basic_synthesis` / `syn6288_basic_sync` / `syn6288_basic_deinit` A simplified wrapper that hides handle management for applications needing only text-to-speech. Defaults: 9600 bps, common mode, GB2312, volume 16, background volume 0, speed 5. To send configuration commands on startup, define `SYN6288_BASIC_SEND_CONFIG 1` before including the header. ### Example Usage: ```c #include "driver_syn6288_basic.h" uint8_t res; /* Initialize chip with default settings */ res = syn6288_basic_init(); if (res != 0) { return 1; /* init failed */ } /* Synthesize GB2312-encoded text "你好" */ res = syn6288_basic_synthesis("你好"); if (res != 0) { /* chip busy or UART error */ (void)syn6288_basic_deinit(); return 1; } /* Block until speech completes (polls every 500 ms) */ res = syn6288_basic_sync(); if (res != 0) { (void)syn6288_basic_deinit(); return 1; } /* Clean shutdown */ (void)syn6288_basic_deinit(); return 0; ``` ``` -------------------------------- ### Makefile Source and Include Path Configuration Source: https://github.com/libdriver/syn6288/blob/main/CONTRIBUTING.md Configure directories for source files, header files, and installation paths. Define collections for source files, header files, and main executable sources. ```makefile # set the pck-config header directories LIB_INC_DIRS := $(shell pkg-config --cflags $(PKGS)) # set the linked libraries LIBS := -lm \ -lz # add the linked libraries LIBS += $(shell pkg-config --libs $(PKGS)) # set all header directories INC_DIRS := -I ./src \ -I ./interface \ -I ./example \ -I ./test # add the linked libraries header directories INC_DIRS += $(LIB_INC_DIRS) # set the installing headers INSTL_INCS := $(wildcard ./src/*.h) \ $(wildcard ./interface/*.h) \ $(wildcard ./example/*.h) \ $(wildcard ./test/*.h) # set all sources files SRCS := $(wildcard ./src/*.c) \ $(wildcard ./interface/*.c) \ $(wildcard ./example/*.c) \ $(wildcard ./test/*.c) # set the main source MAIN := $(wildcard ./project/main.c) \ $(SRCS) ``` -------------------------------- ### SYN6288 Set Synthesis Speed Example Source: https://github.com/libdriver/syn6288/blob/main/doc/html/driver__syn6288__advance_8c_source.html Sets the default synthesis speed for the SYN6288. Includes error handling and deinitialization on failure. ```c res = syn6288_set_synthesis_speed(&gs_handle, SYN6288_ADVANCE_DEFAULT_SYNTHESIS_SPEED); if (res != 0) { syn6288_interface_debug_print("syn6288: set synthesis speed failed.\n"); (void)syn6288_deinit(&gs_handle); return 1; } ``` -------------------------------- ### SYN6288 Set Background Volume Example Source: https://github.com/libdriver/syn6288/blob/main/doc/html/driver__syn6288__advance_8c_source.html Sets the default background volume for the SYN6288. Includes error handling and deinitialization on failure. ```c res = syn6288_set_background_volume(&gs_handle, SYN6288_ADVANCE_DEFAULT_BACKGROUND_VOLUME); if (res != 0) { syn6288_interface_debug_print("syn6288: set background volume failed.\n"); (void)syn6288_deinit(&gs_handle); return 1; } ``` -------------------------------- ### SYN6288 Set Synthesis Volume Example Source: https://github.com/libdriver/syn6288/blob/main/doc/html/driver__syn6288__advance_8c_source.html Sets the default synthesis volume for the SYN6288. Includes error handling and deinitialization on failure. ```c res = syn6288_set_synthesis_volume(&gs_handle, SYN6288_ADVANCE_DEFAULT_SYNTHESIS_VOLUME); if (res != 0) { syn6288_interface_debug_print("syn6288: set synthesis volume failed.\n"); (void)syn6288_deinit(&gs_handle); return 1; } ``` -------------------------------- ### SYN6288 Basic Synthesis Example Source: https://github.com/libdriver/syn6288/blob/main/doc/html/driver__syn6288__basic_8c_source.html Synthesizes the provided text using the SYN6288 driver. It first checks the device status to ensure it's not busy before initiating the synthesis. Returns 0 on success, 1 on failure or if the device is busy. ```c uint8_t syn6288_basic_synthesis(char *text) { uint8_t res; syn6288_status_t status; /* get status */ res = syn6288_get_status(&gs_handle, &status); if (res != 0) { return 1; } /* check status */ if (status == SYN6288_STATUS_BUSY) { return 1; } /* synthesis text */ if (syn6288_synthesis_text(&gs_handle, text) != 0) { return 1; } else { return 0; } } ``` -------------------------------- ### Advanced Driver - Full Playback Control Example Source: https://context7.com/libdriver/syn6288/llms.txt Demonstrates comprehensive control over the SYN6288 module, including text-to-speech, built-in sound effects, message alerts, ringtones, and playback manipulation (pause, resume, stop). Requires SYN6288_ADVANCE_SEND_CONFIG 1 to be defined for default configuration on initialization. Ensure proper error handling after each function call. ```c #include "driver_syn6288_advance.h" uint8_t res; res = syn6288_advance_init(); if (res != 0) { return 1; } /* Text-to-speech */ res = syn6288_advance_synthesis("你好"); if (res != 0) { (void)syn6288_advance_deinit(); return 1; } (void)syn6288_advance_sync(); /* Built-in sound effect */ res = syn6288_advance_sound(SYN6288_SOUND_A); if (res != 0) { (void)syn6288_advance_deinit(); return 1; } (void)syn6288_advance_sync(); /* Message alert */ res = syn6288_advance_message(SYN6288_MESSAGE_A); if (res != 0) { (void)syn6288_advance_deinit(); return 1; } (void)syn6288_advance_sync(); /* Ringtone */ res = syn6288_advance_ring(SYN6288_RING_A); if (res != 0) { (void)syn6288_advance_deinit(); return 1; } (void)syn6288_advance_sync(); /* Pause / resume / stop during ongoing synthesis */ (void)syn6288_advance_synthesis("语音天下"); syn6288_interface_delay_ms(300); (void)syn6288_advance_pause(); syn6288_interface_delay_ms(2000); (void)syn6288_advance_resume(); (void)syn6288_advance_sync(); /* Power down and release */ (void)syn6288_advance_power_down(); (void)syn6288_advance_deinit(); return 0; ``` -------------------------------- ### CMake Package Configuration Source: https://github.com/libdriver/syn6288/blob/main/CONTRIBUTING.md Sets up CPack for packaging the installation program, including package name, version, contact information, description, generator type, and Debian-specific settings like maintainer, architecture, and dependencies. ```cmake # set the cpack package name set(CPACK_PACKAGE_NAME ${PROJECT_NAME}) # set the package version set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION}) # set the package contact set(CPACK_PACKAGE_CONTACT "xxxx@xxx.com") # set the package description set(CPACK_PACKAGE_DESCRIPTION "cpack demo program") # deb output set(CPACK_GENERATOR "DEB") # set the package maintainer set(CPACK_DEBIAN_PACKAGE_MAINTAINER "XXX") # set the cpu type set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "armhf") # set the package name set(CPACK_DEBIAN_FILE_NAME ${CMAKE_PROJECT_NAME}_${PROJECT_VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}.deb) # set the package depends set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6") # .tar.gz output # set(CPACK_GENERATOR TGZ) # set the package name # set(CPACK_PACKAGE_FILE_NAME ${CMAKE_PROJECT_NAME}_${PROJECT_VERSION}) # include the CPack include(CPack) ``` -------------------------------- ### SYN6288 Set Synthesis Volume Example Source: https://github.com/libdriver/syn6288/blob/main/doc/html/driver__syn6288__basic_8c_source.html Sets the default synthesis volume for the SYN6288 device. Includes error handling and deinitialization if the operation fails. A delay is introduced after setting the volume. ```c res = syn6288_set_synthesis_volume(&gs_handle, SYN6288_BASIC_DEFAULT_SYNTHESIS_VOLUME); if (res != 0) { syn6288_interface_debug_print("syn6288: set synthesis volume failed.\n"); (void)syn6288_deinit(&gs_handle); return 1; } syn6288_interface_delay_ms(100); ``` -------------------------------- ### SYN6288 Set Synthesis Speed Example Source: https://github.com/libdriver/syn6288/blob/main/doc/html/driver__syn6288__basic_8c_source.html Sets the default synthesis speed for the SYN6288 device. Includes error handling and deinitialization if the operation fails. A delay is introduced after setting the speed. ```c res = syn6288_set_synthesis_speed(&gs_handle, SYN6288_BASIC_DEFAULT_SYNTHESIS_SPEED); if (res != 0) { syn6288_interface_debug_print("syn6288: set synthesis speed failed.\n"); (void)syn6288_deinit(&gs_handle); return 1; } syn6288_interface_delay_ms(100); ``` -------------------------------- ### SYN6288 Set Background Volume Example Source: https://github.com/libdriver/syn6288/blob/main/doc/html/driver__syn6288__basic_8c_source.html Sets the default background volume for the SYN6288 device. Includes error handling and deinitialization if the operation fails. A delay is introduced after setting the volume. ```c res = syn6288_set_background_volume(&gs_handle, SYN6288_BASIC_DEFAULT_BACKGROUND_VOLUME); if (res != 0) { syn6288_interface_debug_print("syn6288: set background volume failed.\n"); (void)syn6288_deinit(&gs_handle); return 1; } syn6288_interface_delay_ms(100); ``` -------------------------------- ### Define Dynamic Library Build Source: https://github.com/libdriver/syn6288/blob/main/CONTRIBUTING.md Configures the build to output a dynamic library. Sets include directories, link libraries, and public header installation. ```cmake # enable output as a dynamic library add_library(${CMAKE_PROJECT_NAME} SHARED ${SRCS}) # add the definitions target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE TEST_LIB_DEF) # set the executable program include directories target_include_directories(${CMAKE_PROJECT_NAME} PUBLIC $ PRIVATE ${INC_DIRS} ) # set the dynamic library link libraries target_link_libraries(${CMAKE_PROJECT_NAME} ${LIBS} ) # rename as ${CMAKE_PROJECT_NAME} set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES OUTPUT_NAME ${CMAKE_PROJECT_NAME}) # don't delete ${CMAKE_PROJECT_NAME} libs set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES CLEAN_DIRECT_OUTPUT 1) # include the public header set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES PUBLIC_HEADER "${INSTL_INCS}") # set the dynamic library version set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES VERSION ${${CMAKE_PROJECT_NAME}_VERSION}) ``` -------------------------------- ### Syn6288 Get Status Command Transmission Source: https://github.com/libdriver/syn6288/blob/main/doc/html/driver__syn6288_8c_source.html Constructs and sends a command to get the Syn6288 device status. Includes UART flush, write, and read operations with error checking and retries. ```c uint8_t res; uint8_t times = 3; uint16_t len; uint8_t temp[2]; uint8_t cmd[5]; if (handle == NULL) /* check handle */ { return 2; /* return error */ } if (handle->inited != 1) /* check handle initialization */ { return 3; /* return error */ } cmd[0] = 0xFD; /* frame header */ cmd[1] = 0x00; /* length msb */ cmd[2] = 0x02; /* length lsb */ cmd[3] = 0x21; /* command */ cmd[4] = 0xDE; /* xor */ while (1) /* loop */ { res = handle->uart_flush(); /* uart flush */ if (res != 0) /* check result */ { handle->debug_print("syn6288: uart flush failed.\n"); /* uart flush failed */ return 1; /* return error */ } res = handle->uart_write((uint8_t *)cmd, 5); /* uart write */ if (res != 0) /* check result */ { handle->debug_print("syn6288: uart write failed.\n"); /* uart write failed */ return 1; /* return error */ } handle->delay_ms(100); /* delay 100 ms */ memset(temp, 0, sizeof(uint8_t) * 2); /* clear the buffer */ len = handle->uart_read((uint8_t *)temp, 2); /* uart read */ if (len != 2) /* check result */ { handle->debug_print("syn6288: uart read failed.\n"); /* uart read failed */ return 1; /* return error */ } if ((temp[0] == 0x41) && (temp[1] == 0x4F)) /* check frame */ { *status = (syn6288_status_t)(0); /* set status */ return 0; /* success return 0 */ } else if ((temp[0] == 0x41) && (temp[1] == 0x4E)) /* check frame */ { *status = (syn6288_status_t)(1); /* set status */ return 0; /* success return 0 */ } else { if (times != 0) /* check times */ { times--; /* retry times-- */ handle->delay_ms(100); /* delay 100 ms */ continue; /* continue */ } handle->debug_print("syn6288: command receive failed.\n"); /* command receive failed */ return 1; /* return error */ } } ``` -------------------------------- ### syn6288_get_synthesis_speed Source: https://github.com/libdriver/syn6288/blob/main/doc/html/driver__syn6288_8c.html Gets the synthesis speed. ```APIDOC ## syn6288_get_synthesis_speed ### Description Gets the synthesis speed. ### Parameters #### Path Parameters - **handle** (syn6288_handle_t *) - Pointer to the syn6288 handle structure. - **speed** (uint8_t *) - Pointer to the uint8_t to store the synthesis speed. ### Return Value Returns the chip status (uint8_t). ``` -------------------------------- ### syn6288_advance_init Source: https://github.com/libdriver/syn6288/blob/main/doc/html/driver__syn6288__advance_8c.html Initializes the SYN6288 advance driver. ```APIDOC ## syn6288_advance_init ### Description Initializes the SYN6288 advance driver. ### Function Signature ```c uint8_t syn6288_advance_init(void) ``` ### Returns - uint8_t: 0 if success, 1 if error. ``` -------------------------------- ### syn6288_info Source: https://github.com/libdriver/syn6288/blob/main/doc/html/driver__syn6288_8c.html Gets chip's information. ```APIDOC ## syn6288_info ### Description Gets chip's information. ### Parameters #### Path Parameters - **info** (syn6288_info_t *) - Pointer to the syn6288 info structure to store the information. ### Return Value Returns the chip status (uint8_t). ``` -------------------------------- ### syn6288_get_synthesis_volume Source: https://github.com/libdriver/syn6288/blob/main/doc/html/driver__syn6288_8c.html Gets the chip synthesis volume. ```APIDOC ## syn6288_get_synthesis_volume ### Description Gets the chip synthesis volume. ### Parameters #### Path Parameters - **handle** (syn6288_handle_t *) - Pointer to the syn6288 handle structure. - **volume** (uint8_t *) - Pointer to the uint8_t to store the synthesis volume. ### Return Value Returns the chip status (uint8_t). ``` -------------------------------- ### DRIVER_SYN6288_LINK_INIT Source: https://github.com/libdriver/syn6288/blob/main/doc/html/driver__syn6288__basic_8c_source.html Macro to initialize the SYN6288 handle structure. ```APIDOC ## DRIVER_SYN6288_LINK_INIT ### Description Initializes the `syn6288_handle_t` structure. ### Usage ```c DRIVER_SYN6288_LINK_INIT(HANDLE, STRUCTURE) ``` ### Parameters * **HANDLE** - The driver handle. * **STRUCTURE** - The structure to initialize. ``` -------------------------------- ### syn6288_get_text_type Source: https://github.com/libdriver/syn6288/blob/main/doc/html/driver__syn6288_8c.html Gets the chip text type. ```APIDOC ## syn6288_get_text_type ### Description Gets the chip text type. ### Parameters #### Path Parameters - **handle** (syn6288_handle_t *) - Pointer to the syn6288 handle structure. - **type** (syn6288_type_t *) - Pointer to the syn6288 type structure to store the type. ### Return Value Returns the chip status (uint8_t). ``` -------------------------------- ### Test syn6288 text type setting and getting Source: https://github.com/libdriver/syn6288/blob/main/doc/html/driver__syn6288__register__test_8c_source.html This snippet tests the functionality of setting and getting different text types (GB2312, GBK, BIG5) for the syn6288 driver. It includes error handling and debug prints to verify the operations. ```c #define SYN6288_TYPE_GB2312 1 #define SYN6288_TYPE_GBK 2 #define SYN6288_TYPE_BIG5 3 /* syn6288_set_text_type/syn6288_get_text_type test */ syn6288_interface_debug_print("syn6288: syn6288_set_text_type/syn6288_get_text_type test.\n"); /* set GB2312 */ res = syn6288_set_text_type(&gs_handle, SYN6288_TYPE_GB2312); if (res != 0) { syn6288_interface_debug_print("syn6288: set text type failed.\n"); (void)syn6288_deinit(&gs_handle); return 1; } syn6288_interface_debug_print("syn6288: set gb2312 text type.\n"); res = syn6288_get_text_type(&gs_handle, &type); if (res != 0) { syn6288_interface_debug_print("syn6288: get text type failed.\n"); (void)syn6288_deinit(&gs_handle); return 1; } syn6288_interface_debug_print("syn6288: check text type %s.\n", type==SYN6288_TYPE_GB2312?"ok":"error"); /* set GBK */ res = syn6288_set_text_type(&gs_handle, SYN6288_TYPE_GBK); if (res != 0) { syn6288_interface_debug_print("syn6288: set text type failed.\n"); (void)syn6288_deinit(&gs_handle); return 1; } syn6288_interface_debug_print("syn6288: set gbk text type.\n"); res = syn6288_get_text_type(&gs_handle, &type); if (res != 0) { syn6288_interface_debug_print("syn6288: get text type failed.\n"); (void)syn6288_deinit(&gs_handle); return 1; } syn6288_interface_debug_print("syn6288: check text type %s.\n", type==SYN6288_TYPE_GBK?"ok":"error"); /* set BIG5 */ res = syn6288_set_text_type(&gs_handle, SYN6288_TYPE_BIG5); if (res != 0) { syn6288_interface_debug_print("syn6288: set text type failed.\n"); (void)syn6288_deinit(&gs_handle); return 1; } syn6288_interface_debug_print("syn6288: set big5 text type.\n"); res = syn6288_get_text_type(&gs_handle, &type); if (res != 0) { syn6288_interface_debug_print("syn6288: get text type failed.\n"); (void)syn6288_deinit(&gs_handle); return 1; } ``` -------------------------------- ### syn6288_basic_init Source: https://github.com/libdriver/syn6288/blob/main/doc/html/driver__syn6288__basic_8c_source.html Initializes the SYN6288 chip using basic settings. This function should be called before any other operations. ```APIDOC ## syn6288_basic_init ### Description Basic example init. ### Function Signature uint8_t syn6288_basic_init(void) ``` -------------------------------- ### syn6288_get_background_volume Source: https://github.com/libdriver/syn6288/blob/main/doc/html/driver__syn6288_8c.html Gets the chip synthesis background volume. ```APIDOC ## syn6288_get_background_volume ### Description Gets the chip synthesis background volume. ### Parameters #### Path Parameters - **handle** (syn6288_handle_t *) - Pointer to the syn6288 handle structure. - **volume** (uint8_t *) - Pointer to the uint8_t to store the background volume. ### Return Value Returns the chip status (uint8_t). ``` -------------------------------- ### syn6288_basic_init Source: https://github.com/libdriver/syn6288/blob/main/doc/html/driver__syn6288__basic_8h_source.html Initializes the SYN6288 basic driver. This function should be called before any other driver functions. ```APIDOC ## syn6288_basic_init ### Description Initializes the SYN6288 basic driver. This function should be called before any other driver functions. ### Function Signature ```c uint8_t syn6288_basic_init(void); ``` ### Returns - `0` for success - Other values indicate an error ``` -------------------------------- ### Information Retrieval Source: https://github.com/libdriver/syn6288/blob/main/doc/html/driver__syn6288_8c_source.html Function to get information about the SYN6288 chip. ```APIDOC ## syn6288_info ### Description Retrieves information about the SYN6288 chip. ### Parameters - **info** (*syn6288_info_t* *) - Pointer to a structure to store the chip's information. ### Return Value - uint8_t - Returns 0 on success, or an error code otherwise. ``` -------------------------------- ### Basic CMake Project Configuration Source: https://github.com/libdriver/syn6288/blob/main/CONTRIBUTING.md Sets up the minimum CMake version, project name, version, C/C++ standards, and build type flags. Use 'Debug' for development and 'Release' for production builds. ```cmake # set the cmake minimum version cmake_minimum_required(VERSION 3.0) # set the project name and language project(demo C CXX) # read the version from files file(READ ${CMAKE_CURRENT_SOURCE_DIR}/cmake/VERSION ${CMAKE_PROJECT_NAME}_VERSION) # set the project version set(PROJECT_VERSION ${${CMAKE_PROJECT_NAME}_VERSION}) # set c standard c99 set(CMAKE_C_STANDARD 99) # enable c standard required set(CMAKE_C_STANDARD_REQUIRED True) # set c++ standard c++11 set(CMAKE_CXX_STANDARD 11) # enable c++ standard required set(CMAKE_CXX_STANDARD_REQUIRED True) # set debug level # set(CMAKE_BUILD_TYPE Debug) # set the debug flags of c # set(CMAKE_C_FLAGS_DEBUG "-O0 -g") # set the debug flags of c++ # set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g") # set release level set(CMAKE_BUILD_TYPE Release) # set the release flags of c set(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG") # set the release flags of c++ set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG") ``` -------------------------------- ### Status and Control Source: https://github.com/libdriver/syn6288/blob/main/doc/html/driver__syn6288_8c.html Functions for getting the chip status and controlling its operation. ```APIDOC ## syn6288_get_status ### Description Gets the current status of the chip. ### Function Signature `uint8_t syn6288_get_status(syn6288_handle_t *handle, syn6288_status_t *status)` ### Parameters - **handle** (*syn6288_handle_t*): Pointer to the SYN6288 handle structure. - **status** (*syn6288_status_t*): Pointer to a structure to store the chip status. ## syn6288_stop ### Description Stops the chip operation. ### Function Signature `uint8_t syn6288_stop(syn6288_handle_t *handle)` ### Parameters - **handle** (*syn6288_handle_t*): Pointer to the SYN6288 handle structure. ## syn6288_pause ### Description Pauses the chip operation. ### Function Signature `uint8_t syn6288_pause(syn6288_handle_t *handle)` ### Parameters - **handle** (*syn6288_handle_t*): Pointer to the SYN6288 handle structure. ## syn6288_resume ### Description Resumes the chip operation. ### Function Signature `uint8_t syn6288_resume(syn6288_handle_t *handle)` ### Parameters - **handle** (*syn6288_handle_t*): Pointer to the SYN6288 handle structure. ## syn6288_power_down ### Description Powers down the chip. ### Function Signature `uint8_t syn6288_power_down(syn6288_handle_t *handle)` ### Parameters - **handle** (*syn6288_handle_t*): Pointer to the SYN6288 handle structure. ``` -------------------------------- ### Build SYN6288 Project with Make Source: https://github.com/libdriver/syn6288/blob/main/project/raspberrypi4b/README.md Compiles the SYN6288 driver using the Make build system. ```shell make ``` -------------------------------- ### SYN6288 Mode Control Source: https://github.com/libdriver/syn6288/blob/main/doc/html/group__syn6288__advance__driver.html Functions to set and get the operating mode of the SYN6288 chip. ```APIDOC ## syn6288_set_mode ### Description Sets the operating mode for the SYN6288 chip. ### Parameters - **handle** (*syn6288_handle_t*): Pointer to the SYN6288 handle. - **mode** (*syn6288_mode_t*): The desired operating mode. ### Returns - uint8_t: 0 if success, 1 if error. ``` ```APIDOC ## syn6288_get_mode ### Description Gets the current operating mode of the SYN6288 chip. ### Parameters - **handle** (*syn6288_handle_t*): Pointer to the SYN6288 handle. - **mode** (*syn6288_mode_t*): Pointer to store the current operating mode. ### Returns - uint8_t: 0 if success, 1 if error. ``` -------------------------------- ### Basic SYN6288 Driver Initialization and Usage Source: https://context7.com/libdriver/syn6288/llms.txt A simplified wrapper for applications needing only text-to-speech, hiding handle management. Defaults to 9600 bps, common mode, GB2312, volume 16, background volume 0, and speed 5. Define SYN6288_BASIC_SEND_CONFIG 1 before including the header to send configuration commands on startup. ```c #include "driver_syn6288_basic.h" uint8_t res; /* Initialize chip with default settings */ res = syn6288_basic_init(); if (res != 0) { return 1; /* init failed */ } /* Synthesize GB2312-encoded text "你好" */ res = syn6288_basic_synthesis("你好"); if (res != 0) { /* chip busy or UART error */ (void)syn6288_basic_deinit(); return 1; } /* Block until speech completes (polls every 500 ms) */ res = syn6288_basic_sync(); if (res != 0) { (void)syn6288_basic_deinit(); return 1; } /* Clean shutdown */ (void)syn6288_basic_deinit(); return 0; ``` -------------------------------- ### Baud Rate Configuration Source: https://github.com/libdriver/syn6288/blob/main/doc/html/driver__syn6288_8c.html Functions for setting and getting the baud rate of the SYN6288 chip. ```APIDOC ## syn6288_set_baud_rate ### Description Sets the baud rate for the chip. ### Function Signature `uint8_t syn6288_set_baud_rate(syn6288_handle_t *handle, syn6288_baud_rate_t rate)` ### Parameters - **handle** (*syn6288_handle_t*): Pointer to the SYN6288 handle structure. - **rate** (*syn6288_baud_rate_t*): The desired baud rate. ## syn6288_get_baud_rate ### Description Gets the current baud rate of the chip. ### Function Signature `uint8_t syn6288_get_baud_rate(syn6288_handle_t *handle, syn6288_baud_rate_t *rate)` ### Parameters - **handle** (*syn6288_handle_t*): Pointer to the SYN6288 handle structure. - **rate** (*syn6288_baud_rate_t*): Pointer to a variable to store the current baud rate. ``` -------------------------------- ### SY6288 Base Driver Functions Source: https://github.com/libdriver/syn6288/blob/main/doc/html/driver__syn6288_8h_source.html Functions for basic operations like getting the text type. ```APIDOC ## syn6288_get_text_type ### Description Retrieves the text type from the SY6288 chip. ### Parameters - **handle** (*syn6288_handle_t* *) - Pointer to the SY6288 handle structure. - **type** (*syn6288_type_t* *) - Pointer to store the retrieved text type. ### Returns - uint8_t: Returns 0 if successful, otherwise an error code. ``` -------------------------------- ### SYN6288 Synthesis Volume Control Source: https://github.com/libdriver/syn6288/blob/main/doc/html/group__syn6288__advance__driver.html Functions to set and get the synthesis volume for the SYN6288 chip. ```APIDOC ## syn6288_set_synthesis_volume ### Description Sets the synthesis volume for the SYN6288 chip. ### Parameters - **handle** (*syn6288_handle_t*): Pointer to the SYN6288 handle. - **volume** (uint8_t): The desired synthesis volume (typically 0-15). ### Returns - uint8_t: 0 if success, 1 if error. ``` ```APIDOC ## syn6288_get_synthesis_volume ### Description Gets the current synthesis volume of the SYN6288 chip. ### Parameters - **handle** (*syn6288_handle_t*): Pointer to the SYN6288 handle. - **volume** (uint8_t*): Pointer to store the current synthesis volume. ### Returns - uint8_t: 0 if success, 1 if error. ``` -------------------------------- ### SYN6288 Advance Init Source: https://github.com/libdriver/syn6288/blob/main/doc/html/group__syn6288__example__driver.html Initializes the SYN6288 module in advance mode. ```APIDOC ## SYN6288 Advance Init ### Description Initializes the SYN6288 module in advance mode. ### Function Signature `uint8_t syn6288_advance_init(void)` ``` -------------------------------- ### Get SYN6288 Status Source: https://github.com/libdriver/syn6288/blob/main/doc/html/driver__syn6288__advance_8c_source.html Retrieves the current status of the SYN6288 chip. The status is returned via the status pointer. ```c uint8_t syn6288_get_status(syn6288_handle_t *handle, syn6288_status_t *status) ``` -------------------------------- ### DRIVER_SYN6288_LINK_INIT Source: https://github.com/libdriver/syn6288/blob/main/doc/html/driver__syn6288__register__test_8c_source.html Macro to link the initialization function for the SYN6288 handle. ```APIDOC ## DRIVER_SYN6288_LINK_INIT ### Description Links the initialization function for the `syn6288_handle_t` structure. ### Macro Signature ```c #define DRIVER_SYN6288_LINK_INIT(HANDLE, STRUCTURE) ``` ### Parameters - **HANDLE** - The handle for the SYN6288 device. - **STRUCTURE** - The structure to initialize. ``` -------------------------------- ### Mode and Text Type Configuration Source: https://github.com/libdriver/syn6288/blob/main/doc/html/driver__syn6288_8c.html Functions for setting and getting the operating mode and text type of the SYN6288 chip. ```APIDOC ## syn6288_set_mode ### Description Sets the operating mode of the chip. ### Function Signature `uint8_t syn6288_set_mode(syn6288_handle_t *handle, syn6288_mode_t mode)` ### Parameters - **handle** (*syn6288_handle_t*): Pointer to the SYN6288 handle structure. - **mode** (*syn6288_mode_t*): The desired operating mode. ## syn6288_get_mode ### Description Gets the current operating mode of the chip. ### Function Signature `uint8_t syn6288_get_mode(syn6288_handle_t *handle, syn6288_mode_t *mode)` ### Parameters - **handle** (*syn6288_handle_t*): Pointer to the SYN6288 handle structure. - **mode** (*syn6288_mode_t*): Pointer to a variable to store the current operating mode. ## syn6288_set_text_type ### Description Sets the text type for the chip. ### Function Signature `uint8_t syn6288_set_text_type(syn6288_handle_t *handle, syn6288_type_t type)` ### Parameters - **handle** (*syn6288_handle_t*): Pointer to the SYN6288 handle structure. - **type** (*syn6288_type_t*): The desired text type. ``` -------------------------------- ### SYN6288 Basic Init Source: https://github.com/libdriver/syn6288/blob/main/doc/html/group__syn6288__example__driver.html Initializes the SYN6288 module in basic mode. ```APIDOC ## SYN6288 Basic Init ### Description Initializes the SYN6288 module in basic mode. ### Function Signature `uint8_t syn6288_basic_init(void)` ``` -------------------------------- ### Initialize and Synthesize Text (Basic) Source: https://github.com/libdriver/syn6288/blob/main/README.md Initializes the SYN6288 driver in basic mode and synthesizes the provided text. Ensure the UART driver is correctly implemented and the device is initialized before calling this function. Deinitialization is required after use. ```C #include "driver_syn6288_basic.h" uint8_t res; res = syn6288_basic_init(); if (res != 0) { return 1; } ... res = syn6288_basic_synthesis("你好"); if (res != 0) { (void)syn6288_basic_deinit(); return 1; } (void)syn6288_basic_sync(); ... (void)syn6288_basic_deinit(); return 0; ``` -------------------------------- ### Get SY6288 Mode Source: https://github.com/libdriver/syn6288/blob/main/doc/html/driver__syn6288_8c_source.html Retrieves the current operating mode of the SY6288 device. Ensure the handle is valid and initialized before calling. ```c uint8_t syn6288_get_mode(syn6288_handle_t *handle, syn6288_mode_t *mode) { if (handle == NULL) /* check handle */ { return 2; /* return error */ } if (handle->inited != 1) /* check handle initialization */ { return 3; /* return error */ } *mode = (syn6288_mode_t)(handle->mode); /* get mode */ return 0; /* success return 0 */ } ``` -------------------------------- ### syn6288_init Source: https://github.com/libdriver/syn6288/blob/main/doc/html/driver__syn6288_8h.html Initializes the Syn6288 chip. It requires a pointer to a syn6288_handle_t structure for the chip handle. ```APIDOC ## syn6288_init ### Description Initializes the chip. ### Parameters #### Path Parameters - **handle** (*syn6288_handle_t* *) - Pointer to the chip handle. ### Return Value - uint8_t: Returns a status code indicating success or failure. ``` -------------------------------- ### Syn6288 Initialization and Configuration Source: https://github.com/libdriver/syn6288/blob/main/doc/html/driver__syn6288__synthesis__test_8c_source.html Initializes the Syn6288 device, sets the baud rate, mode, synthesis volume, background volume, and synthesis speed. This sequence is crucial for preparing the device for text synthesis. ```c /* syn6288 init */ res = syn6288_init(&gs_handle); if (res != 0) { syn6288_interface_debug_print("syn6288: init failed.\n"); return 1; } /* set baud rate 9600 bps */ res = syn6288_set_baud_rate(&gs_handle, SYN6288_BAUD_RATE_9600_BPS); if (res != 0) { syn6288_interface_debug_print("syn6288: set baud rate failed.\n"); (void)syn6288_deinit(&gs_handle); return 1; } /* set common mode */ res = syn6288_set_mode(&gs_handle, SYN6288_MODE_COMMON); if (res != 0) { syn6288_interface_debug_print("syn6288: set mode failed.\n"); (void)syn6288_deinit(&gs_handle); return 1; } /* set synthesis volume 16 */ res = syn6288_set_synthesis_volume(&gs_handle, 16); if (res != 0) { syn6288_interface_debug_print("syn6288: set synthesis volume failed.\n"); (void)syn6288_deinit(&gs_handle); return 1; } /* set background volume 16 */ res = syn6288_set_background_volume(&gs_handle, 0); if (res != 0) { syn6288_interface_debug_print("syn6288: set background volume failed.\n"); (void)syn6288_deinit(&gs_handle); return 1; } /* set synthesis speed 5 */ res = syn6288_set_synthesis_speed(&gs_handle, 5); if (res != 0) { syn6288_interface_debug_print("syn6288: set synthesis speed failed.\n"); (void)syn6288_deinit(&gs_handle); return 1; } ``` -------------------------------- ### Test Setting Background Volume Source: https://github.com/libdriver/syn6288/blob/main/doc/html/driver__syn6288__register__test_8c_source.html Tests setting and getting the background volume. Includes error handling and debug output. ```c syn6288_interface_debug_print("syn6288: syn6288_set_background_volume/syn6288_get_background_volume test.\n"); res = syn6288_set_background_volume(&gs_handle, 8); if (res != 0) { syn6288_interface_debug_print("syn6288: set background volume failed.\n"); (void)syn6288_deinit(&gs_handle); return 1; } syn6288_interface_debug_print("syn6288: set background volume 8.\n"); res = syn6288_get_background_volume(&gs_handle, (uint8_t *)&volume); if (res != 0) { syn6288_interface_debug_print("syn6288: get background volume failed.\n"); (void)syn6288_deinit(&gs_handle); return 1; } syn6288_interface_debug_print("syn6288: check background volume %s.\n", volume==8?"ok":"error"); ``` -------------------------------- ### syn6288_init Source: https://github.com/libdriver/syn6288/blob/main/doc/html/driver__syn6288_8c_source.html Initializes the SYN6288 driver. It checks for valid handle and initializes the UART interface. ```APIDOC ## syn6288_init ### Description Initializes the SYN6288 driver. It checks for valid handle and initializes the UART interface. ### Parameters #### Path Parameters - **handle** (*syn6288_handle_t*) - Pointer to the SYN6288 handle structure. ### Return Value - **0**: Success - **1**: UART initialization failed - **2**: Handle is NULL - **3**: UART interface functions are NULL ```