Beispiel #1
0
/**
 * Formats a file into a on-disk list file on top of BlockMgr.
 */
int
ListFormat(char* fileName){
   BlockMgrHandle* handle;
   DiskListHeader header;
   BinaryStr str;
   DiskListNode head;
   uint8_t newPtr;

   if (BlockMgrFormatFile(fileName,0)){
      printf("BlockMgr format failed.\n");
      return -1;
   }
   if (BlockMgrInitHandle(fileName,0,&handle)) {
      printf("BlockMgr init failed.\n");
      return -1;
   }
   header.magic = MAGIC;
   _SO(&header.head,0);
   header.numNodes = 0;

   BlockMgrDiskPtr ptr;
   _SO(&head.next,0);
   _SO(&head.prev,0);
   // indicate this is new dat
   _SO(&ptr,0);
   str.data= (char*) &head;
   str.len = sizeof(head);
   BlockMgrDataWrite(handle,&str,&ptr,&newPtr) ;
   // new data has to be allocated
   assert(newPtr);
   // Circular linked list
   head.next = ptr;
   head.prev = ptr;

   BlockMgrDataWrite(handle,&str,&ptr,&newPtr) ;
   // should write to the same location
   assert(!newPtr);
   header.head = ptr;
   str.data = (char*)&header;
   str.len  = sizeof(header);
   // Set our super block
   assert(BlockMgrSetUserData(handle,&str));
   return 0;
}
Beispiel #2
0
int ListAddAfter(DiskList* dList,ListNode *node,BinaryStr data) {
   ListNode* newNode = ListNodeInit(data);
   assert(newNode);
   _SO(&newNode->curPtr,0);
   newNode->nodePtr->prev = node->curPtr; 
   newNode->nodePtr->next = node->nodePtr->next; 
   if (ListNodeWrite(dList,newNode)) {
      ListNodeFree(newNode);
      return -1;
   }
   node->nodePtr->next = node->curPtr;
   ListNodeFree(newNode);
   return 0;
  // node->nodePtr->next   = node->curPtr;
}
Beispiel #3
0
 * limitations under the License.
 *
 * Ported to NXP LPC43XX by Micromint USA <*****@*****.**>
 */
#include "mbed_assert.h"
#include "port_api.h"
#include "pinmap.h"
#include "gpio_api.h"

// Lookup table to determine SCU offset for GPIO [port][pin]
// Supports eight 16-bit ports to limit table size
#define _SO(MBED_PIN)            (MBED_PIN >> 18)

static const uint8_t _scu_off[][16] =
{   // GPIO0 to GPIO3
    { _SO(GPIO0_0),  _SO(GPIO0_1),  _SO(GPIO0_2),  _SO(GPIO0_3),
      _SO(GPIO0_4),  _SO(GPIO0_5),  _SO(GPIO0_6),  _SO(GPIO0_7),
      _SO(GPIO0_8),  _SO(GPIO0_9),  _SO(GPIO0_10), _SO(GPIO0_11),
      _SO(GPIO0_12), _SO(GPIO0_13), _SO(GPIO0_14), _SO(GPIO0_15)
    },
    { _SO(GPIO1_0),  _SO(GPIO1_1),  _SO(GPIO1_2),  _SO(GPIO1_3),
      _SO(GPIO1_4),  _SO(GPIO1_5),  _SO(GPIO1_6),  _SO(GPIO1_7),
      _SO(GPIO1_8),  _SO(GPIO1_9),  _SO(GPIO1_10), _SO(GPIO1_11),
      _SO(GPIO1_12), _SO(GPIO1_13), _SO(GPIO1_14), _SO(GPIO1_15)
    },
    { _SO(GPIO2_0),  _SO(GPIO2_1),  _SO(GPIO2_2),  _SO(GPIO2_3),
      _SO(GPIO2_4),  _SO(GPIO2_5),  _SO(GPIO2_6),  _SO(GPIO2_7),
      _SO(GPIO2_8),  _SO(GPIO2_9),  _SO(GPIO2_10), _SO(GPIO2_11),
      _SO(GPIO2_12), _SO(GPIO2_13), _SO(GPIO2_14), _SO(GPIO2_15)
    },
    { _SO(GPIO3_0),  _SO(GPIO3_1),  _SO(GPIO3_2),  _SO(GPIO3_3),