Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6195789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:31:45+00:00 2026-05-24T03:31:45+00:00

I have an existing code base for an embedded system with no operating system.

  • 0

I have an existing code base for an embedded system with no operating system. I’m trying to get it to build with the x86 gcc instead of just the cross compiler, as a first step toward being able to unit test on the host. Unfortunately there are direct register reads and writes all over the place, instead of using the provided abstraction layer. One option of course is to fix that; replace the direct register access with calls to the GPIO access functions. I’m hoping to get up to speed faster by introducing a macro (used in the x86 build only) to redefine pieces of the code like

myvar = (GPIOC->IDR >> 6) & 0x03;   // Read bits 6 and 7
GPIOD->CRL &= 0xFFFFFF0F;

to something like:

myvar = (myGpiocIdrReadFunc() >> 6) & 0x03;   // Read bits 6 and 7
myGpiodClrWriteFunc() &= 0xFFFFFF0F;

GPIOx’s are #defined as pointers to a physical address. Of course if I try to read and write directly to addresses on my PC with an executable built with x86, that would be access violation. Unfortunately if I try something like this:

#define GPIOC->IDR { myGpiocIdrReadFunc() }

the compiler doesn’t like that “->”, saying “missing whitespace after the macro name.”

If you’ve solved this kind of problem before, how did you do it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T03:31:46+00:00Added an answer on May 24, 2026 at 3:31 am
    typedef struct {
        int IDR;
        int CRL;
    } gpio_t;
    
    gpio_t c;
    gpio_t d;
    
    gpio_t * GPIOC = &c;
    gpio_t * GPIOD = &d;
    

    Just keep adding registers like IDR to the struct as the compiler screams at you.

    EDIT I edited the answer after I saw your comment that you actually want to simulate the values, this way you can, but bear in mind that you need to initialized them like in your hardware.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just joined a project with a rather large existing code base. We
I have an existing website that uses the same code base, but is deployed
I have been trying to learn how to add testing to existing code --
I have an existing code base that is not packaged at all. The code
I have inherited an existing code base where the features are as follows: huge
I have some existing code that retrieves data from a database using ADO.NET that
I have to analyse some existing Erlang code. Does anybody knows about a tool
If I have an existing database, I want to be able to automatically code
We have a large ASP classic code base but I'm looking to do future
I have an existing codebase targeting a Windows environment and with an eye to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.