MCP23S17 not working

Sorry for my broken English in advance.

I am trying to make my atsam4ls2b communicate with an mcp23s17. However, I can not get it to work. I am sending what i think is the correct data over the Mosi pin to the mcp23s17, and when checking the pins with a multimeter I can see that it arrives at the mcp23s17. however it seems like it does nothing with the data. I am hoping anyone can help me out with this problem. Below is my code which is in a loop. it should set all gpio pins to output 3.3v, but it outputs nothing.

SPICon->StartTransaction();
SPICon->Transceive(0x40);//select standard first 4 bits(0100) with opcode 000(A2-A1-A0)(opcode is not used for now) and R/W bit on Write (0) (0100-000-0)
SPICon->Transceive(0x0A);//select IO control register
SPICon->Transceive(0x38);//disable slew rate, sequential and enables address pins
SPICon->EndTransaction();

SPICon->StartTransaction();
SPICon->Transceive(0x40);//select standard first 4 bits(0100) with opcode 000(A2-A1-A0)(opcode is not used for now) and R/W bit on Write (0) (0100-000-0)
SPICon->Transceive(0x0B);//select IO control register
SPICon->Transceive(0x38);//disable slew rate, sequential and enables address pins
SPICon->EndTransaction();

SPICon->StartTransaction();
SPICon->Transceive(0x40);//select standard first 4 bits(0100) with opcode 000(A2-A1-A0)(opcode is not used for now) and R/W bit on Write (0) (0100-000-0)
SPICon->Transceive(0x00);//select IO direction register A
SPICon->Transceive(0x00);//set all pins to output
SPICon->EndTransaction();

SPICon->StartTransaction();
SPICon->Transceive(0x40);//select standard first 4 bits(0100) with opcode 000(A2-A1-A0)(opcode is not used for now) and R/W bit on Write (0) (0100-000-0)
SPICon->Transceive(0x01);//select IO direction register B
SPICon->Transceive(0x00);//set all pins to output
SPICon->EndTransaction();

SPICon->StartTransaction();
SPICon->Transceive(0x40);//select standard first 4 bits(0100) with opcode 000(A2-A1-A0)(opcode is not used for now) and R/W bit on Write (0) (0100-000-0)
SPICon->Transceive(0x14);//select Latch A
SPICon->Transceive(0xFF);//set pins to high
SPICon->EndTransaction();

SPICon->StartTransaction();
SPICon->Transceive(0x40);//select standard first 4 bits(0100) with opcode 000(A2-A1-A0)(opcode is not used for now) and R/W bit on Write (0) (0100-000-0)
SPICon->Transceive(0x15);//select Latch B
SPICon->Transceive(0xFF);//set pins to high
SPICon->EndTransaction();


where the transceive function is:

uint8_t SoftwareSPI::Transceive(uint8_t DataOut)
{
uint8_t DataIn = 0;

for(int i = 0; i < 8; i++)
{
MoSiPin->SetValue((DataOut >> (7 - i) & 0x01) ? GpioValue::High : GpioValue::Low);
ClockPin->SetValue(GpioValue::High);

DelayUs(20);

GpioValue MisoValue = MiSoPin->GetValue();

DataIn |= (((uint8_t)MisoValue) << (7 - i));
ClockPin->SetValue(GpioValue::Low);

DelayUs(20);
}

return DataIn;
}


which basicly does: set the mosi pin to the the value of bit i in the byte DataOut -> set the clock pin to high -> delay to make sure changes go through -> put the value of the miso in in bit i of the byte DataIn -> set the clock pin to low -> delay again to make sure changes go through

this happens 8x so it goes through the whole byte.

the StartTransaction and EndTransaction just pull the CS down and up.

the address pins are all 3 connected to the ground, the mosi pin is connected to pinA22, miso to pinA21, clock to pinA20, chipselect to pinB04, vdd and vss are connected to 3.3V and ground. all gpios are just connected to a led for now.

I am using Atmel Studio 7 as compiler. the program uses some custom made libraries which have been tested correct.

Can anyone see what is wrong here?