Not sure about the dspi requirements, but this is how to align data. Say I wanted a struct to wrap around some standard types to meet some (usually) hardware requirements. Here are two versions that align and don't align data so it gets padded on specific boundaries. The aligned version forces data to the expected 4+4+2+1+2=13 byte size. Try sizeof() on the two versions and you will see the difference. You can also dump memory to see these alignments using the utility below.
struct __attribute__ ((__packed__)) AlignedData {
	int intVar1		__attribute__ ( ( aligned( 4 ) ) ) ;		//4 bytes
	int intVar2		__attribute__ ( ( aligned( 4 ) ) );		//4 + 4 = 8 bytes
	WORD wordVar3	__attribute__ ( ( aligned( 2 ) ) );		//8 + 2 = 10 bytes
	BYTE byteVar4	__attribute__ ( ( aligned( 1 ) ) );		//10 + 1 = 11 bytes
	WORD ADcount	__attribute__ ( ( aligned( 4 ) ) );		//11 + 2 = 13 bytes
}
struct NonAlignedData {
	int intVar1		;		//4 bytes
	int intVar2		;		//4 + 4 = 8 bytes
	WORD wordVar3	;		//8 + 2 = 10 bytes
	BYTE byteVar4	;		//10 + 1 = 11 bytes
	WORD ADcount	;		//11 + 2 = 13 bytes --- NOPE!
}
Here's a modification of the NB ShowData() from utils.cpp that shows the addresses too:
Code: Select all
void ShowAddrAndData( PBYTE fromptr, unsigned int len )
{
// usage: ShowAddrAndData(  (PBYTE) BufToDump, NumBytesToDump ); 
   PBYTE pPos = fromptr;
   unsigned int left = len;
   unsigned int i;
   while ( left > 16 )
   {
      for ( i = 0; i < 16; i++ )
      {
         if( i == 0) {
         	iprintf( "%p: ", pPos);			// print addr 
         }
         iprintf( "%02x ", ( unsigned ) * ( pPos + i ) );
      }
      putchar( ' ' );
      for ( i = 0; i < 16; i++ )
      {
         char c = ( char ) ( *( pPos + i ) );
         if ( c < ' ' )
         {
            putchar( '.' );
         }
         else
         {
            putchar( c );
         }
      }
      putchar( '\r' );
      putchar( '\n' );
      pPos += 16;
      left -= 16;
      OSTimeDly(1);
   }
   for ( i = 0; i < left; i++ )
   {
		if( i == 0) {
        	iprintf( "%p: ", pPos ); 		// print addr
         }iprintf( "%02x ", ( unsigned ) * ( pPos + i ) );
   }
   for ( ; i < 16; i++ )
   {
      iprintf( " . " );
   }
   putchar( ' ' );
   for ( i = 0; i < left; i++ )
   {
      char c = ( char ) ( *( pPos + i ) );
      if ( c < ' ' )
      {
         putchar( '.' );
      }
      else
      {
         putchar( c );
      }
   }
   puts( "\n" );
}
For an overview of aligning data see: 
http://www-01.ibm.com/support/knowledge ... AP?lang=en
or 
http://www.ibm.com/developerworks/library/pa-dalign/
For details of the aligned attribute, see: 
http://www-01.ibm.com/support/knowledge ... ED?lang=en
for details of the packed attribute, see: 
http://www-01.ibm.com/support/knowledge ... ED?lang=en