mbed-os/targets/TARGET_Cypress/TARGET_PSOC6/pinmap.c

70 lines
2.2 KiB
C
Raw Normal View History

/*
* mbed Microcontroller Library
* Copyright (c) 2017-2018 Future Electronics
Added support for PSA target to WIFI_BT board Added WiFi_Bt CM4 PSA target in mbedos json Added SPE-NSPE mailbox initialization for CM4 SystemInit Made similar to FUTURE_SEQUANA configurations Copied FUTURE_SEQUANA CM0 SPM part for WiFi_Bt smoke test Added CY8CKIT_062_WIFI_BT_M0 and CY8CKIT_062_WIFI_BT_M0_PSA targets Sorted files for new CY8CKIT_062_WIFI_BT_M0 and CY8CKIT_062_WIFI_BT_M0_PSA targets Copied files for CY8CKIT_062_WIFI_BT_M0_PSA from FUTURE_SEQUANA Copied and updated cm0p start files Corrected according to FUTURE_SEQUANA Changes to M0 startup files to have SPM started Fixed implicit declaration warning Commented interrupts enabling according to FUTURE_SEQUANA flow Updated prebuild spm_smore CM0 hex for CM4 target Turned on greentea environment Used special memory region for common CM0/CM4 data Updated prebuild CM0 SPM hex Placed shared memory region for flash operations into SPM shared memory region Updated cyprotection code and configuration Start address of protected regions is set by a defined number from target.json Added masters pcMask configuration Added support for PSA target to WIFI_BT board Enabled resources protection for SPM Aligned RAM usage according to Cypress FlashBoot and CyBootloader alligned protection config Added CYW943012P6EVB_01_M0 target Enlarged heap size, remobed nv_seed Added heap reservation in linker script from mbed-os Removed heap size definition turned on nv_seed config Removed nv_seed macros Enabled protection for PSoC6 CM0 Added PSoC6 CM0 PSA readme Enabled mbed_hal-spm test Enabled nv_seed and removed unneeded ipc config define Added SPDX string to feature_ble cypress target files Removed unneeded supported_toolchains lines for Cypress targets Disabled protection settings Corrected flash initialization for PSoC6 CM0 PSA Changed PSoC6 IPC6 protection for flash Enabled special flash initialization and enabled protection settings Updated and added new prebuild PSoC6 CM0 PSA hex files Disabled HW TRNG and CRC for PSoC6 CM4 PSA target Added missing const to allow types to match Updated PSoC6 WIFI_BT_PSA prebuilt directory Moved PSoC6 shared section usage area definition to begin of ld Added initial ARM_STD linker and startup files for PSoC6 CM0 Added initial IAR linker and startup files for PSoC6 CM0 Added defines to disable some SPM protection settings for PSoC64 Moved Flash function variables into separate memory region Added defines for new Public area definition Updated PSoC6 CM0_PSA hex-files
2019-02-23 20:33:07 +00:00
* Copyright (c) 2018-2019 Cypress Semiconductor Corporation
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "mbed_assert.h"
#include "pinmap.h"
#include "mbed_error.h"
#include "cy_gpio.h"
#include "psoc6_utils.h"
void pin_function(PinName pin, int function)
{
if (pin != NC) {
GPIO_PRT_Type *port = Cy_GPIO_PortToAddr(CY_PORT(pin));
uint32_t mode = gpio_get_cy_drive_mode(CY_PIN_DIRECTION(function), CY_PIN_MODE(function));
Cy_GPIO_Pin_FastInit(port, CY_PIN(pin), mode, 1, CY_PIN_HSIOM(function));
// Force output to enable pulls.
switch (mode) {
case CY_GPIO_DM_PULLUP:
Cy_GPIO_Write(port, CY_PIN(pin), 1);
break;
case CY_GPIO_DM_PULLDOWN:
Cy_GPIO_Write(port, CY_PIN(pin), 0);
break;
default:
/* do nothing */
break;
}
}
}
void pin_mode(PinName pin, PinMode mode)
{
if (pin != NC) {
uint32_t cymode = gpio_get_cy_drive_mode(PIN_INPUT, mode);
GPIO_PRT_Type *port = Cy_GPIO_PortToAddr(CY_PORT(pin));
Cy_GPIO_SetDrivemode(port, CY_PIN(pin), cymode);
// Force output to enable pulls.
switch (cymode) {
case CY_GPIO_DM_PULLUP:
Cy_GPIO_Write(port, CY_PIN(pin), 1);
break;
case CY_GPIO_DM_PULLDOWN:
Cy_GPIO_Write(port, CY_PIN(pin), 0);
break;
default:
/* do nothing */
break;
}
}
}