Skip to content

Commit 83298d8

Browse files
author
Andrew Boie
committed
Revert "misc: Remove generic PRINT macros from flash samples"
This reverts commit a641204. Change-Id: I190d418103bfdd3d6714d1ac063cc1e533ce60ad Signed-off-by: Andrew Boie <[email protected]>
1 parent 4bcefbb commit 83298d8

File tree

4 files changed

+54
-52
lines changed

4 files changed

+54
-52
lines changed
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
CONFIG_STDOUT_CONSOLE=y
22
CONFIG_FLASH=y
33
CONFIG_SOC_FLASH_NRF5=y
4-
CONFIG_SYS_LOG=y

samples/drivers/soc_flash_nrf5/src/main.c

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,13 @@
1818
#include <zephyr.h>
1919
#include <flash.h>
2020
#include <device.h>
21-
22-
#define SYS_LOG_LEVEL SYS_LOG_LEVEL_INFO
23-
#include <misc/sys_log.h>
21+
#if defined(CONFIG_STDOUT_CONSOLE)
22+
#include <stdio.h>
23+
#define PRINT printf
24+
#else
25+
#include <misc/printk.h>
26+
#define PRINT printk
27+
#endif
2428

2529
/* Offset between pages */
2630
#define FLASH_TEST_OFFSET 0x40000
@@ -41,83 +45,79 @@ void main(void)
4145
uint32_t buf_word = 0;
4246
uint32_t i, offset;
4347

44-
SYS_LOG_INF("\nNordic nRF5 Flash Testing");
45-
SYS_LOG_INF("=========================");
48+
PRINT("\nNordic nRF5 Flash Testing\n");
49+
PRINT("=========================\n");
4650

4751
flash_dev = device_get_binding("NRF5_FLASH");
4852

4953
if (!flash_dev) {
50-
SYS_LOG_ERR("Nordic nRF5 flash driver was not found!");
54+
PRINT("Nordic nRF5 flash driver was not found!\n");
5155
return;
5256
}
5357

54-
SYS_LOG_INF("\nTest 1: Flash erase page at 0x%x", FLASH_TEST_OFFSET);
58+
PRINT("\nTest 1: Flash erase page at 0x%x\n", FLASH_TEST_OFFSET);
5559
if (flash_erase(flash_dev, FLASH_TEST_OFFSET, FLASH_PAGE_SIZE) != 0) {
56-
SYS_LOG_INF(" Flash erase failed!");
60+
PRINT(" Flash erase failed!\n");
5761
} else {
58-
SYS_LOG_INF(" Flash erase succeeded!");
62+
PRINT(" Flash erase succeeded!\n");
5963
}
6064

61-
SYS_LOG_INF("\nTest 2: Flash write (word array 1)");
65+
PRINT("\nTest 2: Flash write (word array 1)\n");
6266
flash_write_protection_set(flash_dev, false);
6367
for (i = 0; i < TEST_DATA_LEN; i++) {
6468
offset = FLASH_TEST_OFFSET + (i << 2);
65-
SYS_LOG_INF(" Attempted to write %x at 0x%x",
66-
buf_array_1[i], offset);
69+
PRINT(" Attempted to write %x at 0x%x\n", buf_array_1[i],
70+
offset);
6771
if (flash_write(flash_dev, offset, &buf_array_1[i],
6872
TEST_DATA_LEN) != 0) {
69-
SYS_LOG_INF(" Flash write failed!");
73+
PRINT(" Flash write failed!\n");
7074
return;
7175
}
72-
SYS_LOG_INF(" Attempted to read 0x%x", offset);
76+
PRINT(" Attempted to read 0x%x\n", offset);
7377
if (flash_read(flash_dev, offset, &buf_word,
7478
TEST_DATA_LEN) != 0) {
75-
SYS_LOG_INF(" Flash read failed!");
79+
PRINT(" Flash read failed!\n");
7680
return;
7781
}
78-
SYS_LOG_INF(" Data read: %x", buf_word);
82+
PRINT(" Data read: %x\n", buf_word);
7983
if (buf_array_1[i] == buf_word) {
80-
SYS_LOG_INF(" Data read matches data written. "
81-
"Good!");
84+
PRINT(" Data read matches data written. Good!\n");
8285
} else {
83-
SYS_LOG_INF(" Data read does not match data "
84-
"written!");
86+
PRINT(" Data read does not match data written!\n");
8587
}
8688
}
8789
flash_write_protection_set(flash_dev, true);
8890

8991
offset = FLASH_TEST_OFFSET - FLASH_PAGE_SIZE * 2;
90-
SYS_LOG_INF("\nTest 3: Flash erase (4 pages at 0x%x)", offset);
92+
PRINT("\nTest 3: Flash erase (4 pages at 0x%x)\n", offset);
9193
if (flash_erase(flash_dev, offset, FLASH_PAGE_SIZE * 4) != 0) {
92-
SYS_LOG_INF(" Flash erase failed!");
94+
PRINT(" Flash erase failed!\n");
9395
} else {
94-
SYS_LOG_INF(" Flash erase succeeded!");
96+
PRINT(" Flash erase succeeded!\n");
9597
}
9698

97-
SYS_LOG_INF("\nTest 4: Flash write (word array 2)");
99+
PRINT("\nTest 4: Flash write (word array 2)\n");
98100
flash_write_protection_set(flash_dev, false);
99101
for (i = 0; i < TEST_DATA_LEN; i++) {
100102
offset = FLASH_TEST_OFFSET + (i << 2);
101-
SYS_LOG_INF(" Attempted to write %x at 0x%x",
102-
buf_array_2[i], offset);
103+
PRINT(" Attempted to write %x at 0x%x\n", buf_array_2[i],
104+
offset);
103105
if (flash_write(flash_dev, offset, &buf_array_2[i],
104106
TEST_DATA_LEN) != 0) {
105-
SYS_LOG_INF(" Flash write failed!");
107+
PRINT(" Flash write failed!\n");
106108
return;
107109
}
108-
SYS_LOG_INF(" Attempted to read 0x%x", offset);
110+
PRINT(" Attempted to read 0x%x\n", offset);
109111
if (flash_read(flash_dev, offset, &buf_word,
110112
TEST_DATA_LEN) != 0) {
111-
SYS_LOG_INF(" Flash read failed!");
113+
PRINT(" Flash read failed!\n");
112114
return;
113115
}
114-
SYS_LOG_INF(" Data read: %x", buf_word);
116+
PRINT(" Data read: %x\n", buf_word);
115117
if (buf_array_2[i] == buf_word) {
116-
SYS_LOG_INF(" Data read matches data written. "
117-
"Good!");
118+
PRINT(" Data read matches data written. Good!\n");
118119
} else {
119-
SYS_LOG_INF(" Data read does not match data "
120-
"written!");
120+
PRINT(" Data read does not match data written!\n");
121121
}
122122
}
123123
flash_write_protection_set(flash_dev, true);

samples/drivers/spi_flash/prj.conf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,3 @@ CONFIG_SPI=y
44
CONFIG_GPIO=y
55
CONFIG_SPI_CS_GPIO=y
66
CONFIG_SPI_0_CS_GPIO_PIN=24
7-
CONFIG_SYS_LOG=y

samples/drivers/spi_flash/src/main.c

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,13 @@
1717
#include <zephyr.h>
1818
#include <flash.h>
1919
#include <device.h>
20-
#define SYS_LOG_LEVEL SYS_LOG_LEVEL_INFO
21-
#include <misc/sys_log.h>
20+
#if defined(CONFIG_STDOUT_CONSOLE)
21+
#include <stdio.h>
22+
#define PRINT printf
23+
#else
24+
#include <misc/printk.h>
25+
#define PRINT printk
26+
#endif
2227

2328
#define FLASH_TEST_REGION_OFFSET 0xff000
2429
#define FLASH_SECTOR_SIZE 4096
@@ -31,13 +36,13 @@ void main(void)
3136
struct device *flash_dev;
3237
uint8_t buf[TEST_DATA_LEN];
3338

34-
SYS_LOG_INF("\nW25QXXDV SPI flash testing");
35-
SYS_LOG_INF("==========================");
39+
PRINT("\nW25QXXDV SPI flash testing\n");
40+
PRINT("==========================\n");
3641

3742
flash_dev = device_get_binding("W25QXXDV");
3843

3944
if (!flash_dev) {
40-
SYS_LOG_ERR("SPI flash driver was not found!");
45+
PRINT("SPI flash driver was not found!\n");
4146
return;
4247
}
4348

@@ -46,39 +51,38 @@ void main(void)
4651
* on write protection automatically after completion of write and
4752
* erase operations.
4853
*/
49-
SYS_LOG_INF("\nTest 1: Flash erase");
54+
PRINT("\nTest 1: Flash erase\n");
5055
flash_write_protection_set(flash_dev, false);
5156
if (flash_erase(flash_dev,
5257
FLASH_TEST_REGION_OFFSET,
5358
FLASH_SECTOR_SIZE) != 0) {
54-
SYS_LOG_INF(" Flash erase failed!");
59+
PRINT(" Flash erase failed!\n");
5560
} else {
56-
SYS_LOG_INF(" Flash erase succeeded!");
61+
PRINT(" Flash erase succeeded!\n");
5762
}
5863

59-
SYS_LOG_INF("\nTest 2: Flash write");
64+
PRINT("\nTest 2: Flash write\n");
6065
flash_write_protection_set(flash_dev, false);
6166

6267
buf[0] = TEST_DATA_BYTE_0;
6368
buf[1] = TEST_DATA_BYTE_1;
64-
SYS_LOG_INF(" Attempted to write %x %x", buf[0], buf[1]);
69+
PRINT(" Attempted to write %x %x\n", buf[0], buf[1]);
6570
if (flash_write(flash_dev, FLASH_TEST_REGION_OFFSET, buf,
6671
TEST_DATA_LEN) != 0) {
67-
SYS_LOG_INF(" Flash write failed!");
72+
PRINT(" Flash write failed!\n");
6873
return;
6974
}
7075

7176
if (flash_read(flash_dev, FLASH_TEST_REGION_OFFSET, buf,
7277
TEST_DATA_LEN) != 0) {
73-
SYS_LOG_INF(" Flash read failed!");
78+
PRINT(" Flash read failed!\n");
7479
return;
7580
}
76-
SYS_LOG_INF(" Data read %x %x", buf[0], buf[1]);
81+
PRINT(" Data read %x %x\n", buf[0], buf[1]);
7782

7883
if ((buf[0] == TEST_DATA_BYTE_0) && (buf[1] == TEST_DATA_BYTE_1)) {
79-
SYS_LOG_INF(" Data read matches with data written. Good!!");
84+
PRINT(" Data read matches with data written. Good!!\n");
8085
} else {
81-
SYS_LOG_INF(" Data read does not match with data "
82-
"written!!");
86+
PRINT(" Data read does not match with data written!!\n");
8387
}
8488
}

0 commit comments

Comments
 (0)