Skip to content

Commit

Permalink
Merge pull request ARMmbed#33 from yennster/port-api
Browse files Browse the repository at this point in the history
Add Port API stubs
  • Loading branch information
Jenny Plunkett authored Jul 20, 2018
2 parents 0f22162 + c3b9df1 commit 9264463
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 15 deletions.
5 changes: 4 additions & 1 deletion targets/TARGET_TI/TARGET_CC32XX/TARGET_CC3220SF/PortNames.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ extern "C" {

typedef enum {
Port0 = 0,
Port1 = 1
Port1 = 1,
Port2 = 2,
Port3 = 3,
Port4 = 4
} PortName;

#ifdef __cplusplus
Expand Down
63 changes: 63 additions & 0 deletions targets/TARGET_TI/TARGET_CC32XX/TARGET_CC3220SF/device/CC3220SF.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,57 @@ typedef struct
} CC3220SF_UART_TypeDef;


/* =========================================================================================================================== */
/* ================ GPIO ================ */
/* =========================================================================================================================== */


/**
* @brief GPIO
*/
typedef struct
{
__IO uint32_t DATA; /*!< Address offset : 0x00000000 */
uint32_t RESERVED0[32];
__IO uint32_t DIR; /*!< Address offset : 0x00000400 */
__IO uint32_t IS; /*!< Address offset : 0x00000404 */
__IO uint32_t IBE; /*!< Address offset : 0x00000408 */
__IO uint32_t IEV; /*!< Address offset : 0x0000040C */
__IO uint32_t IM; /*!< Address offset : 0x00000410 */
__IO uint32_t RIS; /*!< Address offset : 0x00000414 */
__IO uint32_t MIS; /*!< Address offset : 0x00000418 */
__O uint32_t ICR; /*!< Address offset : 0x0000041C */
__IO uint32_t AFSEL; /*!< Address offset : 0x00000420 */
uint32_t RESERVED1[7];
__IO uint32_t DR2R; /*!< Address offset : 0x00000500 */
__IO uint32_t DR4R; /*!< Address offset : 0x00000504 */
__IO uint32_t DR8R; /*!< Address offset : 0x00000508 */
__IO uint32_t ODR; /*!< Address offset : 0x0000050C */
__IO uint32_t PUR; /*!< Address offset : 0x00000510 */
__IO uint32_t PDR; /*!< Address offset : 0x00000514 */
__IO uint32_t SLR; /*!< Address offset : 0x00000518 */
__IO uint32_t DEN; /*!< Address offset : 0x0000051C */
__IO uint32_t LOCK; /*!< Address offset : 0x00000520 */
__IO uint32_t CR; /*!< Address offset : 0x00000524 */
__IO uint32_t AMSEL; /*!< Address offset : 0x00000528 */
__IO uint32_t PCTL; /*!< Address offset : 0x0000052C */
__IO uint32_t ADCCTL; /*!< Address offset : 0x00000530 */
__IO uint32_t DMACTL; /*!< Address offset : 0x00000534 */
__IO uint32_t SI; /*!< Address offset : 0x00000538 */
uint8_t RESERVED2[339];
__IO uint32_t PERIPHID4; /*!< Address offset : 0x00000FD0 */
__IO uint32_t PERIPHID5; /*!< Address offset : 0x00000FD4 */
__IO uint32_t PERIPHID6; /*!< Address offset : 0x00000FD8 */
__IO uint32_t PERIPHID7; /*!< Address offset : 0x00000FDC */
__IO uint32_t PERIPHID0; /*!< Address offset : 0x00000FE0 */
__IO uint32_t PERIPHID1; /*!< Address offset : 0x00000FE4 */
__IO uint32_t PERIPHID2; /*!< Address offset : 0x00000FE8 */
__IO uint32_t PERIPHID3; /*!< Address offset : 0x00000FEC */
__IO uint32_t PCELLID0; /*!< Address offset : 0x00000FF0 */
__IO uint32_t PCELLID1; /*!< Address offset : 0x00000FF4 */
__IO uint32_t PCELLID2; /*!< Address offset : 0x00000FF8 */
__IO uint32_t PCELLID3; /*!< Address offset : 0x00000FFC */
} CC3220SF_GPIO_TypeDef;

/* =========================================================================================================================== */
/* ================ Device Specific Peripheral Address Map ================ */
Expand Down Expand Up @@ -253,6 +304,18 @@ typedef struct
#define CC3220SF_UART0 ((CC3220SF_UART_TypeDef *) CC3220SF_UARTA0_BASE)
#define CC3220SF_UART1 ((CC3220SF_UART_TypeDef *) CC3220SF_UARTA1_BASE)

/******************************************************************************/
/* */
/* GPIO */
/* */
/******************************************************************************/

#define CC3220SF_GPIO0 ((CC3220SF_GPIO_TypeDef *) CC3220SF_GPIOA0_BASE)
#define CC3220SF_GPIO1 ((CC3220SF_GPIO_TypeDef *) CC3220SF_GPIOA1_BASE)
#define CC3220SF_GPIO2 ((CC3220SF_GPIO_TypeDef *) CC3220SF_GPIOA2_BASE)
#define CC3220SF_GPIO3 ((CC3220SF_GPIO_TypeDef *) CC3220SF_GPIOA3_BASE)
#define CC3220SF_GPIO4 ((CC3220SF_GPIO_TypeDef *) CC3220SF_GPIOA4_BASE)

/**
* @}
*/
Expand Down
15 changes: 8 additions & 7 deletions targets/TARGET_TI/TARGET_CC32XX/TARGET_CC3220SF/objects.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ extern "C" {
#endif

typedef struct {
// TODO ! this is just a placeholder!
unsigned long gpio_port_base_addr;
PinName pin;
PinMode mode;
Expand All @@ -40,19 +39,21 @@ struct serial_s {
uint32_t baudRate; /*!< Baud rate for UART */
unsigned int baseAddr; /*! UART Peripheral's base address */
unsigned int intNum; /*! UART Peripheral's interrupt vector */
unsigned int intPriority; /*! UART Peripheral's interrupt priority */
uint32_t flowControl; /*! Hardware flow control setting defined by driverlib */
PinName rxPin; /*! UART RX pin assignment */
PinName txPin; /*! UART TX pin assignment */
PinName ctsPin; /*! UART clear to send (CTS) pin assignment */
PinName rtsPin; /*! UART request to send (RTS) pin assignment */
unsigned int powerMgrId; /* Determined from base address */
unsigned long peripheralId; /* Value that can be passed to PRCM functions */
UART_LEN dataLength; /* Data length for UART */
UART_STOP stopBits; /* Stop bits for UART */
UART_PAR parityType; /* Parity bit type for UART */
};

struct port_s {
__IO uint32_t *reg_dir;
__IO uint32_t *reg_out;
__I uint32_t *reg_in;
PortName port;
uint32_t mask;
};

#ifdef __cplusplus
}
#endif
Expand Down
42 changes: 42 additions & 0 deletions targets/TARGET_TI/TARGET_CC32XX/TARGET_CC3220SF/port_api.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/* mbed Microcontroller Library
* Copyright (c) 2006-2018 ARM Limited
*
* 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 "port_api.h"
#include "pinmap.h"
#include "gpio_api.h"

PinName port_pin(PortName port, int pin_n) {
// TODO
}

void port_init(port_t *obj, PortName port, int mask, PinDirection dir) {
// TODO
}

void port_mode(port_t *obj, PinMode mode) {
// TODO
}

void port_dir(port_t *obj, PinDirection dir) {
// TODO
}

void port_write(port_t *obj, int value) {
// TODO
}

int port_read(port_t *obj) {
// TODO
}
6 changes: 0 additions & 6 deletions targets/TARGET_TI/TARGET_CC32XX/TARGET_CC3220SF/serial_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,6 @@ void serial_init(serial_t *obj, PinName tx, PinName rx)
obj->uart = (CC3220SF_UART_TypeDef *)uart;

// Set default values for UART
obj->intPriority = (~0);
obj->flowControl = FlowControlNone;
obj->rxPin = rx;
obj->txPin = tx;
obj->ctsPin = NC;
obj->rtsPin = NC;
obj->dataLength = UART_LEN_8;
obj->stopBits = UART_STOP_ONE;
obj->parityType = UART_PAR_NONE;
Expand Down
2 changes: 1 addition & 1 deletion targets/targets.json
Original file line number Diff line number Diff line change
Expand Up @@ -4214,7 +4214,7 @@
},
"CC3220SF": {
"inherits": ["CC32XX"],
"device_has": ["USTICKER", "LPTICKER", "SERIAL", "SERIAL_FC"],
"device_has": ["USTICKER", "LPTICKER", "SERIAL", "SERIAL_FC", "PORTIN", "PORTINOUT", "PORTOUT"],
"core": "Cortex-M4"
}
}

0 comments on commit 9264463

Please sign in to comment.