Skip to content

cpu/cc26x0: add rudimentary interface to support radio core#5496

Closed
yogo1212 wants to merge 50 commits intoRIOT-OS:masterfrom
yogo1212:cc26x0_rfc
Closed

cpu/cc26x0: add rudimentary interface to support radio core#5496
yogo1212 wants to merge 50 commits intoRIOT-OS:masterfrom
yogo1212:cc26x0_rfc

Conversation

@yogo1212
Copy link
Copy Markdown
Contributor

@yogo1212 yogo1212 commented Jun 2, 2016

props to @fvcoen for finding ways to deal with the 'irregularities' of the hardware 👍

i think this should be merged even though no working code is using it.
this should still allow other developers to participate.

@PeterKietzmann PeterKietzmann added Platform: ARM Platform: This PR/issue effects ARM-based platforms Area: drivers Area: Device drivers Type: new feature The issue requests / The PR implemements a new feature for RIOT labels Jun 3, 2016
@PeterKietzmann
Copy link
Copy Markdown
Member

@A-Paul I know this is a big one, but do you mind to be assignee? If yes, feel free to reassign -as usual...

@emmanuelsearch
Copy link
Copy Markdown
Member

@yogo1212 what do you mean exactly by "no working code is using it"?
Do you mean that there is no code/example to test it?
But there seems to be an example?

@yogo1212
Copy link
Copy Markdown
Contributor Author

yogo1212 commented Jun 3, 2016

@emmanuelsearch the example doesn't work :-D
well, the initialisation works but no beacon is being broadcasted :-(
that might happen in the next week or so, though; sometimes you insert a seemingly random printf and... puff - it works ;-)

pingCommand.commandID = CMDR_CMDID_PING;
RFC_DBELL->CMDR = (uint32_t) (&pingCommand);
while (!RFC_DBELL->CMDSTA); /* wait for cmd execution */
printf("rfc_ping fails without a printf reading cmdsta %lu\n", RFC_DBELL->CMDSTA);
Copy link
Copy Markdown
Contributor Author

@yogo1212 yogo1212 Jun 3, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note that the mere presence of this line affects the evaluation in the interrupt which happens BEFORE this printf is reached oO
can't wait to see if anyone finds the reason

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if it's related, but I observed print statements in isr
functions (at leat I interpret functions starting with isr_ as such).
AFAIK printing in interrupt routines is never a good idea. If you need some
sort of signaling and the interrupts occur only sparsely then you can
toggle a led or use another variable to somehow mark that an interrupt was
thrown and do the printing in normal execution
Am 03.06.2016 10:39 schrieb "Leon George" [email protected]:

In cpu/cc26x0/periph/rfc.c
#5496 (comment):

@@ -131,6 +131,7 @@ bool rfc_ping_test(void)
pingCommand.commandID = CMDR_CMDID_PING;
RFC_DBELL->CMDR = (uint32_t) (&pingCommand);
while (!RFC_DBELL->CMDSTA); /* wait for cmd execution */

  • printf("rfc_ping fails without a printf reading cmdsta %lu\n", RFC_DBELL->CMDSTA);

note that the mere presence of this line affects the evaluation in the
interrupt which happens before the printf is reached oO
can't wait to see if anyone finds the reason


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/RIOT-OS/RIOT/pull/5496/files/32f992e5f89b3701bfa6c3de99e0ed2bd6b8e0f6..7bf8ed592f43a05a2d87ef83286c3950b8db726a#r65674010,
or mute the thread
https://github.com/notifications/unsubscribe/AAtHOREcFUflfXwoyi72dPtfYc7XbK9Fks5qH-hXgaJpZM4Isg30
.

@fvcoen
Copy link
Copy Markdown

fvcoen commented Jun 3, 2016

@yogo1212 @emmanuelsearch I'm currently working on fully implementing the advertising functionality, however both the TI doc and the BLE sepcs are rather poorly written, so it's not as straightforward as it could be... I'm also writing a "guide" on BLE advertising with the CC2650, as I make my way trough the doc: I will make it available on the wiki of the board when things are in an acceptable state.


#define RFC_DBELL ((cc26x0_rfc_dbell_regs_t *)(RFC_DBELL_BASE))

#define CMDR_TYPE_mask 0x3
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why no all caps?

@A-Paul
Copy link
Copy Markdown
Member

A-Paul commented Jun 15, 2016

@yogo1212, I'm going to look deeper into your code tomorrow (hopefully).

As a first step I ask you to enclose the macro literals into braces. Also there are several decimal numbers mixed in sequences of hex numbers. Would be helpful to make this more consistent.

@A-Paul
Copy link
Copy Markdown
Member

A-Paul commented Jun 15, 2016

well, the initialisation works but no beacon is being broadcasted :-(
that might happen in the next week or so, though; sometimes you insert a seemingly random printf and... puff - it works ;-)

That is what I consider "Work in progress"?

@yogo1212
Copy link
Copy Markdown
Contributor Author

yogo1212 commented Jun 16, 2016

@A-Paul thank you for your time :-)
i'm not happy about the mixed lower-/upper-case either but there is a point to it.
_mask and _pos are no values that should be written to a register.
i thought i had seen someone do it that way in RIOT - right now i can only find _Msk and _Pos (https://github.com/RIOT-OS/RIOT/blob/master/cpu/sam3/include/sam3x8e/component/component_rtc.h#L81)
that is also the reason for the dec/hex..

@A-Paul A-Paul added the State: WIP State: The PR is still work-in-progress and its code is not in its final presentable form yet label Jun 17, 2016
@A-Paul
Copy link
Copy Markdown
Member

A-Paul commented Jun 17, 2016

@A-Paul thank you for your time :-)

You're welcome.

Your example file is -not the only- one created by a HW vendor. Look at the file header. We use them and and leave them as they are. In RIOT code, please use uppercase letters for constants.

that is also the reason for the dec/hex.

In file cpu/cc26x0/include/cc26x0_rfc.h:
line 254 #define SYSGPOCTL_GPOCTL0_pos 0x0
line 384 #define R_OP_STARTTRIG_TRIG_NO_pos 5

Even that exception is not strict. Seems that I'm not convinced.

@yogo1212
Copy link
Copy Markdown
Contributor Author

you are absolutely right on that.
shall i turn all the positions into hex or decimal?

@yogo1212
Copy link
Copy Markdown
Contributor Author

@fvcoen found a fault in the fcfg headers

    printf("&FCFG->MISC_CONF_1 %p\n", (void *) &FCFG->MISC_CONF_1);
    printf("&FCFG->MAC_BLE_0 %p\n", (void *) &FCFG->MAC_BLE_0);
    printf("&FCFG->MAC_15_4_0 %p\n", (void *) &FCFG->MAC_15_4_0);

->

2016-06-20 23:23:23,540 - INFO # &FCFG->MISC_CONF_1 0x500010a0
2016-06-20 23:23:23,543 - INFO # &FCFG->MAC_BLE_0 0x500012e4 <--- datasheet says 12e8
2016-06-20 23:23:23,545 - INFO # &FCFG->MAC_15_4_0 0x500012ec

fixing that

@yogo1212
Copy link
Copy Markdown
Contributor Author

@A-Paul Since you didn't reply (assuming you have just a few more PRs to merge), I turned the remaining *_POS macros into decimals.
It isn't important to be able to see which bit is where in a bit offset or a length; the value is - after all, most humans and many data sheets still use decimals to work with.
I, personally, would like meta information to stick out more between register values.

Regarding the braces: The RIOT coding guide doesn't seem to include that.
Why should straightforward integer constants be surrounded by braces?
I think it's pollution (for the eye and the environment).

Since we want to get this merged, you should just make ultimate decisions.
Do you want select macros to include braces or all of them?
I'm not able to deduce a pattern from the existing code base.

@A-Paul
Copy link
Copy Markdown
Member

A-Paul commented Jun 23, 2016

I, personally, would like meta information to stick out more between register values.

My intention was to get more consistent notation. If you want certain groups of defines to "stick out", there is also the option of reordering the blocks.

Do you want select macros to include braces or all of them?

I prefer to embrace all of them. :D
I's a best practice which is not bound to RIOT. And you're right, for now it's not consistent in existing codebase.
But, in general, having missed something in the past shouldn't prevent you from doing it better in the future. ;-)

@fvcoen
Copy link
Copy Markdown

fvcoen commented Jun 24, 2016

@yogo1212 as I mentioned here all " PRIu32 " format should be changed to " PRIx32 " in order to correctly display the error codes... I've been trying to understand the famous 0x130 for days now... in vain since it's actually 0x82! 😞

@fvcoen
Copy link
Copy Markdown

fvcoen commented Jun 30, 2016

@yogo1212 I solved the 0x82 mystery! We are actually missing something in the current radio setup. In the function void rfc_prepare(void), we should add the following lines after configuring the RFC power domain:

/* RFC MODE SELECTION */
    PRCM->RFCMODESEL = PRCM_RFCMODESEL_CURR_MODE5; /* CC2650 requires MODE5 - no doc available on RFCMODESEL*/

Did I mention that there is absolutely no documentation on teh RFCMODESEL register? I found out about it through this forum thread.
Based on the Contiki implementation, each MCU of the 26xx family required a specific value in RFCMODESEL: without it, it is impossible to use any of the non-general radio command (BLE, IEEE, proprietary related commands).

I thought it would make more sense if this config were included in this PR rather than a protocol-specific one.

@yogo1212
Copy link
Copy Markdown
Contributor Author

@fvcoen impressive!
you don't cease to amaze me 👍
commits going in your name

@benemorius
Copy link
Copy Markdown
Member

Is anyone currently working on this?

In addition to setting RFCMODESEL, I found that additional steps (undocumented, of course) were required (to get hf_xosc running) in order to get ble advertisements working. If this PR is going to be merged, I can submit a followup PR. I looked briefly to see if anyone had an active branch where this is still being worked on but I didn't find one.

The additional steps are too verbose to quote. There are some required trim values to set (hf_xosc won't start otherwise), and a rom function to call to actually switch to hf_xosc.

@yogo1212
Copy link
Copy Markdown
Contributor Author

yogo1212 commented Aug 16, 2016

@benemorius hi :-)
(broke my debug probe - gotta get a new one)
would you want to open a PR against this branch or rather wait for this to be merged first?
i don't know how long that will take.

what starts working after taking those steps you are talking about?

@yogo1212
Copy link
Copy Markdown
Contributor Author

just realised, why...
@A-Paul i forgot to ping you. shame on me :-(
is there something that still needs fixing?

@benemorius
Copy link
Copy Markdown
Member

would you want to open a PR against this branch or rather wait for this to be merged first?

I'll open a PR against your cc26x0_rfc branch if that's ok.

what starts working after taking those steps you are talking about?

Those steps get the microcontroller switched over to hf_xosc, which is required for the radio. (Actually, I suspect the radio may be working already, but you can't tell because hf_rcosc isn't accurate enough.) Then you need only add the code to send ble advertisements and the advertisements will work.

Here are the changes, including test code which sends advertisements. I'll either clean this up and then open a PR, or open a PR and then clean it up. I'm actually changing my focus to get 15.4 working now so I don't know how much further I'll go on this.

yogo1212/RIOT@cc26x0_rfc...benemorius:cc26x0_rfc_works

@yogo1212
Copy link
Copy Markdown
Contributor Author

yogo1212 commented Aug 29, 2016

@benemorius were there any additional steps you have taken to be able to receive beacons broadcasted by RIOT?
a lot of the stuff you added in your trim.h is already there elsewhere and there are places to add the stuff that isn't :-)

i've rearranged your changes in here: yogo1212#13.
if you object, please say so ;-)

@OlegHahm
Copy link
Copy Markdown
Member

What is the latest here?

@yogo1212
Copy link
Copy Markdown
Contributor Author

@OlegHahm is there a way that one of you could test https://github.com/benemorius/RIOT/tree/cc26x0_rfc_works?
i've checked with multiple probes/sensortags and haven't been able to receive beacons on any devices (i have a slightly cleaner version of that code here yogo1212#13).

just a five minute check whether that code works ;-)

@emmanuelsearch
Copy link
Copy Markdown
Member

emmanuelsearch commented Oct 20, 2016

@yogo1212 maybe you can ask @haukepetersen now that he is more or less back ;)

@smlng
Copy link
Copy Markdown
Member

smlng commented Oct 20, 2016

@yogo1212 I have several TI sensortags available, and could help with testing - please elaborate what to test and how. The referenced repos/branches a kind of outdated compared to latest RIOT master. And whats the difference to the code in this PR?

@yogo1212
Copy link
Copy Markdown
Contributor Author

@emmanuelsearch nice to know

@sming hi :-)
@haukepetersen

the code at https://github.com/benemorius/RIOT/tree/cc26x0_rfc_works is supposed to emit beacons but it isn't for me :-(
can someone confirm it's working?

@miri64
Copy link
Copy Markdown
Member

miri64 commented Jun 20, 2017

@smlng ping?

@sming
Copy link
Copy Markdown

sming commented Jun 20, 2017 via email

@miri64
Copy link
Copy Markdown
Member

miri64 commented Jun 20, 2017

@sming that's why I pinged @smlng ;-). And sorry for including you into this discussion :-/.

@aabadie aabadie modified the milestone: Release 2017.07 Jun 23, 2017
This was referenced Oct 29, 2017
@kYc0o kYc0o removed this from the Release 2017.10 milestone Oct 30, 2017
@smlng smlng added the State: archived State: The PR has been archived for possible future re-adaptation label May 23, 2018
@smlng
Copy link
Copy Markdown
Member

smlng commented May 23, 2018

No progress > 1 year, closing as memo for now.

@smlng smlng closed this May 23, 2018
@yogo1212
Copy link
Copy Markdown
Contributor Author

@smlng ack

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: drivers Area: Device drivers Platform: ARM Platform: This PR/issue effects ARM-based platforms State: archived State: The PR has been archived for possible future re-adaptation State: WIP State: The PR is still work-in-progress and its code is not in its final presentable form yet Type: new feature The issue requests / The PR implemements a new feature for RIOT

Projects

None yet

Development

Successfully merging this pull request may close these issues.