Skip to content

Commit d4b7ca6

Browse files
committed
hw/mcu/da1469x: Add UART driver
Driver that shuts down UART when RX line goes low to minimize power consumption.
1 parent c3991db commit d4b7ca6

File tree

4 files changed

+686
-0
lines changed

4 files changed

+686
-0
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
#ifndef __DRIVERS_UART_DA1469X_H_
21+
#define __DRIVERS_UART_DA1469X_H_
22+
23+
#include "uart/uart.h"
24+
#include "mcu/da1469x_hal.h"
25+
26+
#ifdef __cplusplus
27+
extern "C" {
28+
#endif
29+
30+
struct da1469x_uart_hw_data;
31+
32+
struct da1469x_uart_dev {
33+
struct uart_dev dev;
34+
/* Common UART parameters. */
35+
struct uart_conf uc;
36+
/* DA1469x specific configuration. */
37+
struct da1469x_uart_cfg da1469x_cfg;
38+
39+
/* driver state data */
40+
uint8_t active : 1;
41+
uint8_t tx_started : 1;
42+
uint8_t rx_started : 1;
43+
uint8_t rx_stalled : 1;
44+
uint8_t rx_data;
45+
46+
/* Callout used to re-enable UART after it RX pin went high. */
47+
struct os_callout wakeup_callout;
48+
/* Event raised from interrupt (busy/break) that will setup RX pin to GPIO with interrupt in task context. */
49+
struct os_event setup_wakeup_event;
50+
/* Hardware configuration, register addresses bit mask and such. */
51+
const struct da1469x_uart_hw_data *hw;
52+
};
53+
54+
/**
55+
* Creates UART OS device
56+
*
57+
* @param dev - device structure to initialize
58+
* @param name - device name (must end with character 0|1|2 like "uart0")
59+
* @param priority - priority for os_dev_create
60+
* @param da1469x_cfg - UART parameters
61+
* @return 0 on success,
62+
*/
63+
int da1469x_uart_dev_create(struct da1469x_uart_dev *dev, const char *name, uint8_t priority,
64+
const struct da1469x_uart_cfg *da1469x_cfg);
65+
66+
#ifdef __cplusplus
67+
}
68+
#endif
69+
70+
#endif /* __DRIVERS_UART_DA1469X_H_ */
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
#
19+
20+
pkg.name: hw/drivers/uart/uart_da1469x
21+
pkg.description: UART driver for DA1469X
22+
pkg.author: "Apache Mynewt <[email protected]>"
23+
pkg.homepage: "http://mynewt.apache.org/"
24+
pkg.keywords:
25+
pkg.apis:
26+
pkg.deps:
27+
- "@apache-mynewt-core/hw/hal"
28+
- "@apache-mynewt-core/hw/drivers/uart"

0 commit comments

Comments
 (0)