Click here to Skip to main content
15,891,657 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: how to create client and server winsock in one project or use 2 winsock in one project? Pin
Luc Pattyn25-Sep-10 13:37
sitebuilderLuc Pattyn25-Sep-10 13:37 
GeneralRe: how to create client and server winsock in one project or use 2 winsock in one project? Pin
Richard MacCutchan25-Sep-10 21:29
mveRichard MacCutchan25-Sep-10 21:29 
GeneralRe: how to create client and server winsock in one project or use 2 winsock in one project? Pin
zhiyuan1625-Sep-10 23:11
zhiyuan1625-Sep-10 23:11 
GeneralRe: how to create client and server winsock in one project or use 2 winsock in one project? Pin
Moak25-Sep-10 23:52
Moak25-Sep-10 23:52 
GeneralRe: how to create client and server winsock in one project or use 2 winsock in one project? Pin
zhiyuan1625-Sep-10 23:57
zhiyuan1625-Sep-10 23:57 
GeneralRe: how to create client and server winsock in one project or use 2 winsock in one project? Pin
Moak26-Sep-10 0:59
Moak26-Sep-10 0:59 
GeneralRe: how to create client and server winsock in one project or use 2 winsock in one project? Pin
Richard MacCutchan26-Sep-10 1:04
mveRichard MacCutchan26-Sep-10 1:04 
QuestionMemory aligned bit fields Pin
Trevor Johansen24-Sep-10 21:34
Trevor Johansen24-Sep-10 21:34 
I have been using the following code to access individual bits of memory to use as bit fields for a white but I am not really sure how the heck it works. I now need some extended functionality and as I do not understand how it works I can not upgrade it myself.

struct bits {
  uint8_t b0:1;
  uint8_t b1:1;
  uint8_t b2:1;
  uint8_t b3:1;
  uint8_t b4:1;
  uint8_t b5:1;
  uint8_t b6:1;
  uint8_t b7:1;
} __attribute__((__packed__));

#define FMAN(ADDR,FLAG) ((*(volatile struct bits*)&ADDR).b##FLAG)
#define FIFO_EOF FMAN(0x20,1)

FIFO_EOF = 1;

expands to:

((*(volatile struct flags*)&_SFR_IO8(0x20)).b##1) = 1;


Theirs a few casts and pointers in their to make it confusing but Im going on an understanding that it is taking the value of the bits structure and applying the rusult to the memory location 0x20. I wish to upgrade this functionality by using c++ and some added structure so I could have a bitfeld access like below.

Memory location: 0x14000000
bitfield: RX0E, TX0E, RXB0E, TXB0E ..... etc


I would need to somehow initilize my custom bitfiled to the memory location easily so I can include it in my communications class. So in my code I would have the ability to set the entire bitfiled with one word or by individual bits.

COMMS->FLAGS = 0x90000000 // To set RX0E and TXB0E
COMMS->FLAGS->RX0E = 1;   // to set just RX0E
if(COMMS->FLAGS->TXB0E) // Much easier to read than & 0x1000000



Does that make since? I know its possible as all the source code I have poked around in for ARM based processors use this exact method but the implementations are closed source and I have never figured it out. I use GCC if you are wondering.

Anyone care to take a show at helping me figure out how it works and then how to get my desired results? Thanks!
AnswerRe: Memory aligned bit fields Pin
Luc Pattyn24-Sep-10 23:02
sitebuilderLuc Pattyn24-Sep-10 23:02 
AnswerRe: Memory aligned bit fields Pin
Alain Rist24-Sep-10 23:53
Alain Rist24-Sep-10 23:53 
AnswerRe: Memory aligned bit fields Pin
Aescleal25-Sep-10 0:56
Aescleal25-Sep-10 0:56 
AnswerRe: Memory aligned bit fields Pin
Trevor Johansen25-Sep-10 6:51
Trevor Johansen25-Sep-10 6:51 
AnswerRe: Memory aligned bit fields Pin
Aescleal25-Sep-10 7:26
Aescleal25-Sep-10 7:26 
GeneralRe: Memory aligned bit fields Pin
Trevor Johansen25-Sep-10 8:40
Trevor Johansen25-Sep-10 8:40 
AnswerRe: Memory aligned bit fields Pin
Aescleal25-Sep-10 10:07
Aescleal25-Sep-10 10:07 
GeneralRe: Memory aligned bit fields Pin
Trevor Johansen25-Sep-10 11:15
Trevor Johansen25-Sep-10 11:15 
AnswerRe: Memory aligned bit fields Pin
Luc Pattyn25-Sep-10 8:55
sitebuilderLuc Pattyn25-Sep-10 8:55 
GeneralRe: Memory aligned bit fields Pin
Trevor Johansen25-Sep-10 9:34
Trevor Johansen25-Sep-10 9:34 
GeneralRe: Memory aligned bit fields Pin
Luc Pattyn25-Sep-10 9:45
sitebuilderLuc Pattyn25-Sep-10 9:45 
GeneralRe: Memory aligned bit fields Pin
Trevor Johansen25-Sep-10 10:57
Trevor Johansen25-Sep-10 10:57 
AnswerRe: Memory aligned bit fields Pin
Luc Pattyn25-Sep-10 11:18
sitebuilderLuc Pattyn25-Sep-10 11:18 
GeneralRe: Memory aligned bit fields Pin
Trevor Johansen25-Sep-10 11:56
Trevor Johansen25-Sep-10 11:56 
GeneralRe: Memory aligned bit fields Pin
Luc Pattyn25-Sep-10 12:14
sitebuilderLuc Pattyn25-Sep-10 12:14 
GeneralRe: Memory aligned bit fields Pin
Alain Rist25-Sep-10 9:57
Alain Rist25-Sep-10 9:57 
GeneralRe: Memory aligned bit fields Pin
Aescleal25-Sep-10 10:19
Aescleal25-Sep-10 10:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.