Skip to content
Permalink
27bbebe77b
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
139 lines (121 sloc) 5.62 KB
/******************************************************************************
* File Name: main.c
*
* Description: CTS Server app implements a Bluetooth LE GAP Central and a
* GATT Server which works with AnyCloud CTS Client CE. This file
* contains the main function which initializes the BSP, Debug UART
* port and Bluetooth stack. It creates a FreeRTOS task to handle
* button press.
*
* Related Document: See README.md
*
*******************************************************************************
* Copyright 2020-2024, Cypress Semiconductor Corporation (an Infineon company) or
* an affiliate of Cypress Semiconductor Corporation. All rights reserved.
*
* This software, including source code, documentation and related
* materials ("Software") is owned by Cypress Semiconductor Corporation
* or one of its affiliates ("Cypress") and is protected by and subject to
* worldwide patent protection (United States and foreign),
* United States copyright laws and international treaty provisions.
* Therefore, you may use this Software only as provided in the license
* agreement accompanying the software package from which you
* obtained this Software ("EULA").
* If no EULA applies, Cypress hereby grants you a personal, non-exclusive,
* non-transferable license to copy, modify, and compile the Software
* source code solely for use in connection with Cypress's
* integrated circuit products. Any reproduction, modification, translation,
* compilation, or representation of this Software except as specified
* above is prohibited without the express written permission of Cypress.
*
* Disclaimer: THIS SOFTWARE IS PROVIDED AS-IS, WITH NO WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, NONINFRINGEMENT, IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Cypress
* reserves the right to make changes to the Software without notice. Cypress
* does not assume any liability arising out of the application or use of the
* Software or any product or circuit described in the Software. Cypress does
* not authorize its products for use in any products where a malfunction or
* failure of the Cypress product may reasonably be expected to result in
* significant property damage, injury or death ("High Risk Product"). By
* including Cypress's product in a High Risk Product, the manufacturer
* of such system or application assumes all risk of such use and in doing
* so agrees to indemnify Cypress against all liability.
*******************************************************************************/
/*******************************************************************************
* Header Files
*******************************************************************************/
#include "wiced_bt_stack.h"
#include "cybsp.h"
#include "cyhal.h"
#include "cy_retarget_io.h"
#include <FreeRTOS.h>
#include <task.h>
#include "cycfg_bt_settings.h"
#include "cts_server.h"
#include "cybsp_bt_config.h"
/*******************************************************************************
* Variable Definitions
*******************************************************************************/
/* This enables RTOS aware debugging. */
volatile int uxTopUsedPriority;
/* FreeRTOS task handle for button task. Button task is used to start
* advertisment or enable/disable notification from peer */
TaskHandle_t button_task_handle;
/******************************************************************************
* Function Definitions
******************************************************************************/
/*
* Entry point to the application. Set device configuration and start BT
* stack initialization. The actual application initialization will happen
* when stack reports that BT device is ready.
*/
int main()
{
cy_rslt_t rslt;
wiced_result_t result;
BaseType_t rtos_result;
/* This enables RTOS aware debugging in OpenOCD. */
uxTopUsedPriority = configMAX_PRIORITIES - 1;
/* Initialize the board support package */
rslt = cybsp_init();
if (CY_RSLT_SUCCESS != rslt)
{
CY_ASSERT(0);
}
/* Enable global interrupts */
__enable_irq();
/* Initialize retarget-io to use the debug UART port */
cy_retarget_io_init(CYBSP_DEBUG_UART_TX, CYBSP_DEBUG_UART_RX,
CY_RETARGET_IO_BAUDRATE);
printf("**********************AnyCloud Example*************************\n");
printf("**** Current Time Service (CTS) - Server Application Start ****\n");
printf("***************************************************************\n\n");
/* Configure platform specific settings for the BT device */
cybt_platform_config_init(&cybsp_bt_platform_cfg);
/* Register call back and configuration with stack */
result = wiced_bt_stack_init(app_bt_management_callback,
&wiced_bt_cfg_settings);
/* Check if stack initialization was successful */
if( WICED_BT_SUCCESS == result)
{
printf("Bluetooth Stack Initialization Successful \n");
}
else
{
printf("Bluetooth Stack Initialization failed!! \n");
CY_ASSERT(0);
}
/* Create Button Task for processing button presses */
rtos_result = xTaskCreate(button_task,"button_task", BUTTON_TASK_STACK_SIZE,
NULL, BUTTON_TASK_PRIORITY, &button_task_handle);
if( pdPASS != rtos_result)
{
printf("Failed to create Button task! \n");
CY_ASSERT(0);
}
/* Start the FreeRTOS scheduler */
vTaskStartScheduler();
/* The application should never reach here */
CY_ASSERT(0) ;
}
/* [] END OF FILE */