88#include <zephyr/pm/device_runtime.h>
99#include <zephyr/kernel.h>
1010#include <zephyr/logging/log.h>
11+ #include <zephyr/pm/device.h>
12+ #include <zephyr/pm/device_runtime.h>
13+ #include <nrfs_backend_ipc_service.h>
14+ #include <nrfs_gdpwr.h>
1115
1216/* Note: logging is normally disabled for this test
1317 * Enable only for debugging purposes
@@ -31,6 +35,53 @@ const uint8_t test_pattern[TEST_BUFFER_LEN] = {0x11, 0x12, 0x13, 0x14, 0x15,
3135static uint8_t test_buffer [TEST_BUFFER_LEN ];
3236static volatile uint8_t uart_error_counter ;
3337
38+ /* Required to power off the GD2 and GD3 domains
39+ * Will be removed when GD handling
40+ * is implemented in sdk-zephyr
41+ */
42+ static void gdpwr_handler (nrfs_gdpwr_evt_t const * p_evt , void * context )
43+ {
44+ switch (p_evt -> type ) {
45+ case NRFS_GDPWR_REQ_APPLIED :
46+ printk ("GDPWR handler - response received: 0x%x, CTX=%d\n" , p_evt -> type ,
47+ (uint32_t )context );
48+ break ;
49+ case NRFS_GDPWR_REQ_REJECTED :
50+ printk ("GDPWR handler - request rejected: 0x%x, CTX=%d\n" , p_evt -> type ,
51+ (uint32_t )context );
52+ break ;
53+ default :
54+ printk ("GDPWR handler - unexpected event: 0x%x, CTX=%d\n" , p_evt -> type ,
55+ (uint32_t )context );
56+ break ;
57+ }
58+ }
59+
60+ /* Required to power off the GD2 and GD3 domains
61+ * Will be removed when GD handling
62+ * is implemented in sdk-zephyr
63+ */
64+ static void clear_global_power_domains_requests (void )
65+ {
66+ int service_status ;
67+ int tst_ctx = 1 ;
68+
69+ service_status = nrfs_gdpwr_init (gdpwr_handler );
70+ printk ("Response: %d\n" , service_status );
71+ printk ("Sending GDPWR DISABLE request for: GDPWR_POWER_DOMAIN_ACTIVE_SLOW\n" );
72+ service_status = nrfs_gdpwr_power_request (GDPWR_POWER_DOMAIN_ACTIVE_SLOW ,
73+ GDPWR_POWER_REQUEST_CLEAR , (void * )tst_ctx ++ );
74+ printk ("Response: %d\n" , service_status );
75+ printk ("Sending GDPWR DISABLE request for: GDPWR_POWER_DOMAIN_ACTIVE_FAST\n" );
76+ service_status = nrfs_gdpwr_power_request (GDPWR_POWER_DOMAIN_ACTIVE_FAST ,
77+ GDPWR_POWER_REQUEST_CLEAR , (void * )tst_ctx ++ );
78+ printk ("Response: %d\n" , service_status );
79+ printk ("Sending GDPWR DISABLE request for: GDPWR_POWER_DOMAIN_MAIN_SLOW\n" );
80+ service_status = nrfs_gdpwr_power_request (GDPWR_POWER_DOMAIN_MAIN_SLOW ,
81+ GDPWR_POWER_REQUEST_CLEAR , (void * )tst_ctx );
82+ printk ("Response: %d\n" , service_status );
83+ }
84+
3485/*
3586 * Callback function for UART async transmission
3687 */
@@ -53,6 +104,7 @@ static void async_uart_callback(const struct device *dev, struct uart_event *evt
53104 printk ("Recieived data byte %d does not match pattern 0x%x != "
54105 "0x%x\n" ,
55106 index , test_buffer [index ], test_pattern [index ]);
107+ __ASSERT_NO_MSG (test_buffer [index ] == test_pattern [index ]);
56108 }
57109 }
58110 break ;
@@ -79,6 +131,13 @@ int main(void)
79131 .data_bits = UART_CFG_DATA_BITS_8 ,
80132 .flow_ctrl = UART_CFG_FLOW_CTRL_RTS_CTS };
81133
134+ printk ("Hello World! %s\n" , CONFIG_BOARD_TARGET );
135+ printk ("UART instance: %s\n" , uart_dev -> name );
136+
137+ nrfs_backend_wait_for_connection (K_FOREVER );
138+ clear_global_power_domains_requests ();
139+ k_msleep (250 );
140+
82141 err = uart_configure (uart_dev , & test_uart_config );
83142 if (err != 0 ) {
84143 printk ("Unexpected error when configuring UART: %d\n" , err );
0 commit comments